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

Closes #1865: Add console port and console server port types

This commit is contained in:
Jeremy Stretch
2019-10-30 14:25:55 -04:00
parent c4dd76a748
commit bb30f64252
13 changed files with 253 additions and 24 deletions

View File

@@ -941,7 +941,7 @@ class ConsolePortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsolePortTemplate
fields = [
'device_type', 'name',
'device_type', 'name', 'type',
]
widgets = {
'device_type': forms.HiddenInput(),
@@ -952,6 +952,10 @@ class ConsolePortTemplateCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
type = forms.ChoiceField(
choices=CONSOLE_TYPE_CHOICES,
widget=StaticSelect2()
)
class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
@@ -959,7 +963,7 @@ class ConsoleServerPortTemplateForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsoleServerPortTemplate
fields = [
'device_type', 'name',
'device_type', 'name', 'type',
]
widgets = {
'device_type': forms.HiddenInput(),
@@ -970,6 +974,10 @@ class ConsoleServerPortTemplateCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
type = forms.ChoiceField(
choices=CONSOLE_TYPE_CHOICES,
widget=StaticSelect2()
)
class PowerPortTemplateForm(BootstrapMixin, forms.ModelForm):
@@ -1248,22 +1256,38 @@ class ComponentTemplateImportForm(BootstrapMixin, forms.ModelForm):
class ConsolePortTemplateImportForm(ComponentTemplateImportForm):
type = forms.ChoiceField(
choices=ConsolePortTypes.TYPE_CHOICES
)
class Meta:
model = ConsolePortTemplate
fields = [
'device_type', 'name',
'device_type', 'name', 'type',
]
def clean_type(self):
# Convert slug value to field integer value
slug = self.cleaned_data['type']
return ConsolePortTypes.slug_to_integer(slug)
class ConsoleServerPortTemplateImportForm(ComponentTemplateImportForm):
type = forms.ChoiceField(
choices=ConsolePortTypes.TYPE_CHOICES
)
class Meta:
model = ConsoleServerPortTemplate
fields = [
'device_type', 'name',
'device_type', 'name', 'type',
]
def clean_type(self):
# Convert slug value to field integer value
slug = self.cleaned_data['type']
return ConsolePortTypes.slug_to_integer(slug)
class PowerPortTemplateImportForm(ComponentTemplateImportForm):
@@ -2054,7 +2078,7 @@ class ConsolePortForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsolePort
fields = [
'device', 'name', 'description', 'tags',
'device', 'name', 'type', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
@@ -2065,6 +2089,10 @@ class ConsolePortCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
type = forms.ChoiceField(
choices=CONSOLE_TYPE_CHOICES,
widget=StaticSelect2(),
)
description = forms.CharField(
max_length=100,
required=False
@@ -2086,7 +2114,7 @@ class ConsoleServerPortForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsoleServerPort
fields = [
'device', 'name', 'description', 'tags',
'device', 'name', 'type', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
@@ -2097,6 +2125,10 @@ class ConsoleServerPortCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
type = forms.ChoiceField(
choices=CONSOLE_TYPE_CHOICES,
widget=StaticSelect2(),
)
description = forms.CharField(
max_length=100,
required=False
@@ -2111,6 +2143,11 @@ class ConsoleServerPortBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditF
queryset=ConsoleServerPort.objects.all(),
widget=forms.MultipleHiddenInput()
)
type = forms.ChoiceField(
choices=add_blank_choice(CONSOLE_TYPE_CHOICES),
required=False,
widget=StaticSelect2()
)
description = forms.CharField(
max_length=100,
required=False