mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 20:46:30 -06:00
Fixes #26: Corrected rack validation to work when there are no devices within the rack
This commit is contained in:
parent
f958bc0580
commit
4dd31497e5
@ -188,10 +188,11 @@ class Rack(CreatedUpdatedModel):
|
|||||||
# Validate that Rack is tall enough to house the installed Devices
|
# Validate that Rack is tall enough to house the installed Devices
|
||||||
if self.pk:
|
if self.pk:
|
||||||
top_device = Device.objects.filter(rack=self).order_by('-position').first()
|
top_device = Device.objects.filter(rack=self).order_by('-position').first()
|
||||||
min_height = top_device.position + top_device.device_type.u_height - 1
|
if top_device:
|
||||||
if self.u_height < min_height:
|
min_height = top_device.position + top_device.device_type.u_height - 1
|
||||||
raise ValidationError("Rack must be at least {}U tall with currently installed devices."
|
if self.u_height < min_height:
|
||||||
.format(min_height))
|
raise ValidationError("Rack must be at least {}U tall with currently installed devices."
|
||||||
|
.format(min_height))
|
||||||
|
|
||||||
def to_csv(self):
|
def to_csv(self):
|
||||||
return ','.join([
|
return ','.join([
|
||||||
|
Loading…
Reference in New Issue
Block a user