diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 60ed0e7b2..72b691528 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -2026,6 +2026,7 @@ class PathTraceView(ObjectView): # If tracing a PathEndpoint, locate the CablePath (if one exists) by its origin if isinstance(obj, PathEndpoint): path = obj._path + # Otherwise, find all CablePaths which traverse the specified object else: related_paths = CablePath.objects.filter(path__contains=obj).prefetch_related('origin') @@ -2041,9 +2042,9 @@ class PathTraceView(ObjectView): return render(request, 'dcim/cable_trace.html', { 'obj': obj, - 'path': obj.trace(), + 'path': path, 'related_paths': related_paths, - 'total_length': path.get_total_length(), + 'total_length': path.get_total_length() if path else None, }) diff --git a/netbox/templates/dcim/cable_trace.html b/netbox/templates/dcim/cable_trace.html index 7e5622f07..1fb580c7e 100644 --- a/netbox/templates/dcim/cable_trace.html +++ b/netbox/templates/dcim/cable_trace.html @@ -8,58 +8,59 @@ {% block content %}
- {% for near_end, cable, far_end in path %} + {% with traced_path=path.origin.trace %} + {% for near_end, cable, far_end in traced_path %} - {# Near end #} - {% if near_end.device %} - {% include 'dcim/trace/device.html' with device=near_end.device %} - {% include 'dcim/trace/termination.html' with termination=near_end %} - {% elif near_end.power_panel %} - {% include 'dcim/trace/powerfeed.html' with powerfeed=near_end %} - {% elif near_end.circuit %} - {% include 'dcim/trace/circuit.html' with circuit=near_end.circuit %} - {% include 'dcim/trace/termination.html' with termination=near_end %} - {% else %} -

Split Paths!

- {# TODO: Present the user with successive paths to choose from #} - {% endif %} - - {# Cable #} - {% if cable %} -
- {% include 'dcim/trace/cable.html' %} -
- {% endif %} - - {# Far end #} - {% if far_end.device %} - {% include 'dcim/trace/termination.html' with termination=far_end %} - {% if forloop.last %} - {% include 'dcim/trace/device.html' with device=far_end.device %} + {# Near end #} + {% if near_end.device %} + {% include 'dcim/trace/device.html' with device=near_end.device %} + {% include 'dcim/trace/termination.html' with termination=near_end %} + {% elif near_end.power_panel %} + {% include 'dcim/trace/powerfeed.html' with powerfeed=near_end %} + {% elif near_end.circuit %} + {% include 'dcim/trace/circuit.html' with circuit=near_end.circuit %} + {% include 'dcim/trace/termination.html' with termination=near_end %} + {% else %} +

Split Paths!

+ {# TODO: Present the user with successive paths to choose from #} {% endif %} - {% elif far_end.power_panel %} - {% include 'dcim/trace/powerfeed.html' with powerfeed=far_end %} - {% elif far_end.circuit %} - {% include 'dcim/trace/termination.html' with termination=far_end %} - {% if forloop.last %} - {% include 'dcim/trace/circuit.html' with circuit=far_end.circuit %} - {% endif %} - {% endif %} - {% if forloop.last and far_end %} -
-
-

Trace completed!

-
Total segments: {{ path|length }}
- {% if total_length %} -
Total length: {{ total_length|floatformat:"-2" }} Meters
- {% endif %} + {# Cable #} + {% if cable %} +
+ {% include 'dcim/trace/cable.html' %}
-
- {% endif %} + {% endif %} - {% endfor %} + {# Far end #} + {% if far_end.device %} + {% include 'dcim/trace/termination.html' with termination=far_end %} + {% if forloop.last %} + {% include 'dcim/trace/device.html' with device=far_end.device %} + {% endif %} + {% elif far_end.power_panel %} + {% include 'dcim/trace/powerfeed.html' with powerfeed=far_end %} + {% elif far_end.circuit %} + {% include 'dcim/trace/termination.html' with termination=far_end %} + {% if forloop.last %} + {% include 'dcim/trace/circuit.html' with circuit=far_end.circuit %} + {% endif %} + {% endif %} + {% if forloop.last and far_end %} +
+
+

Trace completed!

+
Total segments: {{ traced_path|length }}
+ {% if total_length %} +
Total length: {{ total_length|floatformat:"-2" }} Meters
+ {% endif %} +
+
+ {% endif %} + + {% endfor %} + {% endwith %}