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

Refactor to_objectchange()

This commit is contained in:
jeremystretch
2022-01-26 20:25:23 -05:00
parent eb00e20269
commit b67859832a
7 changed files with 27 additions and 42 deletions

View File

@@ -75,13 +75,9 @@ class ComponentModel(PrimaryModel):
return self.name
def to_objectchange(self, action):
# Annotate the parent Device
try:
device = self.device
except ObjectDoesNotExist:
# The parent Device has already been deleted
device = None
return super().to_objectchange(action, related_object=device)
objectchange = super().to_objectchange(action)
objectchange.related_object = self.device
return super().to_objectchange(action)
@property
def parent_object(self):