Closes #21550: Call snapshot() before saving related objects (#21551)

Add missing pre-change `snapshot()` calls in views/forms before updating
and saving related objects (device bays, virtual chassis members, and
bulk-import primary MAC/IP assignments), so changelog entries include
pre-change data.
This commit is contained in:
Arthur Hanson
2026-03-03 05:01:04 -08:00
committed by GitHub
parent cdc2fb2f06
commit 3b0b95c265
3 changed files with 5 additions and 0 deletions
+1
View File
@@ -1386,6 +1386,7 @@ class MACAddressImportForm(PrimaryModelImportForm):
# Assign the MAC address as primary for its interface, if designated as such
if interface and self.cleaned_data['is_primary'] and self.instance.pk:
interface.snapshot()
interface.primary_mac_address = self.instance
interface.save()
+2
View File
@@ -2733,6 +2733,7 @@ class DeviceBulkImportView(generic.BulkImportView):
# For child devices, save the reverse relation to the parent device bay
if parent_bay:
device_bay = parent_bay
device_bay.snapshot()
device_bay.installed_device = obj
device_bay.save()
@@ -4099,6 +4100,7 @@ class VirtualChassisEditView(ObjectPermissionRequiredMixin, GetReturnURLMixin, V
members = formset.save(commit=False)
devices = Device.objects.filter(pk__in=[m.pk for m in members])
for device in devices:
device.snapshot()
device.vc_position = None
device.save()
for member in members:
+2
View File
@@ -424,6 +424,7 @@ class IPAddressImportForm(PrimaryModelImportForm):
# Set as primary for device/VM
if self.cleaned_data.get('is_primary') is not None:
parent = self.cleaned_data.get('device') or self.cleaned_data.get('virtual_machine')
parent.snapshot()
if self.instance.address.version == 4:
parent.primary_ip4 = ipaddress if self.cleaned_data.get('is_primary') else None
elif self.instance.address.version == 6:
@@ -433,6 +434,7 @@ class IPAddressImportForm(PrimaryModelImportForm):
# Set as OOB for device
if self.cleaned_data.get('is_oob') is not None:
parent = self.cleaned_data.get('device')
parent.snapshot()
parent.oob_ip = ipaddress if self.cleaned_data.get('is_oob') else None
parent.save()