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

Swapped the order of cable and connection fields

This commit is contained in:
Jeremy Stretch
2018-10-26 13:21:43 -04:00
parent 83dec3b587
commit 94946c5854
9 changed files with 57 additions and 59 deletions

View File

@ -2392,9 +2392,7 @@ class Cable(ChangeLoggedModel):
)
def __str__(self):
if self.label:
return '{} (#{})'.format(self.label, self.pk)
return '#{}'.format(self.pk)
return self.label if self.label else '#{}'.format(self.pk)
def get_absolute_url(self):
return reverse('dcim:cable', args=[self.pk])

View File

@ -526,8 +526,8 @@
<th>LAG</th>
<th>Description</th>
<th>Mode</th>
<th colspan="2">Connection</th>
<th>Cable</th>
<th colspan="2">Connection</th>
<th></th>
</tr>
</thead>
@ -590,8 +590,8 @@
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
{% endif %}
<th>Name</th>
<th colspan="2">Connection</th>
<th>Cable</th>
<th colspan="2">Connection</th>
<th></th>
</tr>
</thead>
@ -649,8 +649,8 @@
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
{% endif %}
<th>Name</th>
<th colspan="2">Connection</th>
<th>Cable</th>
<th colspan="2">Connection</th>
<th></th>
</tr>
</thead>

View File

@ -5,6 +5,15 @@
<i class="fa fa-fw fa-keyboard-o"></i> {{ cp }}
</td>
{# Cable #}
<td>
{% with cable=cp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Connection #}
{% if cp.connected_endpoint %}
<td>
@ -19,15 +28,6 @@
</td>
{% endif %}
{# Cable #}
<td>
{% with cable=cp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right">
{% if perms.dcim.change_consoleport %}

View File

@ -12,6 +12,18 @@
<i class="fa fa-fw fa-keyboard-o"></i> {{ csp }}
</td>
{# Cable #}
<td>
{% with cable=csp.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Connection #}
{% if csp.connected_endpoint %}
<td>
@ -26,18 +38,6 @@
</td>
{% endif %}
{# Cable #}
<td>
{% with cable=csp.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right">
{% if perms.dcim.change_consoleserverport %}

View File

@ -23,7 +23,7 @@
{# Cable #}
<td>
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a>
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% else %}
<span class="text-muted">Not connected</span>
{% endif %}

View File

@ -28,6 +28,18 @@
{# 802.1Q mode #}
<td>{{ iface.get_mode_display }}</td>
{# Cable #}
<td>
{% with cable=iface.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Connection or type #}
{% if iface.is_lag %}
<td colspan="2" class="text-muted">
@ -69,18 +81,6 @@
</td>
{% endif %}
{# Cable #}
<td>
{% with cable=iface.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Buttons #}
<td class="text-right text-nowrap">
{% if show_graphs %}

View File

@ -12,6 +12,15 @@
<i class="fa fa-fw fa-bolt"></i> {{ po }}
</td>
{# Cable #}
<td>
{% with cable=po.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Connection #}
{% if po.connected_endpoint %}
<td>
@ -26,15 +35,6 @@
</td>
{% endif %}
{# Cable #}
<td>
{% with cable=po.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right">
{% if perms.dcim.change_poweroutlet %}

View File

@ -5,6 +5,15 @@
<i class="fa fa-fw fa-bolt"></i> {{ pp }}
</td>
{# Cable #}
<td>
{% with cable=pp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Connection #}
{% if pp.connected_endpoint %}
<td>
@ -19,15 +28,6 @@
</td>
{% endif %}
{# Cable #}
<td>
{% with cable=pp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right">
{% if perms.dcim.change_powerport %}

View File

@ -22,7 +22,7 @@
{# Cable #}
<td>
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a>
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% else %}
<span class="text-muted">Not connected</span>
{% endif %}