Просмотр исходного кода

fix(filtersets): Respect assigned object type for L2VPN terminations

Add the `assigned_object_type_id` filter to `L2VPNTerminationFilterSet`
so that the "Assigned object type" filter correctly restricts L2VPN
terminations by their assigned object type, using the `ObjectType` model
for lookups.

Fixes #20844
Martin Hauser 2 месяцев назад
Родитель
Сommit
d61737396b
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      netbox/vpn/filtersets.py

+ 5 - 0
netbox/vpn/filtersets.py

@@ -2,6 +2,7 @@ import django_filters
 from django.db.models import Q
 from django.utils.translation import gettext as _
 
+from core.models import ObjectType
 from dcim.models import Device, Interface
 from ipam.models import IPAddress, RouteTarget, VLAN
 from netbox.filtersets import NetBoxModelFilterSet, OrganizationalModelFilterSet
@@ -429,6 +430,10 @@ class L2VPNTerminationFilterSet(NetBoxModelFilterSet):
         queryset=VLAN.objects.all(),
         label=_('VLAN (ID)'),
     )
+    assigned_object_type_id = django_filters.ModelMultipleChoiceFilter(
+        queryset=ObjectType.objects.all(),
+        field_name='assigned_object_type'
+    )
     assigned_object_type = ContentTypeFilter()
 
     class Meta: