From 0d39efdc44ec8ae1b64e98e5cbdd29420136bb33 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 9 Sep 2022 15:41:27 -0400 Subject: [PATCH] Clean up expandable field help texts --- netbox/dcim/forms/models.py | 2 +- netbox/dcim/forms/object_create.py | 27 ++++++++------------- netbox/utilities/forms/fields/expandable.py | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/netbox/dcim/forms/models.py b/netbox/dcim/forms/models.py index 01257d4d1..870ea5e22 100644 --- a/netbox/dcim/forms/models.py +++ b/netbox/dcim/forms/models.py @@ -1385,7 +1385,7 @@ class InterfaceForm(InterfaceCommonForm, ModularDeviceComponentForm): ) fieldsets = ( - ('Interface', ('device', 'module', 'name', 'type', 'speed', 'duplex', 'label', 'description', 'tags')), + ('Interface', ('device', 'module', 'name', 'label', 'type', 'speed', 'duplex', 'description', 'tags')), ('Addressing', ('vrf', 'mac_address', 'wwn')), ('Operation', ('mtu', 'tx_power', 'enabled', 'mgmt_only', 'mark_connected')), ('Related Interfaces', ('parent', 'bridge', 'lag')), diff --git a/netbox/dcim/forms/object_create.py b/netbox/dcim/forms/object_create.py index f9efe1b82..132dfab9f 100644 --- a/netbox/dcim/forms/object_create.py +++ b/netbox/dcim/forms/object_create.py @@ -39,7 +39,7 @@ class ComponentCreateForm(forms.Form): name = ExpandableNameField() label = ExpandableNameField( required=False, - help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)' + help_text='Alphanumeric ranges are supported. (Must match the number of objects being created.)' ) replication_fields = ('name', 'label') @@ -58,20 +58,6 @@ class ComponentCreateForm(forms.Form): }, code='label_pattern_mismatch') -# class ModularComponentTemplateCreateForm(ComponentCreateForm): -# """ -# Creation form for component templates that can be assigned to either a DeviceType *or* a ModuleType. -# """ -# name = ExpandableNameField( -# label='Name', -# help_text=""" -# Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range -# are not supported. Example: [ge,xe]-0/0/[0-9]. {module} is accepted as a substitution for -# the module bay position. -# """ -# ) - - # # Device component templates # @@ -179,7 +165,7 @@ class ModuleBayTemplateCreateForm(ComponentCreateForm, model_forms.ModuleBayTemp position = ExpandableNameField( label='Position', required=False, - help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)' + help_text='Alphanumeric ranges are supported. (Must match the number of objects being created.)' ) replication_fields = ('name', 'label', 'position') @@ -226,6 +212,13 @@ class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm): class Meta(model_forms.InterfaceForm.Meta): exclude = ('name', 'label') + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + if 'module' in self.fields: + self.fields['name'].help_text += ' The string {module} will be replaced with the position ' \ + 'of the assigned module, if any' + class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm): rear_port = forms.MultipleChoiceField( @@ -295,7 +288,7 @@ class ModuleBayCreateForm(ComponentCreateForm, model_forms.ModuleBayForm): position = ExpandableNameField( label='Position', required=False, - help_text='Alphanumeric ranges are supported. (Must match the number of names being created.)' + help_text='Alphanumeric ranges are supported. (Must match the number of objects being created.)' ) replication_fields = ('name', 'label', 'position') diff --git a/netbox/utilities/forms/fields/expandable.py b/netbox/utilities/forms/fields/expandable.py index 214775f03..fca370c26 100644 --- a/netbox/utilities/forms/fields/expandable.py +++ b/netbox/utilities/forms/fields/expandable.py @@ -22,7 +22,7 @@ class ExpandableNameField(forms.CharField): if not self.help_text: self.help_text = """ Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range - are not supported. Example: [ge,xe]-0/0/[0-9] + are not supported (example: [ge,xe]-0/0/[0-9]). """ def to_python(self, value):