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

Fixes: #5564 - Raise validation error if a PowerPortTemplate's draw exceeds maximum

This commit is contained in:
Daniel Sheppard
2021-01-05 09:52:11 -06:00
parent d16a7e108c
commit 3441216aca
2 changed files with 10 additions and 0 deletions

View File

@@ -164,6 +164,15 @@ class PowerPortTemplate(ComponentTemplateModel):
allocated_draw=self.allocated_draw
)
def clean(self):
super().clean()
if self.maximum_draw is not None and self.allocated_draw is not None:
if self.allocated_draw > self.maximum_draw:
raise ValidationError({
'allocated_draw': f"Allocated draw cannot exceed the maximum draw ({self.maximum_draw}W)."
})
class PowerOutletTemplate(ComponentTemplateModel):
"""