mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
9654 add weight fields to devices
This commit is contained in:
parent
d0bed830d7
commit
4f75d1e605
@ -307,6 +307,17 @@ class RackBulkEditForm(NetBoxModelBulkEditForm):
|
||||
'location', 'tenant', 'role', 'serial', 'asset_tag', 'outer_width', 'outer_depth', 'outer_unit', 'comments', 'weight'
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
# Validate weight/unit
|
||||
weight = self.cleaned_data.get('weight')
|
||||
weight_unit = self.cleaned_data.get('weight_unit')
|
||||
if weight and not weight_unit:
|
||||
raise forms.ValidationError({
|
||||
'weight_unit': "Must specify a unit when setting weight"
|
||||
})
|
||||
|
||||
|
||||
class RackReservationBulkEditForm(NetBoxModelBulkEditForm):
|
||||
user = forms.ModelChoiceField(
|
||||
@ -384,6 +395,17 @@ class DeviceTypeBulkEditForm(NetBoxModelBulkEditForm):
|
||||
)
|
||||
nullable_fields = ('part_number', 'airflow', 'weight')
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
# Validate weight/unit
|
||||
weight = self.cleaned_data.get('weight')
|
||||
weight_unit = self.cleaned_data.get('weight_unit')
|
||||
if weight and not weight_unit:
|
||||
raise forms.ValidationError({
|
||||
'weight_unit': "Must specify a unit when setting weight"
|
||||
})
|
||||
|
||||
|
||||
class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
|
||||
manufacturer = DynamicModelChoiceField(
|
||||
@ -411,6 +433,17 @@ class ModuleTypeBulkEditForm(NetBoxModelBulkEditForm):
|
||||
)
|
||||
nullable_fields = ('part_number', 'weight',)
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
# Validate weight/unit
|
||||
weight = self.cleaned_data.get('weight')
|
||||
weight_unit = self.cleaned_data.get('weight_unit')
|
||||
if weight and not weight_unit:
|
||||
raise forms.ValidationError({
|
||||
'weight_unit': "Must specify a unit when setting weight"
|
||||
})
|
||||
|
||||
|
||||
class DeviceRoleBulkEditForm(NetBoxModelBulkEditForm):
|
||||
color = ColorField(
|
||||
|
Loading…
Reference in New Issue
Block a user