From 482b4b6e95ce4e32eba2ceb38b359fb66d65e4ee Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 25 Aug 2022 08:37:43 -0400 Subject: [PATCH] Fixes #10147: Permit the creation of 0U device types via REST API --- docs/release-notes/version-3.3.md | 1 + netbox/dcim/api/serializers.py | 2 +- netbox/dcim/tests/test_api.py | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index a1ac5b40f..6e8846e4a 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -27,6 +27,7 @@ * [#10109](https://github.com/netbox-community/netbox/issues/10109) - Fix available prefixes calculation for container prefixes in the global table * [#10111](https://github.com/netbox-community/netbox/issues/10111) - Wrap search QS to catch ValueError on identifier field * [#10134](https://github.com/netbox-community/netbox/issues/10134) - Custom fields data serializer should return a 400 response for invalid data +* [#10147](https://github.com/netbox-community/netbox/issues/10147) - Permit the creation of 0U device types via REST API --- diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 249a3f167..af806acb8 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -310,7 +310,7 @@ class DeviceTypeSerializer(NetBoxModelSerializer): max_digits=4, decimal_places=1, label='Position (U)', - min_value=decimal.Decimal(0.5), + min_value=0, default=1.0 ) subdevice_role = ChoiceField(choices=SubdeviceRoleChoices, allow_blank=True, required=False) diff --git a/netbox/dcim/tests/test_api.py b/netbox/dcim/tests/test_api.py index a78a98ae5..acd52178d 100644 --- a/netbox/dcim/tests/test_api.py +++ b/netbox/dcim/tests/test_api.py @@ -461,16 +461,19 @@ class DeviceTypeTest(APIViewTestCases.APIViewTestCase): 'manufacturer': manufacturers[1].pk, 'model': 'Device Type 4', 'slug': 'device-type-4', + 'u_height': 0, }, { 'manufacturer': manufacturers[1].pk, 'model': 'Device Type 5', 'slug': 'device-type-5', + 'u_height': 0.5, }, { 'manufacturer': manufacturers[1].pk, 'model': 'Device Type 6', 'slug': 'device-type-6', + 'u_height': 1, }, ]