Fixes #8951: Allow changing device type & platform to different manufacturer simultaneously

This commit is contained in:
jeremystretch 2022-03-24 10:34:09 -04:00
parent e09ab79a1a
commit 30a6dc2f64
3 changed files with 3 additions and 7 deletions

View File

@ -18,6 +18,7 @@
* [#8924](https://github.com/netbox-community/netbox/issues/8924) - Improve load time of custom script list * [#8924](https://github.com/netbox-community/netbox/issues/8924) - Improve load time of custom script list
* [#8932](https://github.com/netbox-community/netbox/issues/8932) - Fix error when setting null value for interface `rf_role` via REST API * [#8932](https://github.com/netbox-community/netbox/issues/8932) - Fix error when setting null value for interface `rf_role` via REST API
* [#8935](https://github.com/netbox-community/netbox/issues/8935) - Correct ordering of next/previous racks to use naturalized names * [#8935](https://github.com/netbox-community/netbox/issues/8935) - Correct ordering of next/previous racks to use naturalized names
* [#8951](https://github.com/netbox-community/netbox/issues/8951) - Allow changing device type & platform to different manufacturer simultaneously
--- ---

View File

@ -605,11 +605,6 @@ class DeviceForm(TenancyForm, CustomFieldModelForm):
# can be flipped from one face to another. # can be flipped from one face to another.
self.fields['position'].widget.add_query_param('exclude', self.instance.pk) self.fields['position'].widget.add_query_param('exclude', self.instance.pk)
# Limit platform by manufacturer
self.fields['platform'].queryset = Platform.objects.filter(
Q(manufacturer__isnull=True) | Q(manufacturer=self.instance.device_type.manufacturer)
)
# Disable rack assignment if this is a child device installed in a parent device # Disable rack assignment if this is a child device installed in a parent device
if self.instance.device_type.is_child_device and hasattr(self.instance, 'parent_bay'): if self.instance.device_type.is_child_device and hasattr(self.instance, 'parent_bay'):
self.fields['site'].disabled = True self.fields['site'].disabled = True

View File

@ -739,8 +739,8 @@ class Device(PrimaryModel, ConfigContextModel):
if hasattr(self, 'device_type') and self.platform: if hasattr(self, 'device_type') and self.platform:
if self.platform.manufacturer and self.platform.manufacturer != self.device_type.manufacturer: if self.platform.manufacturer and self.platform.manufacturer != self.device_type.manufacturer:
raise ValidationError({ raise ValidationError({
'platform': "The assigned platform is limited to {} device types, but this device's type belongs " 'platform': f"The assigned platform is limited to {self.platform.manufacturer} device types, but "
"to {}.".format(self.platform.manufacturer, self.device_type.manufacturer) f"this device's type belongs to {self.device_type.manufacturer}."
}) })
# A Device can only be assigned to a Cluster in the same Site (or no Site) # A Device can only be assigned to a Cluster in the same Site (or no Site)