|
|
@@ -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
|