1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

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

This commit is contained in:
Jeremy Stretch
2021-01-25 14:19:32 -05:00
parent 08dfe64301
commit 87c600aa7c
2 changed files with 5 additions and 0 deletions

View File

@ -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")