1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Avoid component_type on subclasses

This commit is contained in:
Jonathan Senecal
2020-06-10 22:10:45 -04:00
parent e3a8638471
commit cf81a8979f
2 changed files with 3 additions and 6 deletions

View File

@ -2727,7 +2727,6 @@ class InterfaceForm(InterfaceCommonForm, BootstrapMixin, forms.ModelForm):
class InterfaceCreateForm(InterfaceCommonForm, LabeledComponentForm): class InterfaceCreateForm(InterfaceCommonForm, LabeledComponentForm):
component_type = 'interface'
device = DynamicModelChoiceField( device = DynamicModelChoiceField(
queryset=Device.objects.prefetch_related('device_type__manufacturer') 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']), form_from_model(Interface, ['type', 'enabled', 'mtu', 'mgmt_only', 'description', 'tags']),
DeviceBulkAddComponentForm DeviceBulkAddComponentForm
): ):
component_type = 'interface' pass
class InterfaceBulkEditForm( class InterfaceBulkEditForm(

View File

@ -808,8 +808,6 @@ class LabeledComponentForm(BootstrapMixin, forms.Form):
""" """
Base form for adding label pattern validation to `Create` forms Base form for adding label pattern validation to `Create` forms
""" """
component_type = 'port'
name_pattern = ExpandableNameField( name_pattern = ExpandableNameField(
label='Name' label='Name'
) )
@ -825,9 +823,9 @@ class LabeledComponentForm(BootstrapMixin, forms.Form):
label_pattern_count = len(self.cleaned_data['label_pattern']) label_pattern_count = len(self.cleaned_data['label_pattern'])
if label_pattern_count and name_pattern_count != label_pattern_count: if label_pattern_count and name_pattern_count != label_pattern_count:
raise forms.ValidationError({ 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( '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') }, code='label_pattern_mismatch')