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

Misc cleanup

This commit is contained in:
Jeremy Stretch
2019-04-11 10:49:43 -04:00
parent b22fd2bc44
commit 05c19af2a3
5 changed files with 44 additions and 8 deletions

View File

@@ -2853,6 +2853,14 @@ class PowerPanel(ChangeLoggedModel):
self.name,
)
def clean(self):
# RackGroup must belong to assigned Site
if self.rack_group and self.rack_group.site != self.site:
raise ValidationError("Rack group {} ({}) is in a different site than {}".format(
self.rack_group, self.rack_group.site, self.site
))
class PowerFeed(ChangeLoggedModel, CableTermination, CustomFieldModel):
"""
@@ -2953,6 +2961,14 @@ class PowerFeed(ChangeLoggedModel, CableTermination, CustomFieldModel):
self.comments,
)
def clean(self):
# Rack must belong to same Site as PowerPanel
if self.rack and self.rack.site != self.power_panel.site:
raise ValidationError("Rack {} ({}) and power panel {} ({}) are in different sites".format(
self.rack, self.rack.site, self.power_panel, self.power_panel.site
))
def get_type_class(self):
return STATUS_CLASSES[self.type]