mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 02:06:42 -06:00
#8580 add interface filters for connected
This commit is contained in:
parent
b702822857
commit
b4877e7fac
@ -1304,6 +1304,9 @@ class InterfaceFilterSet(
|
|||||||
to_field_name='rd',
|
to_field_name='rd',
|
||||||
label='VRF (RD)',
|
label='VRF (RD)',
|
||||||
)
|
)
|
||||||
|
is_occupied = django_filters.BooleanFilter(
|
||||||
|
method='filter_is_occupied'
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
@ -1359,6 +1362,12 @@ class InterfaceFilterSet(
|
|||||||
'wireless': queryset.filter(type__in=WIRELESS_IFACE_TYPES),
|
'wireless': queryset.filter(type__in=WIRELESS_IFACE_TYPES),
|
||||||
}.get(value, queryset.none())
|
}.get(value, queryset.none())
|
||||||
|
|
||||||
|
def filter_is_occupied(self, queryset, name, value):
|
||||||
|
if value:
|
||||||
|
return queryset.filter(Q(cable__isnull=False) | Q(mark_connected=True))
|
||||||
|
else:
|
||||||
|
return queryset.filter(cable__isnull=True, mark_connected=False)
|
||||||
|
|
||||||
|
|
||||||
class FrontPortFilterSet(
|
class FrontPortFilterSet(
|
||||||
ModularDeviceComponentFilterSet,
|
ModularDeviceComponentFilterSet,
|
||||||
|
@ -1009,6 +1009,7 @@ class InterfaceFilterForm(DeviceComponentFilterForm):
|
|||||||
('PoE', ('poe_mode', 'poe_type')),
|
('PoE', ('poe_mode', 'poe_type')),
|
||||||
('Wireless', ('rf_role', 'rf_channel', 'rf_channel_width', 'tx_power')),
|
('Wireless', ('rf_role', 'rf_channel', 'rf_channel_width', 'tx_power')),
|
||||||
('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')),
|
('Device', ('region_id', 'site_group_id', 'site_id', 'location_id', 'rack_id', 'virtual_chassis_id', 'device_id')),
|
||||||
|
('Connection', ('cabled', 'connected', 'is_occupied'))
|
||||||
)
|
)
|
||||||
kind = MultipleChoiceField(
|
kind = MultipleChoiceField(
|
||||||
choices=InterfaceKindChoices,
|
choices=InterfaceKindChoices,
|
||||||
@ -1087,6 +1088,24 @@ class InterfaceFilterForm(DeviceComponentFilterForm):
|
|||||||
label='VRF'
|
label='VRF'
|
||||||
)
|
)
|
||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
cabled = forms.NullBooleanField(
|
||||||
|
required=False,
|
||||||
|
widget=StaticSelect(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
connected = forms.NullBooleanField(
|
||||||
|
required=False,
|
||||||
|
widget=StaticSelect(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
is_occupied = forms.NullBooleanField(
|
||||||
|
required=False,
|
||||||
|
widget=StaticSelect(
|
||||||
|
choices=BOOLEAN_WITH_BLANK_CHOICES
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FrontPortFilterForm(DeviceComponentFilterForm):
|
class FrontPortFilterForm(DeviceComponentFilterForm):
|
||||||
|
Loading…
Reference in New Issue
Block a user