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

Cache each CablePath on its originating endpoint

This commit is contained in:
Jeremy Stretch
2020-10-02 17:16:43 -04:00
parent 8cb636bed2
commit 5737f6fca0
6 changed files with 191 additions and 55 deletions

View File

@@ -1204,6 +1204,13 @@ class CablePath(models.Model):
path = ', '.join([str(path_node_to_object(node)) for node in self.path])
return f"Path #{self.pk}: {self.origin} to {self.destination} via ({path})"
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
# Record a direct reference to this CablePath on its originating object
model = self.origin._meta.model
model.objects.filter(pk=self.origin.pk).update(_path=self.pk)
#
# Virtual chassis