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

Enabled change logging for circuit terminations

This commit is contained in:
Jeremy Stretch
2018-07-12 13:46:30 -04:00
parent 931c58bc9a
commit bbaa3a2058
2 changed files with 22 additions and 2 deletions

View File

@@ -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: