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

Add segment_count property to CablePath

This commit is contained in:
Jeremy Stretch
2020-11-13 12:11:53 -05:00
parent e84a6b99a8
commit eb5f6167a5

View File

@ -379,6 +379,11 @@ class CablePath(models.Model):
model = self.origin._meta.model
model.objects.filter(pk=self.origin.pk).update(_path=self.pk)
@property
def segment_count(self):
total_length = 1 + len(self.path) + (1 if self.destination else 0)
return int(total_length / 3)
def get_path(self):
"""
Return the path as a list of prefetched objects.