First pass at making VLAN optional

This commit is contained in:
Seb Harrington 2024-05-03 10:20:11 +01:00
parent a10435e101
commit 242fe8e320
2 changed files with 2 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class DeviceMapFilterForm(BootstrapMixin, forms.Form):
) )
vlan = DynamicModelChoiceField( vlan = DynamicModelChoiceField(
queryset=VLAN.objects.all(), queryset=VLAN.objects.all(),
required=False,
label="VLAN", label="VLAN",
help_text="Filter devices by VLAN attached to any device interface", help_text="Filter devices by VLAN attached to any device interface",
query_params={"group_id": "$vlan_group"} query_params={"group_id": "$vlan_group"}

View File

@ -28,7 +28,7 @@ class MapView(PermissionRequiredMixin, View):
interfaces = Interface.objects.all() interfaces = Interface.objects.all()
vlan = form.cleaned_data['vlan'] 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() devices = Device.objects.filter(interfaces__in=interfaces).distinct()
if device_roles := form.cleaned_data['device_roles']: if device_roles := form.cleaned_data['device_roles']:
devices = devices.filter(device_role__in=device_roles) devices = devices.filter(device_role__in=device_roles)