1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #5913: Improve change logging (#5924)

* Initial work on #5913
* Provide per-line diff highlighting
* BulkDeteView should delete objects individually to secure a pre-change snapshot
* Add changelog tests for bulk operations
This commit is contained in:
Jeremy Stretch
2021-03-04 13:06:04 -05:00
committed by GitHub
parent f495addb1e
commit 9c967ee3ea
21 changed files with 439 additions and 124 deletions

View File

@@ -44,4 +44,14 @@ class Migration(migrations.Migration):
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AddField(
model_name='vminterface',
name='created',
field=models.DateField(auto_now_add=True, null=True),
),
migrations.AddField(
model_name='vminterface',
name='last_updated',
field=models.DateTimeField(auto_now=True, null=True),
),
]

View File

@@ -9,12 +9,11 @@ from dcim.models import BaseInterface, Device
from extras.models import ConfigContextModel, ObjectChange, TaggedItem
from extras.querysets import ConfigContextModelQuerySet
from extras.utils import extras_features
from netbox.models import BigIDModel, OrganizationalModel, PrimaryModel
from netbox.models import BigIDModel, ChangeLoggingMixin, OrganizationalModel, PrimaryModel
from utilities.fields import NaturalOrderingField
from utilities.ordering import naturalize_interface
from utilities.query_functions import CollateAsChar
from utilities.querysets import RestrictedQuerySet
from utilities.utils import serialize_object
from .choices import *
@@ -373,8 +372,9 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
# Interfaces
#
# TODO: Inherit from PrimaryModel
@extras_features('export_templates', 'webhooks')
class VMInterface(BigIDModel, BaseInterface):
class VMInterface(ChangeLoggingMixin, BigIDModel, BaseInterface):
virtual_machine = models.ForeignKey(
to='virtualization.VirtualMachine',
on_delete=models.CASCADE,
@@ -458,13 +458,7 @@ class VMInterface(BigIDModel, BaseInterface):
def to_objectchange(self, action):
# Annotate the parent VirtualMachine
return ObjectChange(
changed_object=self,
object_repr=str(self),
action=action,
related_object=self.virtual_machine,
object_data=serialize_object(self)
)
return super().to_objectchange(action, related_object=self.virtual_machine)
@property
def parent(self):