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

Fixes #2192: Prevent a 0U device from being assigned to a rack position

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

+ 6 - 0
netbox/dcim/models.py

@@ -963,6 +963,12 @@ class Device(CreatedUpdatedModel, CustomFieldModel):
                 'face': "Must specify rack face when defining rack position.",
             })
 
+        # Prevent 0U devices from being assigned to a specific position
+        if self.position and self.device_type.u_height == 0:
+            raise ValidationError({
+                'position': "A U0 device type ({}) cannot be assigned to a rack position.".format(self.device_type)
+            })
+
         if self.rack:
 
             try: