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

Closes #11670: Add ability to optionally import DeviceType and ModuleType weight (#12512)

* 11670: Add optional weight to DeviceType import

This is 1 of 2 commits to address issue #11670

To maintain consistency, the import design of the DeviceType weight follows the
same pattern used for importing weight and weight units in DCIM Racks.

* Closes #11670: Add weight to ModuleType import

This is commit 2 of 2 to address and close #11670.

To maintain consistency, the import design of the ModuleType weight follows the
same pattern used for importing weight and weight units in DCIM Racks.

* Merge tests; misc cleanup

---------

Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
Dillon Henschen
2023-05-09 09:59:42 -04:00
committed by GitHub
parent e1b7a3aeb6
commit c55c14ea4c
3 changed files with 45 additions and 5 deletions

View File

@ -292,12 +292,21 @@ class DeviceTypeImportForm(NetBoxModelImportForm):
required=False,
help_text=_('The default platform for devices of this type (optional)')
)
weight = forms.DecimalField(
required=False,
help_text=_('Device weight'),
)
weight_unit = CSVChoiceField(
choices=WeightUnitChoices,
required=False,
help_text=_('Unit for device weight')
)
class Meta:
model = DeviceType
fields = [
'manufacturer', 'default_platform', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth',
'subdevice_role', 'airflow', 'description', 'comments',
'subdevice_role', 'airflow', 'description', 'weight', 'weight_unit', 'comments',
]
@ -306,10 +315,19 @@ class ModuleTypeImportForm(NetBoxModelImportForm):
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
weight = forms.DecimalField(
required=False,
help_text=_('Module weight'),
)
weight_unit = CSVChoiceField(
choices=WeightUnitChoices,
required=False,
help_text=_('Unit for module weight')
)
class Meta:
model = ModuleType
fields = ['manufacturer', 'model', 'part_number', 'description', 'comments']
fields = ['manufacturer', 'model', 'part_number', 'description', 'weight', 'weight_unit', 'comments']
class DeviceRoleImportForm(NetBoxModelImportForm):