mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-30 04:16:24 -06:00
Move {module} substitution help text to main ComponentCreateForm.__init__ so it applies to all component types, and fix formatting
This commit is contained in:
parent
27d15615b3
commit
ba7dbcfc4f
@ -52,6 +52,19 @@ class ComponentCreateForm(forms.Form):
|
|||||||
# ComponentCreateView when creating objects.
|
# ComponentCreateView when creating objects.
|
||||||
replication_fields = ('name', 'label')
|
replication_fields = ('name', 'label')
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Components attached to a module need to present this standardized substitution help text.
|
||||||
|
if 'module' in self.fields:
|
||||||
|
help_text_parts = []
|
||||||
|
if self.fields['name'].help_text:
|
||||||
|
help_text_parts.append(self.fields['name'].help_text)
|
||||||
|
help_text_parts.append(_(
|
||||||
|
"The string <code>{module}</code> will be replaced with the position of the assigned module, if any."
|
||||||
|
))
|
||||||
|
self.fields['name'].help_text = ' '.join([str(x) for x in help_text_parts])
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
@ -243,14 +256,6 @@ class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm):
|
|||||||
class Meta(model_forms.InterfaceForm.Meta):
|
class Meta(model_forms.InterfaceForm.Meta):
|
||||||
exclude = ('name', 'label')
|
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):
|
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
||||||
device = DynamicModelChoiceField(
|
device = DynamicModelChoiceField(
|
||||||
|
Loading…
Reference in New Issue
Block a user