Просмотр исходного кода

Closes #19738: Deprecate the direct assignment of a VLAN to a site (#19904)

Jeremy Stretch 7 месяцев назад
Родитель
Сommit
733dd81f0e
2 измененных файлов с 13 добавлено и 1 удалено
  1. 3 0
      docs/models/ipam/vlan.md
  2. 10 1
      netbox/ipam/forms/model_forms.py

+ 3 - 0
docs/models/ipam/vlan.md

@@ -25,6 +25,9 @@ The user-defined functional [role](./role.md) assigned to the VLAN.
 
 
 ### VLAN Group or Site
 ### VLAN Group or Site
 
 
+!!! warning "Site assignment is deprecated"
+    The assignment of individual VLANs directly to a site has been deprecated. This ability will be removed in a future NetBox release. Users are strongly encouraged to utilize VLAN groups, which have the added benefit of supporting the assignment of a VLAN to multiple sites.
+
 The [VLAN group](./vlangroup.md) or [site](../dcim/site.md) to which the VLAN is assigned.
 The [VLAN group](./vlangroup.md) or [site](../dcim/site.md) to which the VLAN is assigned.
 
 
 ### Q-in-Q Role
 ### Q-in-Q Role

+ 10 - 1
netbox/ipam/forms/model_forms.py

@@ -20,6 +20,7 @@ from utilities.forms.fields import (
 from utilities.forms.rendering import FieldSet, InlineFields, ObjectAttribute, TabbedGroups
 from utilities.forms.rendering import FieldSet, InlineFields, ObjectAttribute, TabbedGroups
 from utilities.forms.utils import get_field_value
 from utilities.forms.utils import get_field_value
 from utilities.forms.widgets import DatePicker, HTMXSelect
 from utilities.forms.widgets import DatePicker, HTMXSelect
+from django.utils.safestring import mark_safe
 from utilities.templatetags.builtins.filters import bettertitle
 from utilities.templatetags.builtins.filters import bettertitle
 from virtualization.models import VMInterface
 from virtualization.models import VMInterface
 
 
@@ -680,7 +681,15 @@ class VLANForm(TenancyForm, NetBoxModelForm):
         queryset=Site.objects.all(),
         queryset=Site.objects.all(),
         required=False,
         required=False,
         null_option='None',
         null_option='None',
-        selector=True
+        selector=True,
+        help_text=mark_safe(
+            '<span class="text-warning"><i class="mdi mdi-alert"></i> {text}</span>'.format(
+                text=_(
+                    'The direct assignment of VLANs to a site is deprecated and will be removed in a future release. '
+                    'Users are encouraged to utilize VLAN groups for this purpose.'
+                )
+            )
+        )
     )
     )
     role = DynamicModelChoiceField(
     role = DynamicModelChoiceField(
         label=_('Role'),
         label=_('Role'),