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

Fixes #5218: Raise validation error if a power port's allocated_draw exceeds its maximum_draw

This commit is contained in:
Jeremy Stretch
2020-10-07 13:23:19 -04:00
parent 5089df3ffd
commit 39e4ab164e
2 changed files with 9 additions and 0 deletions

View File

@@ -405,6 +405,14 @@ class PowerPort(CableTermination, ComponentModel):
self.description,
)
def clean(self):
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)."
})
@property
def connected_endpoint(self):
"""