Parcourir la source

Allow for setting mgmt_only=True in "Add management interfaces" link

Jeremy Stretch il y a 8 ans
Parent
commit
46b1ac23af

+ 1 - 1
netbox/dcim/views.py

@@ -353,7 +353,7 @@ class ComponentTemplateCreateView(View):
         return render(request, 'dcim/component_template_add.html', {
             'devicetype': devicetype,
             'component_type': self.model._meta.verbose_name,
-            'form': self.form(),
+            'form': self.form(initial=request.GET),
             'cancel_url': reverse('dcim:devicetype', kwargs={'pk': devicetype.pk}),
         })
 

+ 5 - 1
netbox/templates/dcim/devicetype.html

@@ -75,11 +75,15 @@
                     <td>Is a Network Device</td>
                     <td>{{ devicetype.is_network_device|yesno|capfirst }}</td>
                 </tr>
+                <tr>
+                    <td>Parent/Child Role</td>
+                    <td>{{ devicetype.get_subdevice_role_display }}</td>
+                </tr>
             </table>
         </div>
         {% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' add_url='dcim:devicetype_add_consoleport' delete_url='dcim:devicetype_delete_consoleport' %}
         {% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' add_url='dcim:devicetype_add_powerport' delete_url='dcim:devicetype_delete_powerport' %}
-        {% include 'dcim/inc/devicetype_component_table.html' with table=mgmt_interface_table title='Management Interfaces' add_url='dcim:devicetype_add_interface' delete_url='dcim:devicetype_delete_interface' %}
+        {% include 'dcim/inc/devicetype_component_table.html' with table=mgmt_interface_table title='Management Interfaces' add_url='dcim:devicetype_add_interface' add_url_extra='?mgmt_only=1' delete_url='dcim:devicetype_delete_interface' %}
     </div>
     <div class="col-md-6">
         {% if devicetype.is_parent_device %}

+ 4 - 1
netbox/templates/dcim/inc/devicetype_component_table.html

@@ -4,7 +4,10 @@
         {% csrf_token %}
         <div class="panel panel-default">
             <div class="panel-heading">
-                <a href="{% url add_url pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add {{ title }}</a>
+                <a href="{% url add_url pk=devicetype.pk %}{{ add_url_extra }}" class="btn btn-primary btn-xs pull-right">
+                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
+                    Add {{ title }}
+                </a>
                 <strong>{{ title }}</strong>
             </div>
             {% render_table table 'table.html' %}