mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
12826 make RackType.form_factor required (#17327)
* 12826 make RackType.form_factor required * 12826 fix tests
This commit is contained in:
parent
6db29880cc
commit
8fff4e2a5d
@ -39,7 +39,7 @@ class Migration(migrations.Migration):
|
|||||||
)),
|
)),
|
||||||
('model', models.CharField(max_length=100)),
|
('model', models.CharField(max_length=100)),
|
||||||
('slug', models.SlugField(max_length=100, unique=True)),
|
('slug', models.SlugField(max_length=100, unique=True)),
|
||||||
('form_factor', models.CharField(blank=True, max_length=50)),
|
('form_factor', models.CharField(max_length=50)),
|
||||||
('width', models.PositiveSmallIntegerField(default=19)),
|
('width', models.PositiveSmallIntegerField(default=19)),
|
||||||
('u_height', models.PositiveSmallIntegerField(
|
('u_height', models.PositiveSmallIntegerField(
|
||||||
default=42,
|
default=42,
|
||||||
|
@ -41,12 +41,6 @@ class RackBase(WeightMixin, PrimaryModel):
|
|||||||
"""
|
"""
|
||||||
Base class for RackType & Rack. Holds
|
Base class for RackType & Rack. Holds
|
||||||
"""
|
"""
|
||||||
form_factor = models.CharField(
|
|
||||||
choices=RackFormFactorChoices,
|
|
||||||
max_length=50,
|
|
||||||
blank=True,
|
|
||||||
verbose_name=_('form factor')
|
|
||||||
)
|
|
||||||
width = models.PositiveSmallIntegerField(
|
width = models.PositiveSmallIntegerField(
|
||||||
choices=RackWidthChoices,
|
choices=RackWidthChoices,
|
||||||
default=RackWidthChoices.WIDTH_19IN,
|
default=RackWidthChoices.WIDTH_19IN,
|
||||||
@ -125,6 +119,11 @@ class RackType(RackBase):
|
|||||||
Devices are housed within Racks. Each rack has a defined height measured in rack units, and a front and rear face.
|
Devices are housed within Racks. Each rack has a defined height measured in rack units, and a front and rear face.
|
||||||
Each Rack is assigned to a Site and (optionally) a Location.
|
Each Rack is assigned to a Site and (optionally) a Location.
|
||||||
"""
|
"""
|
||||||
|
form_factor = models.CharField(
|
||||||
|
choices=RackFormFactorChoices,
|
||||||
|
max_length=50,
|
||||||
|
verbose_name=_('form factor')
|
||||||
|
)
|
||||||
manufacturer = models.ForeignKey(
|
manufacturer = models.ForeignKey(
|
||||||
to='dcim.Manufacturer',
|
to='dcim.Manufacturer',
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
@ -246,6 +245,12 @@ class Rack(ContactsMixin, ImageAttachmentsMixin, RackBase):
|
|||||||
'outer_unit', 'mounting_depth', 'weight', 'weight_unit', 'max_weight',
|
'outer_unit', 'mounting_depth', 'weight', 'weight_unit', 'max_weight',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
form_factor = models.CharField(
|
||||||
|
choices=RackFormFactorChoices,
|
||||||
|
max_length=50,
|
||||||
|
blank=True,
|
||||||
|
verbose_name=_('form factor')
|
||||||
|
)
|
||||||
rack_type = models.ForeignKey(
|
rack_type = models.ForeignKey(
|
||||||
to='dcim.RackType',
|
to='dcim.RackType',
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
|
@ -287,9 +287,9 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
|
|||||||
Manufacturer.objects.bulk_create(manufacturers)
|
Manufacturer.objects.bulk_create(manufacturers)
|
||||||
|
|
||||||
rack_types = (
|
rack_types = (
|
||||||
RackType(manufacturer=manufacturers[0], model='Rack Type 1', slug='rack-type-1'),
|
RackType(manufacturer=manufacturers[0], model='Rack Type 1', slug='rack-type-1', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
RackType(manufacturer=manufacturers[0], model='Rack Type 2', slug='rack-type-2'),
|
RackType(manufacturer=manufacturers[0], model='Rack Type 2', slug='rack-type-2', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
RackType(manufacturer=manufacturers[0], model='Rack Type 3', slug='rack-type-3'),
|
RackType(manufacturer=manufacturers[0], model='Rack Type 3', slug='rack-type-3', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
)
|
)
|
||||||
RackType.objects.bulk_create(rack_types)
|
RackType.objects.bulk_create(rack_types)
|
||||||
|
|
||||||
@ -298,16 +298,19 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase):
|
|||||||
'manufacturer': manufacturers[1].pk,
|
'manufacturer': manufacturers[1].pk,
|
||||||
'model': 'Rack Type 4',
|
'model': 'Rack Type 4',
|
||||||
'slug': 'rack-type-4',
|
'slug': 'rack-type-4',
|
||||||
|
'form_factor': RackFormFactorChoices.TYPE_CABINET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'manufacturer': manufacturers[1].pk,
|
'manufacturer': manufacturers[1].pk,
|
||||||
'model': 'Rack Type 5',
|
'model': 'Rack Type 5',
|
||||||
'slug': 'rack-type-5',
|
'slug': 'rack-type-5',
|
||||||
|
'form_factor': RackFormFactorChoices.TYPE_CABINET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'manufacturer': manufacturers[1].pk,
|
'manufacturer': manufacturers[1].pk,
|
||||||
'model': 'Rack Type 6',
|
'model': 'Rack Type 6',
|
||||||
'slug': 'rack-type-6',
|
'slug': 'rack-type-6',
|
||||||
|
'form_factor': RackFormFactorChoices.TYPE_CABINET,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -346,9 +346,9 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
Manufacturer.objects.bulk_create(manufacturers)
|
Manufacturer.objects.bulk_create(manufacturers)
|
||||||
|
|
||||||
rack_types = (
|
rack_types = (
|
||||||
RackType(manufacturer=manufacturers[0], model='RackType 1', slug='rack-type-1',),
|
RackType(manufacturer=manufacturers[0], model='RackType 1', slug='rack-type-1', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
RackType(manufacturer=manufacturers[0], model='RackType 2', slug='rack-type-2',),
|
RackType(manufacturer=manufacturers[0], model='RackType 2', slug='rack-type-2', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
RackType(manufacturer=manufacturers[0], model='RackType 3', slug='rack-type-3',),
|
RackType(manufacturer=manufacturers[0], model='RackType 3', slug='rack-type-3', form_factor=RackFormFactorChoices.TYPE_CABINET,),
|
||||||
)
|
)
|
||||||
RackType.objects.bulk_create(rack_types)
|
RackType.objects.bulk_create(rack_types)
|
||||||
|
|
||||||
@ -369,6 +369,7 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'weight': 100,
|
'weight': 100,
|
||||||
'max_weight': 2000,
|
'max_weight': 2000,
|
||||||
'weight_unit': WeightUnitChoices.UNIT_POUND,
|
'weight_unit': WeightUnitChoices.UNIT_POUND,
|
||||||
|
'form_factor': RackFormFactorChoices.TYPE_CABINET,
|
||||||
'comments': 'Some comments',
|
'comments': 'Some comments',
|
||||||
'tags': [t.pk for t in tags],
|
'tags': [t.pk for t in tags],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user