mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fix tracing from front/rear ports
This commit is contained in:
@ -2026,6 +2026,7 @@ class PathTraceView(ObjectView):
|
|||||||
# If tracing a PathEndpoint, locate the CablePath (if one exists) by its origin
|
# If tracing a PathEndpoint, locate the CablePath (if one exists) by its origin
|
||||||
if isinstance(obj, PathEndpoint):
|
if isinstance(obj, PathEndpoint):
|
||||||
path = obj._path
|
path = obj._path
|
||||||
|
|
||||||
# Otherwise, find all CablePaths which traverse the specified object
|
# Otherwise, find all CablePaths which traverse the specified object
|
||||||
else:
|
else:
|
||||||
related_paths = CablePath.objects.filter(path__contains=obj).prefetch_related('origin')
|
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', {
|
return render(request, 'dcim/cable_trace.html', {
|
||||||
'obj': obj,
|
'obj': obj,
|
||||||
'path': obj.trace(),
|
'path': path,
|
||||||
'related_paths': related_paths,
|
'related_paths': related_paths,
|
||||||
'total_length': path.get_total_length(),
|
'total_length': path.get_total_length() if path else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-5 col-sm-12 text-center">
|
<div class="col-md-5 col-sm-12 text-center">
|
||||||
{% 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 #}
|
{# Near end #}
|
||||||
{% if near_end.device %}
|
{% if near_end.device %}
|
||||||
@ -50,7 +51,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h3 class="text-success text-center">Trace completed!</h3>
|
<h3 class="text-success text-center">Trace completed!</h3>
|
||||||
<h5>Total segments: {{ path|length }}</h5>
|
<h5>Total segments: {{ traced_path|length }}</h5>
|
||||||
{% if total_length %}
|
{% if total_length %}
|
||||||
<h5>Total length: {{ total_length|floatformat:"-2" }} Meters<h5>
|
<h5>Total length: {{ total_length|floatformat:"-2" }} Meters<h5>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -59,7 +60,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-7 col-sm-12">
|
<div class="col-md-7 col-sm-12">
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user