|
|
@@ -293,7 +293,7 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|
|
# If editing an existing DeviceType to have a larger u_height, first validate that *all* instances of it have
|
|
|
# room to expand within their racks. This validation will impose a very high performance penalty when there are
|
|
|
# many instances to check, but increasing the u_height of a DeviceType should be a very rare occurrence.
|
|
|
- if self.pk and self.u_height > self._original_u_height:
|
|
|
+ if not self._state.adding and self.u_height > self._original_u_height:
|
|
|
for d in Device.objects.filter(device_type=self, position__isnull=False):
|
|
|
face_required = None if self.is_full_depth else d.face
|
|
|
u_available = d.rack.get_available_units(
|
|
|
@@ -310,7 +310,7 @@ class DeviceType(ImageAttachmentsMixin, PrimaryModel, WeightMixin):
|
|
|
})
|
|
|
|
|
|
# If modifying the height of an existing DeviceType to 0U, check for any instances assigned to a rack position.
|
|
|
- elif self.pk and self._original_u_height > 0 and self.u_height == 0:
|
|
|
+ elif not self._state.adding and self._original_u_height > 0 and self.u_height == 0:
|
|
|
racked_instance_count = Device.objects.filter(
|
|
|
device_type=self,
|
|
|
position__isnull=False
|
|
|
@@ -1351,7 +1351,7 @@ class VirtualChassis(PrimaryModel):
|
|
|
|
|
|
# Verify that the selected master device has been assigned to this VirtualChassis. (Skip when creating a new
|
|
|
# VirtualChassis.)
|
|
|
- if self.pk and self.master and self.master not in self.members.all():
|
|
|
+ if not self._state.adding and self.master and self.master not in self.members.all():
|
|
|
raise ValidationError({
|
|
|
'master': _("The selected master ({master}) is not assigned to this virtual chassis.").format(
|
|
|
master=self.master
|