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

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()