Fixes #9653 - Add default_platform to DeviceType

This commit is contained in:
kkthxbye-code
2023-02-10 21:57:23 +01:00
committed by jeremystretch
parent a1c9f7a2c6
commit 81b8046d1d
12 changed files with 108 additions and 13 deletions

View File

@@ -374,6 +374,10 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
queryset=Manufacturer.objects.all(),
required=False
)
default_platform = DynamicModelChoiceField(
queryset=Platform.objects.all(),
required=False
)
part_number = forms.CharField(
required=False
)
@@ -412,7 +416,7 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
model = DeviceType
fieldsets = (
('Device Type', ('manufacturer', 'part_number', 'u_height', 'is_full_depth', 'airflow', 'description')),
('Device Type', ('manufacturer', 'default_platform', 'part_number', 'u_height', 'is_full_depth', 'airflow', 'description')),
('Weight', ('weight', 'weight_unit')),
)
nullable_fields = ('part_number', 'airflow', 'weight', 'weight_unit', 'description', 'comments')

View File

@@ -281,12 +281,17 @@ class DeviceTypeImportForm(NetBoxModelImportForm):
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
default_platform = forms.ModelChoiceField(
queryset=Platform.objects.all(),
to_field_name='name',
required=False,
)
class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'description', 'comments',
'manufacturer', 'default_platform', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth',
'subdevice_role', 'airflow', 'description', 'comments',
]

View File

@@ -378,7 +378,7 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm):
model = DeviceType
fieldsets = (
(None, ('q', 'filter_id', 'tag')),
('Hardware', ('manufacturer_id', 'part_number', 'subdevice_role', 'airflow')),
('Hardware', ('manufacturer_id', 'default_platform_id', 'part_number', 'subdevice_role', 'airflow')),
('Images', ('has_front_image', 'has_rear_image')),
('Components', (
'console_ports', 'console_server_ports', 'power_ports', 'power_outlets', 'interfaces',
@@ -391,6 +391,11 @@ class DeviceTypeFilterForm(NetBoxModelFilterSetForm):
required=False,
label=_('Manufacturer')
)
default_platform_id = DynamicModelMultipleChoiceField(
queryset=Platform.objects.all(),
required=False,
label=_('Default platform')
)
part_number = forms.CharField(
required=False
)

View File

@@ -378,13 +378,17 @@ class DeviceTypeForm(NetBoxModelForm):
manufacturer = DynamicModelChoiceField(
queryset=Manufacturer.objects.all()
)
default_platform = DynamicModelChoiceField(
queryset=Platform.objects.all(),
required=False
)
slug = SlugField(
slug_source='model'
)
comments = CommentField()
fieldsets = (
('Device Type', ('manufacturer', 'model', 'slug', 'description', 'tags')),
('Device Type', ('manufacturer', 'model', 'slug', 'description', 'tags', 'default_platform')),
('Chassis', (
'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit',
)),
@@ -395,7 +399,7 @@ class DeviceTypeForm(NetBoxModelForm):
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'weight', 'weight_unit', 'front_image', 'rear_image', 'description', 'comments', 'tags',
'weight', 'weight_unit', 'front_image', 'rear_image', 'description', 'comments', 'tags', 'default_platform'
]
widgets = {
'airflow': StaticSelect(),