mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 19:36:26 -06:00
Convert RACK_WIDTH_CHOICES to ChoiceSet
This commit is contained in:
parent
bcf56b59a7
commit
28c723350e
@ -118,7 +118,7 @@ class RackSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
|||||||
status = ChoiceField(choices=RACK_STATUS_CHOICES, required=False)
|
status = ChoiceField(choices=RACK_STATUS_CHOICES, required=False)
|
||||||
role = NestedRackRoleSerializer(required=False, allow_null=True)
|
role = NestedRackRoleSerializer(required=False, allow_null=True)
|
||||||
type = ChoiceField(choices=RackTypeChoices, required=False, allow_null=True)
|
type = ChoiceField(choices=RackTypeChoices, required=False, allow_null=True)
|
||||||
width = ChoiceField(choices=RACK_WIDTH_CHOICES, required=False)
|
width = ChoiceField(choices=RackWidthChoices, required=False)
|
||||||
outer_unit = ChoiceField(choices=RACK_DIMENSION_UNIT_CHOICES, required=False)
|
outer_unit = ChoiceField(choices=RACK_DIMENSION_UNIT_CHOICES, required=False)
|
||||||
tags = TagListSerializerField(required=False)
|
tags = TagListSerializerField(required=False)
|
||||||
device_count = serializers.IntegerField(read_only=True)
|
device_count = serializers.IntegerField(read_only=True)
|
||||||
|
@ -30,6 +30,17 @@ class RackTypeChoices(ChoiceSet):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RackWidthChoices(ChoiceSet):
|
||||||
|
|
||||||
|
WIDTH_19IN = 19
|
||||||
|
WIDTH_23IN = 23
|
||||||
|
|
||||||
|
CHOICES = (
|
||||||
|
(WIDTH_19IN, '19 inches'),
|
||||||
|
(WIDTH_23IN, '23 inches'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Console port type values
|
# Console port type values
|
||||||
#
|
#
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
# Rack widths
|
|
||||||
RACK_WIDTH_19IN = 19
|
|
||||||
RACK_WIDTH_23IN = 23
|
|
||||||
RACK_WIDTH_CHOICES = (
|
|
||||||
(RACK_WIDTH_19IN, '19 inches'),
|
|
||||||
(RACK_WIDTH_23IN, '23 inches'),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Rack faces
|
# Rack faces
|
||||||
RACK_FACE_FRONT = 0
|
RACK_FACE_FRONT = 0
|
||||||
RACK_FACE_REAR = 1
|
RACK_FACE_REAR = 1
|
||||||
|
@ -492,10 +492,7 @@ class RackCSVForm(forms.ModelForm):
|
|||||||
help_text='Rack type'
|
help_text='Rack type'
|
||||||
)
|
)
|
||||||
width = forms.ChoiceField(
|
width = forms.ChoiceField(
|
||||||
choices=(
|
choices=RackWidthChoices,
|
||||||
(RACK_WIDTH_19IN, '19'),
|
|
||||||
(RACK_WIDTH_23IN, '23'),
|
|
||||||
),
|
|
||||||
help_text='Rail-to-rail width (in inches)'
|
help_text='Rail-to-rail width (in inches)'
|
||||||
)
|
)
|
||||||
outer_unit = CSVChoiceField(
|
outer_unit = CSVChoiceField(
|
||||||
@ -598,7 +595,7 @@ class RackBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditFor
|
|||||||
widget=StaticSelect2()
|
widget=StaticSelect2()
|
||||||
)
|
)
|
||||||
width = forms.ChoiceField(
|
width = forms.ChoiceField(
|
||||||
choices=add_blank_choice(RACK_WIDTH_CHOICES),
|
choices=add_blank_choice(RackWidthChoices),
|
||||||
required=False,
|
required=False,
|
||||||
widget=StaticSelect2()
|
widget=StaticSelect2()
|
||||||
)
|
)
|
||||||
|
@ -504,8 +504,8 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
|
|||||||
verbose_name='Type'
|
verbose_name='Type'
|
||||||
)
|
)
|
||||||
width = models.PositiveSmallIntegerField(
|
width = models.PositiveSmallIntegerField(
|
||||||
choices=RACK_WIDTH_CHOICES,
|
choices=RackWidthChoices,
|
||||||
default=RACK_WIDTH_19IN,
|
default=RackWidthChoices.WIDTH_19IN,
|
||||||
verbose_name='Width',
|
verbose_name='Width',
|
||||||
help_text='Rail-to-rail width'
|
help_text='Rail-to-rail width'
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user