From 9a159dbdcd534a2f81a8dcc6b747531ac35d18b2 Mon Sep 17 00:00:00 2001 From: Dillon Henschen Date: Thu, 18 May 2023 02:19:30 -0400 Subject: [PATCH 1/2] Closes #11619: Allow VLANs without a site during multi-port edits This commit allows users to be able to select VLANs without a site assignment during bulk interfaces edits under Devices > DEVICE COMPONENTS > Interfaces. Prior to this commit, only VLANs that were assigned the same site as the device were available for selection. --- netbox/dcim/forms/bulk_edit.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 6ed483c7936..92f952de216 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -1292,8 +1292,9 @@ def __init__(self, *args, **kwargs): break if site is not None: - self.fields['untagged_vlan'].widget.add_query_param('site_id', site.pk) - self.fields['tagged_vlans'].widget.add_query_param('site_id', site.pk) + # Query for VLANs assigned to the same site and VLANs with no site assigned (null). + self.fields['untagged_vlan'].widget.add_query_param('site_id', [site.pk, 'null']) + self.fields['tagged_vlans'].widget.add_query_param('site_id', [site.pk, 'null']) self.fields['parent'].choices = () self.fields['parent'].widget.attrs['disabled'] = True From 17d68c4390ac7aaf80e3bb54d0f8a36a16430bdc Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 22 May 2023 14:48:50 -0400 Subject: [PATCH 2/2] Replace 'null' with FILTERS_NULL_CHOICE_VALUE constant --- netbox/dcim/forms/bulk_edit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/forms/bulk_edit.py b/netbox/dcim/forms/bulk_edit.py index 92f952de216..bc9693afbe0 100644 --- a/netbox/dcim/forms/bulk_edit.py +++ b/netbox/dcim/forms/bulk_edit.py @@ -1,4 +1,5 @@ from django import forms +from django.conf import settings from django.contrib.auth.models import User from django.utils.translation import gettext as _ from timezone_field import TimeZoneFormField @@ -1293,8 +1294,12 @@ def __init__(self, *args, **kwargs): if site is not None: # Query for VLANs assigned to the same site and VLANs with no site assigned (null). - self.fields['untagged_vlan'].widget.add_query_param('site_id', [site.pk, 'null']) - self.fields['tagged_vlans'].widget.add_query_param('site_id', [site.pk, 'null']) + self.fields['untagged_vlan'].widget.add_query_param( + 'site_id', [site.pk, settings.FILTERS_NULL_CHOICE_VALUE] + ) + self.fields['tagged_vlans'].widget.add_query_param( + 'site_id', [site.pk, settings.FILTERS_NULL_CHOICE_VALUE] + ) self.fields['parent'].choices = () self.fields['parent'].widget.attrs['disabled'] = True