mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
12074 move device location setting to save from clean
This commit is contained in:
parent
a6070e1aa0
commit
941c4df9d9
@ -659,8 +659,6 @@ class Device(PrimaryModel, ConfigContextModel):
|
|||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'rack': f"Rack {self.rack} does not belong to location {self.location}.",
|
'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.rack is None:
|
||||||
if self.face:
|
if self.face:
|
||||||
@ -801,6 +799,9 @@ class Device(PrimaryModel, ConfigContextModel):
|
|||||||
if is_new and not self.airflow:
|
if is_new and not self.airflow:
|
||||||
self.airflow = self.device_type.airflow
|
self.airflow = self.device_type.airflow
|
||||||
|
|
||||||
|
if self.rack:
|
||||||
|
self.location = self.rack.location
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
# If this is a new Device, instantiate all the related components per the DeviceType definition
|
# If this is a new Device, instantiate all the related components per the DeviceType definition
|
||||||
|
@ -39,9 +39,4 @@ class ValidatedModelSerializer(BaseModelSerializer):
|
|||||||
for k, v in attrs.items():
|
for k, v in attrs.items():
|
||||||
setattr(instance, k, v)
|
setattr(instance, k, v)
|
||||||
instance.full_clean()
|
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
|
return data
|
||||||
|
Loading…
Reference in New Issue
Block a user