mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #2742: Preserve cluster assignment when editing a device
This commit is contained in:
@ -8,6 +8,11 @@ v2.5.3 (FUTURE)
|
|||||||
* [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors
|
* [#2693](https://github.com/digitalocean/netbox/issues/2693) - Additional cable colors
|
||||||
* [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search
|
* [#2726](https://github.com/digitalocean/netbox/issues/2726) - Include cables in global search
|
||||||
|
|
||||||
|
## Bug Fixes
|
||||||
|
|
||||||
|
* [#2742](https://github.com/digitalocean/netbox/issues/2742) - Preserve cluster assignment when editing a device
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
v2.5.2 (2018-12-21)
|
v2.5.2 (2018-12-21)
|
||||||
|
@ -1213,11 +1213,13 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
|
|||||||
|
|
||||||
# Initialize helper selectors
|
# Initialize helper selectors
|
||||||
instance = kwargs.get('instance')
|
instance = kwargs.get('instance')
|
||||||
|
if 'initial' not in kwargs:
|
||||||
|
kwargs['initial'] = {}
|
||||||
# Using hasattr() instead of "is not None" to avoid RelatedObjectDoesNotExist on required field
|
# Using hasattr() instead of "is not None" to avoid RelatedObjectDoesNotExist on required field
|
||||||
if instance and hasattr(instance, 'device_type'):
|
if instance and hasattr(instance, 'device_type'):
|
||||||
initial = kwargs.get('initial', {}).copy()
|
kwargs['initial']['manufacturer'] = instance.device_type.manufacturer
|
||||||
initial['manufacturer'] = instance.device_type.manufacturer
|
if instance and instance.cluster is not None:
|
||||||
kwargs['initial'] = initial
|
kwargs['initial']['cluster_group'] = instance.cluster.group
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user