88from netbox .filtersets import NetBoxModelFilterSet
99
1010from cesnet_service_path_plugin .models import Segment
11- from cesnet_service_path_plugin .models .custom_choices import StatusChoices
11+ from cesnet_service_path_plugin .models .custom_choices import StatusChoices , OwnershipTypeChoices
1212from cesnet_service_path_plugin .models .segment_types import SegmentTypeChoices
1313
1414logger = logging .getLogger (__name__ )
@@ -23,6 +23,7 @@ class SegmentFilterSet(NetBoxModelFilterSet):
2323 name = django_filters .CharFilter (lookup_expr = "icontains" )
2424 network_label = django_filters .CharFilter (lookup_expr = "icontains" )
2525 status = django_filters .MultipleChoiceFilter (choices = StatusChoices , null_value = None )
26+ ownership_type = django_filters .MultipleChoiceFilter (choices = OwnershipTypeChoices , null_value = None )
2627
2728 # Basic segment type filter
2829 segment_type = django_filters .MultipleChoiceFilter (
@@ -521,6 +522,7 @@ def search(self, queryset, name, value):
521522 network_label = Q (network_label__icontains = value )
522523 provider_segment_id = Q (provider_segment_id__icontains = value )
523524 status = Q (status__iexact = value )
525+ ownership_type = Q (ownership_type__iexact = value )
524526 segment_type = Q (segment_type__iexact = value )
525527
526528 return queryset .filter (
@@ -532,5 +534,6 @@ def search(self, queryset, name, value):
532534 | network_label
533535 | provider_segment_id
534536 | status
537+ | ownership_type
535538 | segment_type
536539 )
0 commit comments