diff --git a/netbox/ipam/forms.py b/netbox/ipam/forms.py index 8714a03d9..9003f295c 100644 --- a/netbox/ipam/forms.py +++ b/netbox/ipam/forms.py @@ -1240,47 +1240,8 @@ class VLANGroupFilterForm(BootstrapMixin, forms.Form): # class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm): - region = DynamicModelChoiceField( - queryset=Region.objects.all(), - required=False, - initial_params={ - 'sites': '$site' - } - ) - site_group = DynamicModelChoiceField( - queryset=SiteGroup.objects.all(), - required=False, - initial_params={ - 'sites': '$site' - } - ) - site = DynamicModelChoiceField( - queryset=Site.objects.all(), - required=False, - null_option='None', - query_params={ - 'region_id': '$region', - 'group_id': '$site_group', - } - ) - location = DynamicModelChoiceField( - queryset=Location.objects.all(), - required=False, - null_option='None', - query_params={ - 'site_id': '$site', - } - ) - rack = DynamicModelChoiceField( - queryset=Rack.objects.all(), - required=False, - null_option='None', - query_params={ - 'site_id': '$site', - 'location_id': '$location', - } - ) - group_scope = forms.ChoiceField( + # VLANGroup assignment fields + scope_type = forms.ChoiceField( choices=( ('', ''), ('dcim.region', 'Region'), @@ -1297,14 +1258,39 @@ class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm): queryset=VLANGroup.objects.all(), required=False, query_params={ - 'scope_type': '$group_scope', - 'region': '$region', - 'sitegroup': '$site_group', - 'site': '$site', - 'location': '$location', - 'rack': '$rack', + 'scope_type': '$scope_type', + }, + label='VLAN Group' + ) + + # Site assignment fields + region = DynamicModelChoiceField( + queryset=Region.objects.all(), + required=False, + initial_params={ + 'sites': '$site' + }, + label='Region' + ) + sitegroup = DynamicModelChoiceField( + queryset=SiteGroup.objects.all(), + required=False, + initial_params={ + 'sites': '$site' + }, + label='Site group' + ) + site = DynamicModelChoiceField( + queryset=Site.objects.all(), + required=False, + null_option='None', + query_params={ + 'region_id': '$region', + 'group_id': '$sitegroup', } ) + + # Other fields role = DynamicModelChoiceField( queryset=Role.objects.all(), required=False @@ -1319,11 +1305,6 @@ class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm): fields = [ 'site', 'group', 'vid', 'name', 'status', 'role', 'description', 'tenant_group', 'tenant', 'tags', ] - fieldsets = ( - ('VLAN', ('vid', 'name', 'status', 'role', 'description', 'tags')), - ('Assignment', ('region', 'site_group', 'site', 'location', 'rack', 'group_scope', 'group')), - ('Tenancy', ('tenant_group', 'tenant')), - ) help_texts = { 'site': "Leave blank if this VLAN spans multiple sites", 'group': "VLAN group (optional)", diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 0e712817b..7e618ad1c 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -90,7 +90,7 @@ VLAN_ROLE_LINK = """ VLANGROUP_ADD_VLAN = """ {% with next_vid=record.get_next_available_vid %} {% if next_vid and perms.ipam.add_vlan %} - + {% endif %} diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 63d81d58e..f262a6a17 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -768,6 +768,7 @@ class VLANVMInterfacesView(generic.ObjectView): class VLANEditView(generic.ObjectEditView): queryset = VLAN.objects.all() model_form = forms.VLANForm + template_name = 'ipam/vlan_edit.html' class VLANDeleteView(generic.ObjectDeleteView): diff --git a/netbox/templates/ipam/vlan_edit.html b/netbox/templates/ipam/vlan_edit.html new file mode 100644 index 000000000..c86906e6c --- /dev/null +++ b/netbox/templates/ipam/vlan_edit.html @@ -0,0 +1,57 @@ +{% extends 'generic/object_edit.html' %} +{% load static %} +{% load form_helpers %} +{% load helpers %} + +{% block form %} +