Browse Source

Fixes #903: Only alert on missing criticial connections if present in the parent device type

Jeremy Stretch 8 years ago
parent
commit
4d26fc7e7c
1 changed files with 30 additions and 24 deletions
  1. 30 24
      netbox/templates/dcim/device.html

+ 30 - 24
netbox/templates/dcim/device.html

@@ -240,38 +240,44 @@
                 {% for iface in mgmt_interfaces %}
                 {% for iface in mgmt_interfaces %}
                     {% include 'dcim/inc/interface.html' with icon='wrench' %}
                     {% include 'dcim/inc/interface.html' with icon='wrench' %}
                 {% empty %}
                 {% empty %}
-                    <tr>
-                        <td colspan="5" class="alert-warning">
-                            <i class="fa fa-fw fa-warning"></i> No management interfaces defined
-                            {% if perms.dcim.add_interface %}
-                                <a href="{% url 'dcim:interface_add' pk=device.pk %}?mgmt_only=1" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
-                            {% endif %}
-                        </td>
-                    </tr>
+                    {% if device.device_type.interface_templates.exists %}
+                        <tr>
+                            <td colspan="6" class="alert-warning">
+                                <i class="fa fa-fw fa-warning"></i> No management interfaces defined
+                                {% if perms.dcim.add_interface %}
+                                    <a href="{% url 'dcim:interface_add' pk=device.pk %}?mgmt_only=1" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
+                                {% endif %}
+                            </td>
+                        </tr>
+                    {% endif %}
                 {% endfor %}
                 {% endfor %}
                 {% for cp in console_ports %}
                 {% for cp in console_ports %}
                     {% include 'dcim/inc/consoleport.html' %}
                     {% include 'dcim/inc/consoleport.html' %}
                 {% empty %}
                 {% empty %}
-                    <tr>
-                        <td colspan="5" class="alert-warning">
-                            <i class="fa fa-fw fa-warning"></i> No console ports defined
-                            {% if perms.dcim.add_consoleport %}
-                                <a href="{% url 'dcim:consoleport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
-                            {% endif %}
-                        </td>
-                    </tr>
+                    {% if device.device_type.console_port_templates.exists %}
+                        <tr>
+                            <td colspan="6" class="alert-warning">
+                                <i class="fa fa-fw fa-warning"></i> No console ports defined
+                                {% if perms.dcim.add_consoleport %}
+                                    <a href="{% url 'dcim:consoleport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
+                                {% endif %}
+                            </td>
+                        </tr>
+                    {% endif %}
                 {% endfor %}
                 {% endfor %}
                 {% for pp in power_ports %}
                 {% for pp in power_ports %}
                     {% include 'dcim/inc/powerport.html' %}
                     {% include 'dcim/inc/powerport.html' %}
                 {% empty %}
                 {% empty %}
-                    <tr>
-                        <td colspan="5" class="alert-warning">
-                            <i class="fa fa-fw fa-warning"></i> No power ports defined
-                            {% if perms.dcim.add_powerport %}
-                                <a href="{% url 'dcim:powerport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
-                            {% endif %}
-                        </td>
-                    </tr>
+                    {% if device.device_type.power_port_templates.exists %}
+                        <tr>
+                            <td colspan="6" class="alert-warning">
+                                <i class="fa fa-fw fa-warning"></i> No power ports defined
+                                {% if perms.dcim.add_powerport %}
+                                    <a href="{% url 'dcim:powerport_add' pk=device.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
+                                {% endif %}
+                            </td>
+                        </tr>
+                    {% endif %}
                 {% endfor %}
                 {% endfor %}
             </table>
             </table>
             {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %}
             {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %}