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

Fixes #5574: Restrict the creation of device bay templates on non-parent device types

This commit is contained in:
Jeremy Stretch
2021-01-19 10:49:56 -05:00
parent 69bf451b20
commit a0e82e1817
4 changed files with 14 additions and 3 deletions

View File

@@ -363,3 +363,9 @@ class DeviceBayTemplate(ComponentTemplateModel):
name=self.name,
label=self.label
)
def clean(self):
if self.device_type and self.device_type.subdevice_role != SubdeviceRoleChoices.ROLE_PARENT:
raise ValidationError(
f"Subdevice role of device type ({self.device_type}) must be set to \"parent\" to allow device bays."
)