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

Fixes #5665: Validate rack group is assigned to same site when creating a rack

Jeremy Stretch 5 лет назад
Родитель
Сommit
87c600aa7c
2 измененных файлов с 5 добавлено и 0 удалено
  1. 1 0
      docs/release-notes/version-2.10.md
  2. 4 0
      netbox/dcim/models/racks.py

+ 1 - 0
docs/release-notes/version-2.10.md

@@ -17,6 +17,7 @@
 * [#5603](https://github.com/netbox-community/netbox/issues/5603) - Fix display of white cables in trace view
 * [#5639](https://github.com/netbox-community/netbox/issues/5639) - Fix filtering connection lists by device name
 * [#5640](https://github.com/netbox-community/netbox/issues/5640) - Fix permissions assessment when adding VM interfaces in bulk
+* [#5665](https://github.com/netbox-community/netbox/issues/5665) - Validate rack group is assigned to same site when creating a rack
 
 ---
 

+ 4 - 0
netbox/dcim/models/racks.py

@@ -299,6 +299,10 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
     def clean(self):
         super().clean()
 
+        # Validate group/site assignment
+        if self.site and self.group and self.group.site != self.site:
+            raise ValidationError(f"Assigned rack group must belong to parent site ({self.site}).")
+
         # Validate outer dimensions and unit
         if (self.outer_width is not None or self.outer_depth is not None) and not self.outer_unit:
             raise ValidationError("Must specify a unit when setting an outer width/depth")