mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-27 15:47:46 -06:00
Compare commits
8 Commits
v4.3.5
...
Solcon-202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d1f5eaeb8 | ||
|
|
425670f52a | ||
|
|
9f7313e492 | ||
|
|
cf4dcd3dd7 | ||
|
|
b713fdbadc | ||
|
|
da13444d70 | ||
|
|
293937a1a7 | ||
|
|
1661af480f |
19
netbox/dcim/migrations/0070_multilink_circuit.py
Normal file
19
netbox/dcim/migrations/0070_multilink_circuit.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 2.2.2 on 2019-06-17 19:07
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0069_deprecate_nullablecharfield'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='interface',
|
||||
name='_connected_circuittermination',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='circuits.CircuitTermination'),
|
||||
),
|
||||
]
|
||||
@@ -2178,7 +2178,7 @@ class Interface(CableTermination, ComponentModel):
|
||||
blank=True,
|
||||
null=True
|
||||
)
|
||||
_connected_circuittermination = models.OneToOneField(
|
||||
_connected_circuittermination = models.ForeignKey(
|
||||
to='circuits.CircuitTermination',
|
||||
on_delete=models.SET_NULL,
|
||||
related_name='+',
|
||||
@@ -2971,8 +2971,10 @@ class Cable(ChangeLoggedModel):
|
||||
Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be
|
||||
None.
|
||||
"""
|
||||
a_path = self.termination_b.trace()
|
||||
b_path = self.termination_a.trace()
|
||||
from circuits.models import CircuitTermination
|
||||
|
||||
a_path = self.termination_b.trace(follow_circuits=True)
|
||||
b_path = self.termination_a.trace(follow_circuits=True)
|
||||
|
||||
# Determine overall path status (connected or planned)
|
||||
if self.status == CONNECTION_STATUS_PLANNED:
|
||||
@@ -2987,6 +2989,18 @@ 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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user