Browse Source

Fixes #435: Added a "add prefix" button to the VLAN view

Jeremy Stretch 8 years ago
parent
commit
ac2aa7ea89
2 changed files with 9 additions and 1 deletions
  1. 1 1
      netbox/ipam/views.py
  2. 8 0
      netbox/templates/ipam/vlan.html

+ 1 - 1
netbox/ipam/views.py

@@ -373,7 +373,7 @@ class PrefixEditView(PermissionRequiredMixin, ObjectEditView):
     permission_required = 'ipam.change_prefix'
     model = Prefix
     form_class = forms.PrefixForm
-    fields_initial = ['site', 'vrf', 'prefix']
+    fields_initial = ['vrf', 'tenant', 'site', 'prefix', 'vlan']
     cancel_url = 'ipam:prefix_list'
 
 

+ 8 - 0
netbox/templates/ipam/vlan.html

@@ -125,6 +125,14 @@
                 <strong>Prefixes</strong>
             </div>
             {% render_table prefix_table %}
+            {% if perms.ipam.add_prefix %}
+                <div class="panel-footer text-right">
+                    <a href="{% url 'ipam:prefix_add' %}?{% if vlan.tenant %}tenant={{ vlan.tenant.pk }}&{% endif %}site={{ vlan.site.pk }}&vlan={{ vlan.pk }}" class="btn btn-primary btn-xs">
+                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
+                        Add a prefix
+                    </a>
+                </div>
+            {% endif %}
         </div>
 	</div>
 </div>