|
|
@@ -1667,12 +1667,14 @@ class CableFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
field_name='terminations__termination_type'
|
|
|
)
|
|
|
termination_a_id = MultiValueNumberFilter(
|
|
|
+ method='filter_by_cable_end_a',
|
|
|
field_name='terminations__termination_id'
|
|
|
)
|
|
|
termination_b_type = ContentTypeFilter(
|
|
|
field_name='terminations__termination_type'
|
|
|
)
|
|
|
termination_b_id = MultiValueNumberFilter(
|
|
|
+ method='filter_by_cable_end_b',
|
|
|
field_name='terminations__termination_id'
|
|
|
)
|
|
|
type = django_filters.MultipleChoiceFilter(
|
|
|
@@ -1730,6 +1732,18 @@ class CableFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
|
# Supported objects: device, rack, location, site
|
|
|
return queryset.filter(**{f'terminations___{name}__in': value}).distinct()
|
|
|
|
|
|
+ def filter_by_cable_end(self, queryset, name, value, side):
|
|
|
+ # Filter by termination id and cable_end type
|
|
|
+ return queryset.filter(**{f'{name}__in': value, 'terminations__cable_end': side}).distinct()
|
|
|
+
|
|
|
+ def filter_by_cable_end_a(self, queryset, name, value):
|
|
|
+ # Filter by termination id and cable_end type
|
|
|
+ return self.filter_by_cable_end(queryset, name, value, CableEndChoices.SIDE_A)
|
|
|
+
|
|
|
+ def filter_by_cable_end_b(self, queryset, name, value):
|
|
|
+ # Filter by termination id and cable_end type
|
|
|
+ return self.filter_by_cable_end(queryset, name, value, CableEndChoices.SIDE_B)
|
|
|
+
|
|
|
|
|
|
class CableTerminationFilterSet(BaseFilterSet):
|
|
|
termination_type = ContentTypeFilter()
|