mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
12826 add slug
This commit is contained in:
parent
323bd24597
commit
d6815ff033
@ -365,6 +365,16 @@ class RackFilterSet(NetBoxModelFilterSet, TenancyFilterSet, ContactModelFilterSe
|
||||
to_field_name='slug',
|
||||
label=_('Location (slug)'),
|
||||
)
|
||||
rack_type = django_filters.ModelMultipleChoiceFilter(
|
||||
field_name='rack_type__slug',
|
||||
queryset=RackType.objects.all(),
|
||||
to_field_name='slug',
|
||||
label=_('Rack type (slug)'),
|
||||
)
|
||||
rack_type_id = django_filters.ModelMultipleChoiceFilter(
|
||||
queryset=RackType.objects.all(),
|
||||
label=_('Rack type (ID)'),
|
||||
)
|
||||
status = django_filters.MultipleChoiceFilter(
|
||||
choices=RackStatusChoices,
|
||||
null_value=None
|
||||
|
@ -208,8 +208,8 @@ class RackTypeImportForm(NetBoxModelImportForm):
|
||||
class Meta:
|
||||
model = RackType
|
||||
fields = (
|
||||
'name', 'type',
|
||||
'width', 'u_height', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight',
|
||||
'name', 'slug', 'type', 'width', 'u_height', 'desc_units', 'outer_width',
|
||||
'outer_depth', 'outer_unit', 'mounting_depth', 'weight',
|
||||
'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
||||
)
|
||||
|
||||
|
@ -206,7 +206,7 @@ class RackTypeForm(NetBoxModelForm):
|
||||
comments = CommentField()
|
||||
|
||||
fieldsets = (
|
||||
FieldSet('name', 'description', 'tags', name=_('Rack')),
|
||||
FieldSet('name', 'slug', 'description', 'tags', name=_('Rack')),
|
||||
FieldSet(
|
||||
'type', 'width', 'starting_unit', 'u_height',
|
||||
InlineFields('outer_width', 'outer_depth', 'outer_unit', label=_('Outer Dimensions')),
|
||||
@ -218,9 +218,9 @@ class RackTypeForm(NetBoxModelForm):
|
||||
class Meta:
|
||||
model = RackType
|
||||
fields = [
|
||||
'name',
|
||||
'type', 'width', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth',
|
||||
'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', 'comments', 'tags',
|
||||
'name', 'slug', 'type', 'width', 'u_height', 'starting_unit', 'desc_units',
|
||||
'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight',
|
||||
'weight_unit', 'description', 'comments', 'tags',
|
||||
]
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ class Migration(migrations.Migration):
|
||||
'name', blank=True, max_length=100, naturalize_function=utilities.ordering.naturalize
|
||||
),
|
||||
),
|
||||
('slug', models.SlugField(max_length=100, unique=True)),
|
||||
('type', models.CharField(blank=True, max_length=50)),
|
||||
('width', models.PositiveSmallIntegerField(default=19)),
|
||||
(
|
||||
|
@ -51,6 +51,11 @@ class RackType(PrimaryModel, WeightMixin):
|
||||
max_length=100,
|
||||
blank=True
|
||||
)
|
||||
slug = models.SlugField(
|
||||
verbose_name=_('slug'),
|
||||
max_length=100,
|
||||
unique=True
|
||||
)
|
||||
type = models.CharField(
|
||||
choices=RackTypeChoices,
|
||||
max_length=50,
|
||||
|
@ -80,7 +80,8 @@ class RackTypeTestCase(TestCase):
|
||||
def setUpTestData(cls):
|
||||
|
||||
RackType.objects.create(
|
||||
name='Rack 1',
|
||||
name='RackType 1',
|
||||
slug='rack-type-1',
|
||||
width=11,
|
||||
u_height=22,
|
||||
starting_unit=3,
|
||||
|
@ -343,9 +343,9 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
def setUpTestData(cls):
|
||||
|
||||
racks = (
|
||||
Rack(name='RackType 1'),
|
||||
Rack(name='RackType 2'),
|
||||
Rack(name='RackType 3'),
|
||||
RackType(name='RackType 1', slug='rack-type-1',),
|
||||
RackType(name='RackType 2', slug='rack-type-2',),
|
||||
RackType(name='RackType 3', slug='rack-type-3',),
|
||||
)
|
||||
RackType.objects.bulk_create(racks)
|
||||
|
||||
@ -353,6 +353,7 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
|
||||
cls.form_data = {
|
||||
'name': 'RackType X',
|
||||
'slug': 'rack-type-x',
|
||||
'type': RackTypeChoices.TYPE_CABINET,
|
||||
'width': RackWidthChoices.WIDTH_19IN,
|
||||
'u_height': 48,
|
||||
@ -369,10 +370,10 @@ class RackTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,width,u_height,weight,max_weight,weight_unit",
|
||||
"RackType 4,19,42,100,2000,kg",
|
||||
"RackType 5,19,42,100,2000,kg",
|
||||
"RackType 6,19,42,100,2000,kg",
|
||||
"name,slug,width,u_height,weight,max_weight,weight_unit",
|
||||
"RackType 4,rack-type-4,19,42,100,2000,kg",
|
||||
"RackType 5,rack-type-5,19,42,100,2000,kg",
|
||||
"RackType 6,rack-type-6,19,42,100,2000,kg",
|
||||
)
|
||||
|
||||
cls.csv_update_data = (
|
||||
|
Loading…
Reference in New Issue
Block a user