mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Removed prefix parent
filter (see #1684)
This commit is contained in:
@ -99,11 +99,6 @@ class PrefixFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
|||||||
method='search',
|
method='search',
|
||||||
label='Search',
|
label='Search',
|
||||||
)
|
)
|
||||||
# TODO: Deprecate in v2.3.0
|
|
||||||
parent = django_filters.CharFilter(
|
|
||||||
method='search_within_include',
|
|
||||||
label='Parent prefix (deprecated)',
|
|
||||||
)
|
|
||||||
within = django_filters.CharFilter(
|
within = django_filters.CharFilter(
|
||||||
method='search_within',
|
method='search_within',
|
||||||
label='Within prefix',
|
label='Within prefix',
|
||||||
@ -172,17 +167,6 @@ class PrefixFilter(CustomFieldFilterSet, django_filters.FilterSet):
|
|||||||
model = Prefix
|
model = Prefix
|
||||||
fields = ['family', 'is_pool']
|
fields = ['family', 'is_pool']
|
||||||
|
|
||||||
def search(self, queryset, name, value):
|
|
||||||
if not value.strip():
|
|
||||||
return queryset
|
|
||||||
qs_filter = Q(description__icontains=value)
|
|
||||||
try:
|
|
||||||
prefix = str(IPNetwork(value.strip()).cidr)
|
|
||||||
qs_filter |= Q(prefix__net_contains_or_equals=prefix)
|
|
||||||
except (AddrFormatError, ValueError):
|
|
||||||
pass
|
|
||||||
return queryset.filter(qs_filter)
|
|
||||||
|
|
||||||
def search_within(self, queryset, name, value):
|
def search_within(self, queryset, name, value):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
if not value:
|
if not value:
|
||||||
|
Reference in New Issue
Block a user