mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fixes #4648: Fix bulk CSV import of child devices
This commit is contained in:
parent
ba91b3aa2e
commit
a64351279d
@ -8,6 +8,7 @@ v2.8.5 (FUTURE)
|
|||||||
* [#4644](https://github.com/netbox-community/netbox/issues/4644) - Fix ordering of services table by parent
|
* [#4644](https://github.com/netbox-community/netbox/issues/4644) - Fix ordering of services table by parent
|
||||||
* [#4646](https://github.com/netbox-community/netbox/issues/4646) - Correct UI link for reports with custom name
|
* [#4646](https://github.com/netbox-community/netbox/issues/4646) - Correct UI link for reports with custom name
|
||||||
* [#4647](https://github.com/netbox-community/netbox/issues/4647) - Fix caching invalidation issue related to assigning new IP addresses to interfaces
|
* [#4647](https://github.com/netbox-community/netbox/issues/4647) - Fix caching invalidation issue related to assigning new IP addresses to interfaces
|
||||||
|
* [#4648](https://github.com/netbox-community/netbox/issues/4648) - Fix bulk CSV import of child devices
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1956,7 +1956,7 @@ class ChildDeviceCSVForm(BaseDeviceCSVForm):
|
|||||||
help_text='Parent device'
|
help_text='Parent device'
|
||||||
)
|
)
|
||||||
device_bay = CSVModelChoiceField(
|
device_bay = CSVModelChoiceField(
|
||||||
queryset=Device.objects.all(),
|
queryset=DeviceBay.objects.all(),
|
||||||
to_field_name='name',
|
to_field_name='name',
|
||||||
help_text='Device bay in which this device is installed'
|
help_text='Device bay in which this device is installed'
|
||||||
)
|
)
|
||||||
@ -1976,6 +1976,20 @@ class ChildDeviceCSVForm(BaseDeviceCSVForm):
|
|||||||
params = {f"device__{self.fields['parent'].to_field_name}": data.get('parent')}
|
params = {f"device__{self.fields['parent'].to_field_name}": data.get('parent')}
|
||||||
self.fields['device_bay'].queryset = self.fields['device_bay'].queryset.filter(**params)
|
self.fields['device_bay'].queryset = self.fields['device_bay'].queryset.filter(**params)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
# Set parent_bay reverse relationship
|
||||||
|
device_bay = self.cleaned_data.get('device_bay')
|
||||||
|
if device_bay:
|
||||||
|
self.instance.parent_bay = device_bay
|
||||||
|
|
||||||
|
# Inherit site and rack from parent device
|
||||||
|
parent = self.cleaned_data.get('parent')
|
||||||
|
if parent:
|
||||||
|
self.instance.site = parent.site
|
||||||
|
self.instance.rack = parent.rack
|
||||||
|
|
||||||
|
|
||||||
class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
|
class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
|
||||||
pk = forms.ModelMultipleChoiceField(
|
pk = forms.ModelMultipleChoiceField(
|
||||||
|
Loading…
Reference in New Issue
Block a user