From cf81a8979f13b0481156bc8f9b0037d02ffa82e5 Mon Sep 17 00:00:00 2001 From: Jonathan Senecal Date: Wed, 10 Jun 2020 22:10:45 -0400 Subject: [PATCH] Avoid `component_type` on subclasses --- netbox/dcim/forms.py | 3 +-- netbox/utilities/forms.py | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index ca706d6f2..81f8775ec 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -2727,7 +2727,6 @@ class InterfaceForm(InterfaceCommonForm, BootstrapMixin, forms.ModelForm): class InterfaceCreateForm(InterfaceCommonForm, LabeledComponentForm): - component_type = 'interface' device = DynamicModelChoiceField( queryset=Device.objects.prefetch_related('device_type__manufacturer') ) @@ -2816,7 +2815,7 @@ class InterfaceBulkCreateForm( form_from_model(Interface, ['type', 'enabled', 'mtu', 'mgmt_only', 'description', 'tags']), DeviceBulkAddComponentForm ): - component_type = 'interface' + pass class InterfaceBulkEditForm( diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py index 8e80168ab..1dfa3d608 100644 --- a/netbox/utilities/forms.py +++ b/netbox/utilities/forms.py @@ -808,8 +808,6 @@ class LabeledComponentForm(BootstrapMixin, forms.Form): """ Base form for adding label pattern validation to `Create` forms """ - component_type = 'port' - name_pattern = ExpandableNameField( label='Name' ) @@ -825,9 +823,9 @@ class LabeledComponentForm(BootstrapMixin, forms.Form): label_pattern_count = len(self.cleaned_data['label_pattern']) if label_pattern_count and name_pattern_count != label_pattern_count: raise forms.ValidationError({ - 'label_pattern': 'The provided name pattern will create {} {}s, however {} labels will ' + 'label_pattern': 'The provided name pattern will create {} components, however {} labels will ' 'be generated. These counts must match.'.format( - name_pattern_count, self.component_type, label_pattern_count) + name_pattern_count, label_pattern_count) }, code='label_pattern_mismatch')