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

Fixes #3596: Prevent server error when reassigning a device to a new device bay

This commit is contained in:
Jeremy Stretch
2019-10-23 09:28:00 -04:00
parent f21a63382c
commit 7467347af1
2 changed files with 13 additions and 1 deletions

View File

@@ -2588,6 +2588,16 @@ class DeviceBay(ComponentModel):
if self.device == self.installed_device:
raise ValidationError("Cannot install a device into itself.")
# Check that the installed device is not already installed elsewhere
if self.installed_device:
current_bay = DeviceBay.objects.filter(installed_device=self.installed_device).first()
if current_bay:
raise ValidationError({
'installed_device': "Cannot install the specified device; device is already installed in {}".format(
current_bay
)
})
#
# Inventory items