From 293937a1a7aca4836bb80b00d4539818369796d4 Mon Sep 17 00:00:00 2001 From: Sander Steffann Date: Mon, 17 Jun 2019 21:29:43 +0200 Subject: [PATCH] Restore functionality of showing Circuit when no Interface connected --- netbox/dcim/models.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index e3529a47b..145d938b8 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -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 None. """ + from circuits.models import CircuitTermination + a_path = self.termination_b.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] 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