From bbaa3a2058741f75369147f42486527968e5a51b Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 12 Jul 2018 13:46:30 -0400 Subject: [PATCH] Enabled change logging for circuit terminations --- netbox/circuits/models.py | 16 +++++++++++++++- netbox/templates/extras/objectchange.html | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index 10ca8d7db..055ea65b1 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -8,8 +8,9 @@ from taggit.managers import TaggableManager from dcim.constants import STATUS_CLASSES from dcim.fields import ASNField -from extras.models import CustomFieldModel +from extras.models import CustomFieldModel, ObjectChange from utilities.models import ChangeLoggedModel +from utilities.utils import serialize_object from .constants import CIRCUIT_STATUS_ACTIVE, CIRCUIT_STATUS_CHOICES, TERM_SIDE_CHOICES @@ -270,6 +271,19 @@ class CircuitTermination(models.Model): def __str__(self): return '{} (Side {})'.format(self.circuit, self.get_term_side_display()) + def log_change(self, user, request_id, action): + """ + Reference the parent circuit when recording the change. + """ + ObjectChange( + user=user, + request_id=request_id, + changed_object=self, + related_object=self.circuit, + action=action, + object_data=serialize_object(self) + ).save() + def get_peer_termination(self): peer_side = 'Z' if self.term_side == 'A' else 'A' try: diff --git a/netbox/templates/extras/objectchange.html b/netbox/templates/extras/objectchange.html index 21922b60a..306aeeee0 100644 --- a/netbox/templates/extras/objectchange.html +++ b/netbox/templates/extras/objectchange.html @@ -8,7 +8,13 @@