mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 03:16:25 -06:00
Restore functionality of showing Circuit when no Interface connected
This commit is contained in:
parent
1661af480f
commit
293937a1a7
@ -2673,6 +2673,8 @@ class Cable(ChangeLoggedModel):
|
|||||||
Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be
|
Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be
|
||||||
None.
|
None.
|
||||||
"""
|
"""
|
||||||
|
from circuits.models import CircuitTermination
|
||||||
|
|
||||||
a_path = self.termination_b.trace(follow_circuits=True)
|
a_path = self.termination_b.trace(follow_circuits=True)
|
||||||
b_path = self.termination_a.trace(follow_circuits=True)
|
b_path = self.termination_a.trace(follow_circuits=True)
|
||||||
|
|
||||||
@ -2689,4 +2691,16 @@ class Cable(ChangeLoggedModel):
|
|||||||
a_endpoint = a_path[-1][2]
|
a_endpoint = a_path[-1][2]
|
||||||
b_endpoint = b_path[-1][2]
|
b_endpoint = b_path[-1][2]
|
||||||
|
|
||||||
|
# If there is nothing on the other end show the first circuit
|
||||||
|
if not a_endpoint:
|
||||||
|
for segment in a_path:
|
||||||
|
if isinstance(segment[2], (Interface, CircuitTermination)):
|
||||||
|
a_endpoint = segment[2]
|
||||||
|
break
|
||||||
|
if not b_endpoint:
|
||||||
|
for segment in b_path:
|
||||||
|
if isinstance(segment[2], (Interface, CircuitTermination)):
|
||||||
|
b_endpoint = segment[2]
|
||||||
|
break
|
||||||
|
|
||||||
return a_endpoint, b_endpoint, path_status
|
return a_endpoint, b_endpoint, path_status
|
||||||
|
Loading…
Reference in New Issue
Block a user