From 242fe8e32003dbd0133a3004253bf4f10f292492 Mon Sep 17 00:00:00 2001 From: Seb Harrington Date: Fri, 3 May 2024 10:20:11 +0100 Subject: [PATCH] First pass at making VLAN optional --- netbox_device_map/forms.py | 1 + netbox_device_map/views.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox_device_map/forms.py b/netbox_device_map/forms.py index 980ea1a..2d5b9a5 100644 --- a/netbox_device_map/forms.py +++ b/netbox_device_map/forms.py @@ -15,6 +15,7 @@ class DeviceMapFilterForm(BootstrapMixin, forms.Form): ) vlan = DynamicModelChoiceField( queryset=VLAN.objects.all(), + required=False, label="VLAN", help_text="Filter devices by VLAN attached to any device interface", query_params={"group_id": "$vlan_group"} diff --git a/netbox_device_map/views.py b/netbox_device_map/views.py index 61c7b58..823bdd6 100644 --- a/netbox_device_map/views.py +++ b/netbox_device_map/views.py @@ -28,7 +28,7 @@ class MapView(PermissionRequiredMixin, View): interfaces = Interface.objects.all() vlan = form.cleaned_data['vlan'] - interfaces = interfaces.filter(Q(untagged_vlan=vlan) | Q(tagged_vlans=vlan)) + #interfaces = interfaces.filter(Q(untagged_vlan=vlan) | Q(tagged_vlans=vlan)) devices = Device.objects.filter(interfaces__in=interfaces).distinct() if device_roles := form.cleaned_data['device_roles']: devices = devices.filter(device_role__in=device_roles)