mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
adds assigned bool for ip address API #13151
This commit is contained in:
parent
006c353d46
commit
f3fe05b476
@ -591,6 +591,10 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
|||||||
method='_assigned_to_interface',
|
method='_assigned_to_interface',
|
||||||
label=_('Is assigned to an interface'),
|
label=_('Is assigned to an interface'),
|
||||||
)
|
)
|
||||||
|
assigned = django_filters.BooleanFilter(
|
||||||
|
method='_assigned',
|
||||||
|
label=_('Is assigned'),
|
||||||
|
)
|
||||||
status = django_filters.MultipleChoiceFilter(
|
status = django_filters.MultipleChoiceFilter(
|
||||||
choices=IPAddressStatusChoices,
|
choices=IPAddressStatusChoices,
|
||||||
null_value=None
|
null_value=None
|
||||||
@ -706,6 +710,18 @@ class IPAddressFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
|||||||
assigned_object_id__isnull=False
|
assigned_object_id__isnull=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _assigned(self, queryset, name, value):
|
||||||
|
if value:
|
||||||
|
return queryset.exclude(
|
||||||
|
assigned_object_type__isnull=True,
|
||||||
|
assigned_object_id__isnull=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return queryset.filter(
|
||||||
|
assigned_object_type__isnull=True,
|
||||||
|
assigned_object_id__isnull=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FHRPGroupFilterSet(NetBoxModelFilterSet):
|
class FHRPGroupFilterSet(NetBoxModelFilterSet):
|
||||||
protocol = django_filters.MultipleChoiceFilter(
|
protocol = django_filters.MultipleChoiceFilter(
|
||||||
|
Loading…
Reference in New Issue
Block a user