mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 00:28:16 -06:00
17058 RackType name -> model
This commit is contained in:
parent
1a6406632a
commit
c2b325974a
@ -73,12 +73,12 @@ class RackTypeSerializer(RackBaseSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = RackType
|
model = RackType
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display_url', 'display', 'manufacturer', 'name', 'slug', 'description', 'form_factor',
|
'id', 'url', 'display_url', 'display', 'manufacturer', 'model', 'slug', 'description', 'form_factor',
|
||||||
'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'weight',
|
'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'weight',
|
||||||
'max_weight', 'weight_unit', 'mounting_depth', 'airflow', 'description', 'comments', 'tags',
|
'max_weight', 'weight_unit', 'mounting_depth', 'airflow', 'description', 'comments', 'tags',
|
||||||
'custom_fields', 'created', 'last_updated',
|
'custom_fields', 'created', 'last_updated',
|
||||||
]
|
]
|
||||||
brief_fields = ('id', 'url', 'display', 'manufacturer', 'name', 'slug', 'description')
|
brief_fields = ('id', 'url', 'display', 'manufacturer', 'model', 'slug', 'description')
|
||||||
|
|
||||||
|
|
||||||
class RackSerializer(RackBaseSerializer):
|
class RackSerializer(RackBaseSerializer):
|
||||||
|
@ -311,7 +311,7 @@ class RackTypeFilterSet(NetBoxModelFilterSet):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = RackType
|
model = RackType
|
||||||
fields = (
|
fields = (
|
||||||
'id', 'name', 'slug', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit',
|
'id', 'model', 'slug', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit',
|
||||||
'mounting_depth', 'airflow', 'weight', 'max_weight', 'weight_unit', 'description',
|
'mounting_depth', 'airflow', 'weight', 'max_weight', 'weight_unit', 'description',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ class RackTypeImportForm(NetBoxModelImportForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = RackType
|
model = RackType
|
||||||
fields = (
|
fields = (
|
||||||
'manufacturer', 'name', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units',
|
'manufacturer', 'model', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units',
|
||||||
'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'airflow', 'weight', 'max_weight',
|
'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'airflow', 'weight', 'max_weight',
|
||||||
'weight_unit', 'description', 'comments', 'tags',
|
'weight_unit', 'description', 'comments', 'tags',
|
||||||
)
|
)
|
||||||
|
@ -211,7 +211,7 @@ class RackTypeForm(NetBoxModelForm):
|
|||||||
slug = SlugField()
|
slug = SlugField()
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('manufacturer', 'name', 'slug', 'description', 'form_factor', 'airflow', 'tags', name=_('Rack Type')),
|
FieldSet('manufacturer', 'model', 'slug', 'description', 'form_factor', 'airflow', 'tags', name=_('Rack Type')),
|
||||||
FieldSet(
|
FieldSet(
|
||||||
'width', 'u_height',
|
'width', 'u_height',
|
||||||
InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')),
|
InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')),
|
||||||
@ -224,7 +224,7 @@ class RackTypeForm(NetBoxModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = RackType
|
model = RackType
|
||||||
fields = [
|
fields = [
|
||||||
'manufacturer', 'name', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units',
|
'manufacturer', 'model', 'slug', 'form_factor', 'width', 'u_height', 'starting_unit', 'desc_units',
|
||||||
'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit',
|
'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit',
|
||||||
'airflow', 'description', 'comments', 'tags',
|
'airflow', 'description', 'comments', 'tags',
|
||||||
]
|
]
|
||||||
|
@ -37,14 +37,7 @@ class Migration(migrations.Migration):
|
|||||||
related_name='rack_types',
|
related_name='rack_types',
|
||||||
to='dcim.manufacturer'
|
to='dcim.manufacturer'
|
||||||
)),
|
)),
|
||||||
('name', models.CharField(max_length=100)),
|
('model', models.CharField(max_length=100)),
|
||||||
('_name', utilities.fields.NaturalOrderingField(
|
|
||||||
'name',
|
|
||||||
blank=True,
|
|
||||||
max_length=100,
|
|
||||||
naturalize_function=utilities.ordering.naturalize
|
|
||||||
),
|
|
||||||
),
|
|
||||||
('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(blank=True, max_length=50)),
|
||||||
('width', models.PositiveSmallIntegerField(default=19)),
|
('width', models.PositiveSmallIntegerField(default=19)),
|
||||||
@ -71,7 +64,7 @@ class Migration(migrations.Migration):
|
|||||||
options={
|
options={
|
||||||
'verbose_name': 'racktype',
|
'verbose_name': 'racktype',
|
||||||
'verbose_name_plural': 'racktypes',
|
'verbose_name_plural': 'racktypes',
|
||||||
'ordering': ('_name', 'pk'),
|
'ordering': ('manufacturer', 'model'),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.RenameField(
|
migrations.RenameField(
|
||||||
@ -90,4 +83,16 @@ class Migration(migrations.Migration):
|
|||||||
to='dcim.racktype',
|
to='dcim.racktype',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='racktype',
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=('manufacturer', 'model'), name='dcim_racktype_unique_manufacturer_model'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='racktype',
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=('manufacturer', 'slug'), name='dcim_racktype_unique_manufacturer_slug'
|
||||||
|
),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -136,15 +136,10 @@ class RackType(RackBase):
|
|||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
related_name='rack_types'
|
related_name='rack_types'
|
||||||
)
|
)
|
||||||
name = models.CharField(
|
model = models.CharField(
|
||||||
verbose_name=_('name'),
|
verbose_name=_('model'),
|
||||||
max_length=100
|
max_length=100
|
||||||
)
|
)
|
||||||
_name = NaturalOrderingField(
|
|
||||||
target_field='name',
|
|
||||||
max_length=100,
|
|
||||||
blank=True
|
|
||||||
)
|
|
||||||
slug = models.SlugField(
|
slug = models.SlugField(
|
||||||
verbose_name=_('slug'),
|
verbose_name=_('slug'),
|
||||||
max_length=100,
|
max_length=100,
|
||||||
@ -160,19 +155,29 @@ class RackType(RackBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('_name', 'pk') # (site, location, name) may be non-unique
|
ordering = ('manufacturer', 'model')
|
||||||
|
constraints = (
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=('manufacturer', 'model'),
|
||||||
|
name='%(app_label)s_%(class)s_unique_manufacturer_model'
|
||||||
|
),
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=('manufacturer', 'slug'),
|
||||||
|
name='%(app_label)s_%(class)s_unique_manufacturer_slug'
|
||||||
|
),
|
||||||
|
)
|
||||||
verbose_name = _('rack type')
|
verbose_name = _('rack type')
|
||||||
verbose_name_plural = _('rack types')
|
verbose_name_plural = _('rack types')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.model
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('dcim:racktype', args=[self.pk])
|
return reverse('dcim:racktype', args=[self.pk])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
return f"{self.manufacturer} {self.name}"
|
return f"{self.manufacturer} {self.model}"
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
@ -50,9 +50,8 @@ class RackRoleTable(NetBoxTable):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class RackTypeTable(NetBoxTable):
|
class RackTypeTable(NetBoxTable):
|
||||||
name = tables.Column(
|
model = tables.Column(
|
||||||
verbose_name=_('Name'),
|
verbose_name=_('Model'),
|
||||||
order_by=('_name',),
|
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
manufacturer = tables.Column(
|
manufacturer = tables.Column(
|
||||||
@ -96,12 +95,12 @@ class RackTypeTable(NetBoxTable):
|
|||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = RackType
|
model = RackType
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width',
|
'pk', 'id', 'model', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width',
|
||||||
'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments',
|
'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description', 'comments',
|
||||||
'instance_count', 'tags', 'created', 'last_updated',
|
'instance_count', 'tags', 'created', 'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'manufacturer', 'type', 'u_height', 'description', 'instance_count',
|
'pk', 'model', 'manufacturer', 'type', 'u_height', 'description', 'instance_count',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user