Skip to content

Commit aa05097

Browse files
committed
Fixes netbox-community#7279: Fix exception when tracing cable with no associated path
1 parent de58f53 commit aa05097

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/release-notes/version-3.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [#7167](https://github.com/netbox-community/netbox/issues/7167) - Ensure consistent font size when using monospace formatting
1616
* [#7226](https://github.com/netbox-community/netbox/issues/7226) - Exempt GraphQL API requests from CSRF inspection
1717
* [#7248](https://github.com/netbox-community/netbox/issues/7248) - Fix global search results section links
18+
* [#7279](https://github.com/netbox-community/netbox/issues/7279) - Fix exception when tracing cable with no associated path
1819

1920
---
2021

netbox/dcim/views.py

+6
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,12 @@ def get_extra_context(self, request, instance):
24112411
else:
24122412
path = related_paths.first()
24132413

2414+
# No paths found
2415+
if path is None:
2416+
return {
2417+
'path': None
2418+
}
2419+
24142420
# Get the total length of the cable and whether the length is definitive (fully defined)
24152421
total_length, is_definitive = path.get_total_length() if path else (None, False)
24162422

netbox/templates/dcim/cable_trace.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
{% block content %}
77
<div class="row">
8+
9+
{# Cable trace SVG & options #}
810
<div class="col col-md-5">
11+
{% if path %}
912
<div class="text-center my-3">
1013
<object data="{{ svg_url }}" class="rack_elevation"></object>
1114
<a class="btn btn-outline-primary btn-sm my-3" href="{{ svg_url }}">
@@ -51,9 +54,15 @@ <h3 class="text-center text-success">Trace Completed</h3>
5154
{% endif %}
5255
{% endwith %}
5356
</div>
57+
{% else %}
58+
<h3 class="text-center text-muted my-3">
59+
No paths found
60+
</h3>
61+
{% endif %}
5462
</div>
55-
<div class="col col-md-7">
5663

64+
{# Related paths #}
65+
<div class="col col-md-7">
5766
<div class="card">
5867
<h5 class="card-header">
5968
Related Paths
@@ -95,7 +104,7 @@ <h5 class="card-header">
95104
</table>
96105
</div>
97106
</div>
98-
99107
</div>
108+
100109
</div>
101110
{% endblock %}

0 commit comments

Comments
 (0)