Clean up expandable field help texts

This commit is contained in:
jeremystretch 2022-09-09 15:41:27 -04:00
parent 1fd23daa07
commit 0d39efdc44
3 changed files with 12 additions and 19 deletions

View File

@ -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')),

View File

@ -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: <code>[ge,xe]-0/0/[0-9]</code>. {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 <code>{module}</code> 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')

View File

@ -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: <code>[ge,xe]-0/0/[0-9]</code>
are not supported (example: <code>[ge,xe]-0/0/[0-9]</code>).
"""
def to_python(self, value):