Просмотр исходного кода

Fixes #2608: Fixed null outer_unit error on rack import

Jeremy Stretch 7 лет назад
Родитель
Сommit
a46f68c6e4
2 измененных файлов с 5 добавлено и 6 удалено
  1. 1 0
      CHANGELOG.md
  2. 4 6
      netbox/dcim/models.py

+ 1 - 0
CHANGELOG.md

@@ -60,6 +60,7 @@ NetBox now supports modeling physical cables for console, power, and interface c
 * [#2593](https://github.com/digitalocean/netbox/issues/2593) - Fix toggling of connected cable's status
 * [#2601](https://github.com/digitalocean/netbox/issues/2601) - Added a `description` field to pass-through ports
 * [#2602](https://github.com/digitalocean/netbox/issues/2602) - Return HTTP 204 when no new IPs/prefixes are available for provisioning
+* [#2608](https://github.com/digitalocean/netbox/issues/2608) - Fixed null `outer_unit` error on rack import
 
 ## API Changes
 

+ 4 - 6
netbox/dcim/models.py

@@ -552,12 +552,10 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
     def clean(self):
 
         # Validate outer dimensions and unit
-        if self.outer_width and not self.outer_unit:
-            raise ValidationError("Must specify a unit when setting an outer width")
-        if self.outer_depth and not self.outer_unit:
-            raise ValidationError("Must specify a unit when setting an outer depth")
-        if self.outer_unit and self.outer_width is None and self.outer_depth is None:
-            self.length_unit = ''
+        if (self.outer_width or self.outer_depth) and not self.outer_unit:
+            raise ValidationError("Must specify a unit when setting an outer width/depth")
+        else:
+            self.outer_unit = ''
 
         if self.pk:
             # Validate that Rack is tall enough to house the installed Devices