diff --git a/netbox/dcim/api/serializers_/racks.py b/netbox/dcim/api/serializers_/racks.py index 74087fc5a..9dd6ddfcd 100644 --- a/netbox/dcim/api/serializers_/racks.py +++ b/netbox/dcim/api/serializers_/racks.py @@ -43,12 +43,12 @@ class RackTypeSerializer(NetBoxModelSerializer): class Meta: model = RackType fields = [ - 'id', 'url', 'display_url', 'display', 'name', + 'id', 'url', 'display_url', 'display', 'name', 'slug', 'type', 'width', 'u_height', 'starting_unit', 'weight', 'max_weight', 'weight_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', ] - brief_fields = ('id', 'url', 'display', 'name', 'description') + brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description') class RackSerializer(NetBoxModelSerializer): diff --git a/netbox/dcim/filtersets.py b/netbox/dcim/filtersets.py index 750b2fe29..91acf4f4b 100644 --- a/netbox/dcim/filtersets.py +++ b/netbox/dcim/filtersets.py @@ -301,7 +301,7 @@ class RackTypeFilterSet(NetBoxModelFilterSet): class Meta: model = RackType fields = ( - 'id', 'name', 'u_height', 'starting_unit', 'desc_units', 'outer_width', + 'id', 'name', 'slug', 'u_height', 'starting_unit', 'desc_units', 'outer_width', 'outer_depth', 'outer_unit', 'mounting_depth', 'weight', 'max_weight', 'weight_unit', 'description', ) diff --git a/netbox/dcim/graphql/types.py b/netbox/dcim/graphql/types.py index 14300c825..646b60a49 100644 --- a/netbox/dcim/graphql/types.py +++ b/netbox/dcim/graphql/types.py @@ -612,7 +612,7 @@ class PowerPortTemplateType(ModularComponentTemplateType): fields='__all__', filters=RackTypeFilter ) -class RackTypeType(ImageAttachmentsMixin, NetBoxObjectType): +class RackTypeType(NetBoxObjectType): _name: str diff --git a/netbox/dcim/tests/test_api.py b/netbox/dcim/tests/test_api.py index 61c0f4039..68250dd83 100644 --- a/netbox/dcim/tests/test_api.py +++ b/netbox/dcim/tests/test_api.py @@ -276,7 +276,7 @@ class RackRoleTest(APIViewTestCases.APIViewTestCase): class RackTypeTest(APIViewTestCases.APIViewTestCase): model = RackType - brief_fields = ['description', 'display', 'id', 'name', 'url'] + brief_fields = ['description', 'display', 'id', 'name', 'slug', 'url'] bulk_update_data = { 'description': 'new description', } @@ -285,21 +285,24 @@ class RackTypeTest(APIViewTestCases.APIViewTestCase): def setUpTestData(cls): racks = ( - RackType(name='Rack 1'), - RackType(name='Rack 2'), - RackType(name='Rack 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) cls.create_data = [ { - 'name': 'Test Rack 4', + 'name': 'Test RackType 4', + 'slug': 'test-rack-type-4', }, { - 'name': 'Test Rack 5', + 'name': 'Test RackType 5', + 'slug': 'test-rack-type-5', }, { - 'name': 'Test Rack 6', + 'name': 'Test RackType 6', + 'slug': 'test-rack-type-6', }, ] diff --git a/netbox/dcim/tests/test_filtersets.py b/netbox/dcim/tests/test_filtersets.py index 2c2bec273..7f60d9d21 100644 --- a/netbox/dcim/tests/test_filtersets.py +++ b/netbox/dcim/tests/test_filtersets.py @@ -477,7 +477,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests): racks = ( RackType( - name='Rack 1', + name='RackType 1', + slug='rack-type-1', type=RackTypeChoices.TYPE_2POST, width=RackWidthChoices.WIDTH_19IN, u_height=42, @@ -491,7 +492,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests): description='foobar1' ), RackType( - name='Rack 2', + name='RackType 2', + slug='rack-type-2', type=RackTypeChoices.TYPE_4POST, width=RackWidthChoices.WIDTH_21IN, u_height=43, @@ -505,7 +507,8 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests): description='foobar2' ), RackType( - name='Rack 3', + name='RackType 3', + slug='rack-type-3', type=RackTypeChoices.TYPE_CABINET, width=RackWidthChoices.WIDTH_23IN, u_height=44, @@ -526,7 +529,11 @@ class RackTypeTestCase(TestCase, ChangeLoggedFilterSetTests): self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_name(self): - params = {'name': ['Rack 1', 'Rack 2']} + params = {'name': ['RackType 1', 'RackType 2']} + self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) + + def test_slug(self): + params = {'slug': ['rack-type-1', 'rack-type-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self):