Просмотр исходного кода

Show the last node in a CablePath with no destination

Jeremy Stretch 4 лет назад
Родитель
Сommit
5e4432b9ad
2 измененных файлов с 8 добавлено и 1 удалено
  1. 7 0
      netbox/dcim/models/cables.py
  2. 1 1
      netbox/dcim/tables/devices.py

+ 7 - 0
netbox/dcim/models/cables.py

@@ -505,6 +505,13 @@ class CablePath(BigIDModel):
 
 
         return path
         return path
 
 
+    @property
+    def last_node(self):
+        """
+        Return either the destination or the last node within the path.
+        """
+        return self.destination or path_node_to_object(self.path[-1])
+
     def get_cable_ids(self):
     def get_cable_ids(self):
         """
         """
         Return all Cable IDs within the path.
         Return all Cable IDs within the path.

+ 1 - 1
netbox/dcim/tables/devices.py

@@ -260,7 +260,7 @@ class CableTerminationTable(BaseTable):
 
 
 class PathEndpointTable(CableTerminationTable):
 class PathEndpointTable(CableTerminationTable):
     connection = tables.TemplateColumn(
     connection = tables.TemplateColumn(
-        accessor='_path.destination',
+        accessor='_path.last_node',
         template_code=CABLETERMINATION,
         template_code=CABLETERMINATION,
         verbose_name='Connection',
         verbose_name='Connection',
         orderable=False
         orderable=False