12074 move device location setting to save from clean

This commit is contained in:
Arthur 2023-03-31 12:14:59 -07:00
parent a6070e1aa0
commit 941c4df9d9
2 changed files with 3 additions and 7 deletions

View File

@ -659,8 +659,6 @@ class Device(PrimaryModel, ConfigContextModel):
raise ValidationError({
'rack': f"Rack {self.rack} does not belong to location {self.location}.",
})
elif self.rack:
self.location = self.rack.location
if self.rack is None:
if self.face:
@ -801,6 +799,9 @@ class Device(PrimaryModel, ConfigContextModel):
if is_new and not self.airflow:
self.airflow = self.device_type.airflow
if self.rack:
self.location = self.rack.location
super().save(*args, **kwargs)
# If this is a new Device, instantiate all the related components per the DeviceType definition

View File

@ -39,9 +39,4 @@ class ValidatedModelSerializer(BaseModelSerializer):
for k, v in attrs.items():
setattr(instance, k, v)
instance.full_clean()
# copy any changes to data made in full_clean
for k, v in attrs.items():
data[k] = getattr(instance, k)
return data