Просмотр исходного кода

Swapped the order of cable and connection fields

Jeremy Stretch 7 лет назад
Родитель
Сommit
94946c5854

+ 1 - 3
netbox/dcim/models.py

@@ -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])

+ 3 - 3
netbox/templates/dcim/device.html

@@ -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>

+ 9 - 9
netbox/templates/dcim/inc/consoleport.html

@@ -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 %}

+ 12 - 12
netbox/templates/dcim/inc/consoleserverport.html

@@ -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 %}

+ 1 - 1
netbox/templates/dcim/inc/frontport.html

@@ -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 %}

+ 12 - 12
netbox/templates/dcim/inc/interface.html

@@ -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 %}

+ 9 - 9
netbox/templates/dcim/inc/poweroutlet.html

@@ -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 %}

+ 9 - 9
netbox/templates/dcim/inc/powerport.html

@@ -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 %}

+ 1 - 1
netbox/templates/dcim/inc/rearport.html

@@ -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 %}