1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add GenericRelation to originating cable paths on PathEndpoint

This commit is contained in:
Jeremy Stretch
2020-10-01 11:30:03 -04:00
parent 46df5a97b2
commit 19a3a4d4ef
8 changed files with 50 additions and 87 deletions

View File

@@ -36,18 +36,7 @@
</td>
{# Connection #}
{% if cp.connected_endpoint %}
<td>
<a href="{% url 'dcim:device' pk=cp.connected_endpoint.device.pk %}">{{ cp.connected_endpoint.device }}</a>
</td>
<td>
{{ cp.connected_endpoint }}
</td>
{% else %}
<td colspan="2">
<span class="text-muted">Not connected</span>
</td>
{% endif %}
{% include 'dcim/inc/endpoint_connection.html' with paths=cp.paths.all %}
{# Actions #}
<td class="text-right noprint">

View File

@@ -38,18 +38,7 @@
</td>
{# Connection #}
{% if csp.connected_endpoint %}
<td>
<a href="{% url 'dcim:device' pk=csp.connected_endpoint.device.pk %}">{{ csp.connected_endpoint.device }}</a>
</td>
<td>
{{ csp.connected_endpoint }}
</td>
{% else %}
<td colspan="2">
<span class="text-muted">Not connected</span>
</td>
{% endif %}
{% include 'dcim/inc/endpoint_connection.html' with paths=csp.paths.all %}
{# Actions #}
<td class="text-right noprint">

View File

@@ -0,0 +1,10 @@
{% if paths|length > 1 %}
<td colspan="2">Multiple connections</td>
{% elif paths %}
{% with endpoint=paths.0.destination %}
<td><a href="{{ endpoint.parent.get_absolute_url }}">{{ endpoint.parent }}</a></td>
<td><a href="{{ endpoint.get_absolute_url }}">{{ endpoint }}</a></td>
{% endwith %}
{% else %}
<td colspan="2" class="text-muted">Not connected</td>
{% endif %}

View File

@@ -76,18 +76,7 @@
{% elif iface.is_wireless %}
<td colspan="2" class="text-muted">Wireless interface</td>
{% else %}
{% with path_count=iface.get_connections.count %}
{% if path_count > 1 %}
<td colspan="2">Multiple connections</td>
{% elif path_count %}
{% with endpoint=iface.get_connections.first.destination %}
<td><a href="{{ endpoint.parent.get_absolute_url }}">{{ endpoint.parent }}</a></td>
<td><a href="{{ endpoint.get_absolute_url }}">{{ endpoint }}</a></td>
{% endwith %}
{% else %}
<td colspan="2" class="text-muted">Not connected</td>
{% endif %}
{% endwith %}
{% include 'dcim/inc/endpoint_connection.html' with paths=iface.paths.all %}
{% endif %}
{# Buttons #}

View File

@@ -49,27 +49,20 @@
</td>
{# Connection #}
{% if po.connected_endpoint %}
{% with pp=po.connected_endpoint %}
<td>
<a href="{% url 'dcim:device' pk=pp.device.pk %}">{{ pp.device }}</a>
</td>
<td>
{{ pp }}
</td>
<td>
{% if pp.allocated_draw %}
{{ pp.allocated_draw }}W{% if pp.maximum_draw %} ({{ pp.maximum_draw }}W max){% endif %}
{% elif pp.maximum_draw %}
{{ pp.maximum_draw }}W
{% endif %}
</td>
{% endwith %}
{% else %}
<td colspan="3">
<span class="text-muted">Not connected</span>
{% with paths=po.paths.all %}
{% include 'dcim/inc/endpoint_connection.html' %}
<td>
{% if paths|length == 1 %}
{% with pp=paths.0.destination %}
{% if pp.allocated_draw %}
{{ pp.allocated_draw }}W{% if pp.maximum_draw %} ({{ pp.maximum_draw }}W max){% endif %}
{% elif pp.maximum_draw %}
{{ pp.maximum_draw }}W
{% endif %}
{% endwith %}
{% endif %}
</td>
{% endif %}
{% endwith %}
{# Actions #}
<td class="text-right noprint">

View File

@@ -45,22 +45,7 @@
</td>
{# Connection #}
{% if pp.connected_endpoint.device %}
<td>
<a href="{% url 'dcim:device' pk=pp.connected_endpoint.device.pk %}">{{ pp.connected_endpoint.device }}</a>
</td>
<td>
{{ pp.connected_endpoint }}
</td>
{% elif pp.connected_endpoint %}
<td colspan="2">
<a href="{{ pp.connected_endpoint.get_absolute_url }}">{{ pp.connected_endpoint }}</a>
</td>
{% else %}
<td colspan="2">
<span class="text-muted">Not connected</span>
</td>
{% endif %}
{% include 'dcim/inc/endpoint_connection.html' with paths=pp.paths.all %}
{# Actions #}
<td class="text-right noprint">