mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge pull request #3765 from netbox-community/3760-template-buttons
Introduce clone, edit, and delete button templatetags
This commit is contained in:
@ -29,19 +29,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.circuits.add_circuit %}
|
{% if perms.circuits.add_circuit %}
|
||||||
{% clone_button 'circuits:circuit_add' circuit %}
|
{% clone_button circuit %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.circuits.change_circuit %}
|
{% if perms.circuits.change_circuit %}
|
||||||
<a href="{% url 'circuits:circuit_edit' pk=circuit.pk %}" class="btn btn-warning">
|
{% edit_button circuit %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this circuit
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.circuits.delete_circuit %}
|
{% if perms.circuits.delete_circuit %}
|
||||||
<a href="{% url 'circuits:circuit_delete' pk=circuit.pk %}" class="btn btn-danger">
|
{% delete_button circuit %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this circuit
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{{ circuit }}</h1>
|
<h1>{{ circuit }}</h1>
|
||||||
|
@ -30,24 +30,17 @@
|
|||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if show_graphs %}
|
{% if show_graphs %}
|
||||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#graphs_modal" data-obj="{{ provider.name }}" data-url="{% url 'circuits-api:provider-graphs' pk=provider.pk %}" title="Show graphs">
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#graphs_modal" data-obj="{{ provider.name }}" data-url="{% url 'circuits-api:provider-graphs' pk=provider.pk %}" title="Show graphs">
|
||||||
<i class="fa fa-signal" aria-hidden="true"></i>
|
<i class="fa fa-signal" aria-hidden="true"></i> Graphs
|
||||||
Graphs
|
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.circuits.add_provider %}
|
{% if perms.circuits.add_provider %}
|
||||||
{% clone_button 'circuits:provider_add' provider %}
|
{% clone_button provider %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.circuits.change_provider %}
|
{% if perms.circuits.change_provider %}
|
||||||
<a href="{% url 'circuits:provider_edit' slug=provider.slug %}" class="btn btn-warning">
|
{% edit_button provider %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this provider
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.circuits.delete_provider %}
|
{% if perms.circuits.delete_provider %}
|
||||||
<a href="{% url 'circuits:provider_delete' slug=provider.slug %}" class="btn btn-danger">
|
{% delete_button provider %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this provider
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{{ provider }}</h1>
|
<h1>{{ provider }}</h1>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
@ -13,14 +14,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.dcim.change_cable %}
|
{% if perms.dcim.change_cable %}
|
||||||
<a href="{% url 'dcim:cable_edit' pk=cable.pk %}" class="btn btn-warning">
|
{% edit_button cable %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span> Edit this cable
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_cable %}
|
{% if perms.dcim.delete_cable %}
|
||||||
<a href="{% url 'dcim:cable_delete' pk=cable.pk %}" class="btn btn-danger">
|
{% delete_button cable %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span> Delete this cable
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}Cable {{ cable }}{% endblock %}</h1>
|
<h1>{% block title %}Cable {{ cable }}{% endblock %}</h1>
|
||||||
|
@ -60,19 +60,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.add_device %}
|
{% if perms.dcim.add_device %}
|
||||||
{% clone_button 'dcim:device_add' device %}
|
{% clone_button device %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.change_device %}
|
{% if perms.dcim.change_device %}
|
||||||
<a href="{% url 'dcim:device_edit' pk=device.pk %}" class="btn btn-warning">
|
{% edit_button device %}
|
||||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this device
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_device %}
|
{% if perms.dcim.delete_device %}
|
||||||
<a href="{% url 'dcim:device_delete' pk=device.pk %}" class="btn btn-danger">
|
{% delete_button device %}
|
||||||
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
|
|
||||||
Delete this device
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{{ device }}</h1>
|
<h1>{{ device }}</h1>
|
||||||
|
@ -34,19 +34,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.add_devicetype %}
|
{% if perms.dcim.add_devicetype %}
|
||||||
{% clone_button 'dcim:devicetype_add' devicetype %}
|
{% clone_button devicetype %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.change_devicetype %}
|
{% if perms.dcim.change_devicetype %}
|
||||||
<a href="{% url 'dcim:devicetype_edit' pk=devicetype.pk %}" class="btn btn-warning">
|
{% edit_button devicetype use_pk=True %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this device type
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_devicetype %}
|
{% if perms.dcim.delete_devicetype %}
|
||||||
<a href="{% url 'dcim:devicetype_delete' pk=devicetype.pk %}" class="btn btn-danger">
|
{% delete_button devicetype use_pk=True %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this device type
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{{ devicetype.manufacturer }} {{ devicetype.model }}</h1>
|
<h1>{{ devicetype.manufacturer }} {{ devicetype.model }}</h1>
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.dcim.change_interface %}
|
{% if perms.dcim.change_interface %}
|
||||||
<a href="{% if interface.device %}{% url 'dcim:interface_edit' pk=interface.pk %}{% else %}{% url 'virtualization:interface_edit' pk=interface.pk %}{% endif %}" class="btn btn-warning">
|
<a href="{% if interface.device %}{% url 'dcim:interface_edit' pk=interface.pk %}{% else %}{% url 'virtualization:interface_edit' pk=interface.pk %}{% endif %}" class="btn btn-warning">
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span> Edit this interface
|
<span class="fa fa-pencil" aria-hidden="true"></span> Edit
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_interface %}
|
{% if perms.dcim.delete_interface %}
|
||||||
<a href="{% if interface.device %}{% url 'dcim:interface_delete' pk=interface.pk %}{% else %}{% url 'virtualization:interface_delete' pk=interface.pk %}{% endif %}" class="btn btn-danger">
|
<a href="{% if interface.device %}{% url 'dcim:interface_delete' pk=interface.pk %}{% else %}{% url 'virtualization:interface_delete' pk=interface.pk %}{% endif %}" class="btn btn-danger">
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span> Delete this interface
|
<span class="fa fa-trash" aria-hidden="true"></span> Delete
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,19 +32,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.dcim.add_powerfeed %}
|
{% if perms.dcim.add_powerfeed %}
|
||||||
{% clone_button 'dcim:powerfeed_add' powerfeed %}
|
{% clone_button powerfeed %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.change_powerfeed %}
|
{% if perms.dcim.change_powerfeed %}
|
||||||
<a href="{% url 'dcim:powerfeed_edit' pk=powerfeed.pk %}" class="btn btn-warning">
|
{% edit_button powerfeed %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this power feed
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_powerfeed %}
|
{% if perms.dcim.delete_powerfeed %}
|
||||||
<a href="{% url 'dcim:powerfeed_delete' pk=powerfeed.pk %}" class="btn btn-danger">
|
{% delete_button powerfeed %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this power feed
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ powerfeed }}{% endblock %}</h1>
|
<h1>{% block title %}{{ powerfeed }}{% endblock %}</h1>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load static %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<div class="row noprint">
|
<div class="row noprint">
|
||||||
@ -30,16 +31,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.dcim.change_powerpanel %}
|
{% if perms.dcim.change_powerpanel %}
|
||||||
<a href="{% url 'dcim:powerpanel_edit' pk=powerpanel.pk %}" class="btn btn-warning">
|
{% edit_button powerpanel %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this power panel
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_powerpanel %}
|
{% if perms.dcim.delete_powerpanel %}
|
||||||
<a href="{% url 'dcim:powerpanel_delete' pk=powerpanel.pk %}" class="btn btn-danger">
|
{% delete_button powerpanel %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this power panel
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ powerpanel }}{% endblock %}</h1>
|
<h1>{% block title %}{{ powerpanel }}{% endblock %}</h1>
|
||||||
|
@ -33,17 +33,13 @@
|
|||||||
<span class="fa fa-chevron-right" aria-hidden="true"></span> Next Rack
|
<span class="fa fa-chevron-right" aria-hidden="true"></span> Next Rack
|
||||||
</a>
|
</a>
|
||||||
{% if perms.dcim.add_rack %}
|
{% if perms.dcim.add_rack %}
|
||||||
{% clone_button 'dcim:rack_add' rack %}
|
{% clone_button rack %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.change_rack %}
|
{% if perms.dcim.change_rack %}
|
||||||
<a href="{% url 'dcim:rack_edit' pk=rack.pk %}" class="btn btn-warning">
|
{% edit_button rack %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span> Edit this rack
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_rack %}
|
{% if perms.dcim.delete_rack %}
|
||||||
<a href="{% url 'dcim:rack_delete' pk=rack.pk %}" class="btn btn-danger">
|
{% delete_button rack %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span> Delete this rack
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}Rack {{ rack }}{% endblock %}</h1>
|
<h1>{% block title %}Rack {{ rack }}{% endblock %}</h1>
|
||||||
|
@ -40,19 +40,13 @@
|
|||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.add_site %}
|
{% if perms.dcim.add_site %}
|
||||||
{% clone_button 'dcim:site_add' site %}
|
{% clone_button site %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.change_site %}
|
{% if perms.dcim.change_site %}
|
||||||
<a href="{% url 'dcim:site_edit' slug=site.slug %}" class="btn btn-warning">
|
{% edit_button site %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this site
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.dcim.delete_site %}
|
{% if perms.dcim.delete_site %}
|
||||||
<a href="{% url 'dcim:site_delete' slug=site.slug %}" class="btn btn-danger">
|
{% delete_button site %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this site
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ site }}{% endblock %}</h1>
|
<h1>{% block title %}{{ site }}{% endblock %}</h1>
|
||||||
|
@ -27,19 +27,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.ipam.add_aggregate %}
|
{% if perms.ipam.add_aggregate %}
|
||||||
{% clone_button 'ipam:aggregate_add' aggregate %}
|
{% clone_button aggregate %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.change_aggregate %}
|
{% if perms.ipam.change_aggregate %}
|
||||||
<a href="{% url 'ipam:aggregate_edit' pk=aggregate.pk %}" class="btn btn-warning">
|
{% edit_button aggregate %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this aggregate
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.delete_aggregate %}
|
{% if perms.ipam.delete_aggregate %}
|
||||||
<a href="{% url 'ipam:aggregate_delete' pk=aggregate.pk %}" class="btn btn-danger">
|
{% delete_button aggregate %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this aggregate
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ aggregate }}{% endblock %}</h1>
|
<h1>{% block title %}{{ aggregate }}{% endblock %}</h1>
|
||||||
|
@ -29,19 +29,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.ipam.add_ipaddress %}
|
{% if perms.ipam.add_ipaddress %}
|
||||||
{% clone_button 'ipam:ipaddress_add' ipaddress %}
|
{% clone_button ipaddress %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.change_ipaddress %}
|
{% if perms.ipam.change_ipaddress %}
|
||||||
<a href="{% url 'ipam:ipaddress_edit' pk=ipaddress.pk %}" class="btn btn-warning">
|
{%edit_button ipaddress %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this IP
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.delete_ipaddress %}
|
{% if perms.ipam.delete_ipaddress %}
|
||||||
<a href="{% url 'ipam:ipaddress_delete' pk=ipaddress.pk %}" class="btn btn-danger">
|
{% delete_button ipaddress %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this IP
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ ipaddress }}{% endblock %}</h1>
|
<h1>{% block title %}{{ ipaddress }}{% endblock %}</h1>
|
||||||
|
@ -40,19 +40,13 @@
|
|||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.add_prefix %}
|
{% if perms.ipam.add_prefix %}
|
||||||
{% clone_button 'ipam:prefix_add' prefix %}
|
{% clone_button prefix %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.change_prefix %}
|
{% if perms.ipam.change_prefix %}
|
||||||
<a href="{% url 'ipam:prefix_edit' pk=prefix.pk %}" class="btn btn-warning">
|
{% edit_button prefix %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this prefix
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.delete_prefix %}
|
{% if perms.ipam.delete_prefix %}
|
||||||
<a href="{% url 'ipam:prefix_delete' pk=prefix.pk %}" class="btn btn-danger">
|
{% delete_button prefix %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this prefix
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ prefix }}{% endblock %}</h1>
|
<h1>{% block title %}{{ prefix }}{% endblock %}</h1>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
@ -24,14 +25,14 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if perms.dcim.change_service %}
|
<div class="pull-right">
|
||||||
<div class="pull-right">
|
{% if perms.dcim.change_service %}
|
||||||
<a href="{% url 'ipam:service_edit' pk=service.pk %}" class="btn btn-warning">
|
{% edit_button service %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
{% endif %}
|
||||||
Edit this service
|
{% if perms.dcim.delete_service %}
|
||||||
</a>
|
{% delete_button service %}
|
||||||
</div>
|
{% endif %}
|
||||||
{% endif %}
|
</div>
|
||||||
<h1>{% block title %}{{ service }}{% endblock %}</h1>
|
<h1>{% block title %}{{ service }}{% endblock %}</h1>
|
||||||
{% include 'inc/created_updated.html' with obj=service %}
|
{% include 'inc/created_updated.html' with obj=service %}
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
|
@ -32,19 +32,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.ipam.add_vlan %}
|
{% if perms.ipam.add_vlan %}
|
||||||
{% clone_button 'ipam:vlan_add' vlan %}
|
{% clone_button vlan %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.change_vlan %}
|
{% if perms.ipam.change_vlan %}
|
||||||
<a href="{% url 'ipam:vlan_edit' pk=vlan.pk %}" class="btn btn-warning">
|
{% edit_button vlan %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this VLAN
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.delete_vlan %}
|
{% if perms.ipam.delete_vlan %}
|
||||||
<a href="{% url 'ipam:vlan_delete' pk=vlan.pk %}" class="btn btn-danger">
|
{% delete_button vlan %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this VLAN
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}VLAN {{ vlan.display_name }}{% endblock %}</h1>
|
<h1>{% block title %}VLAN {{ vlan.display_name }}{% endblock %}</h1>
|
||||||
|
@ -26,19 +26,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.ipam.add_vrf %}
|
{% if perms.ipam.add_vrf %}
|
||||||
{% clone_button 'ipam:vrf_add' vrf %}
|
{% clone_button vrf %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.change_vrf %}
|
{% if perms.ipam.change_vrf %}
|
||||||
<a href="{% url 'ipam:vrf_edit' pk=vrf.pk %}" class="btn btn-warning">
|
{% edit_button vrf %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this VRF
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.ipam.delete_vrf %}
|
{% if perms.ipam.delete_vrf %}
|
||||||
<a href="{% url 'ipam:vrf_delete' pk=vrf.pk %}" class="btn btn-danger">
|
{% delete_button vrf %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this VRF
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}VRF {{ vrf }}{% endblock %}</h1>
|
<h1>{% block title %}VRF {{ vrf }}{% endblock %}</h1>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load static %}
|
{% load buttons %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
{% load secret_helpers %}
|
{% load secret_helpers %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<div class="row noprint">
|
<div class="row noprint">
|
||||||
@ -16,16 +17,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.secrets.change_secret %}
|
{% if perms.secrets.change_secret %}
|
||||||
<a href="{% url 'secrets:secret_edit' pk=secret.pk %}" class="btn btn-warning">
|
{% edit_button secret %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this secret
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.secrets.delete_secret %}
|
{% if perms.secrets.delete_secret %}
|
||||||
<a href="{% url 'secrets:secret_delete' pk=secret.pk %}" class="btn btn-danger">
|
{% delete_button secret %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this secret
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ secret }}{% endblock %}</h1>
|
<h1>{% block title %}{{ secret }}{% endblock %}</h1>
|
||||||
|
@ -29,19 +29,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.tenancy.add_tenant %}
|
{% if perms.tenancy.add_tenant %}
|
||||||
{% clone_button 'tenancy:tenant_add' tenant %}
|
{% clone_button tenant %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.tenancy.change_tenant %}
|
{% if perms.tenancy.change_tenant %}
|
||||||
<a href="{% url 'tenancy:tenant_edit' slug=tenant.slug %}" class="btn btn-warning">
|
{% edit_button tenant %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this tenant
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.tenancy.delete_tenant %}
|
{% if perms.tenancy.delete_tenant %}
|
||||||
<a href="{% url 'tenancy:tenant_delete' slug=tenant.slug %}" class="btn btn-danger">
|
{% delete_button tenant %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this tenant
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ tenant }}{% endblock %}</h1>
|
<h1>{% block title %}{{ tenant }}{% endblock %}</h1>
|
||||||
|
@ -29,19 +29,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.virtualization.add_cluster %}
|
{% if perms.virtualization.add_cluster %}
|
||||||
{% clone_button 'virtualization:cluster_add' cluster %}
|
{% clone_button cluster %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.virtualization.change_cluster %}
|
{% if perms.virtualization.change_cluster %}
|
||||||
<a href="{% url 'virtualization:cluster_edit' pk=cluster.pk %}" class="btn btn-warning">
|
{% edit_button cluster %}
|
||||||
<span class="fa fa-pencil" aria-hidden="true"></span>
|
|
||||||
Edit this cluster
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.virtualization.delete_cluster %}
|
{% if perms.virtualization.delete_cluster %}
|
||||||
<a href="{% url 'virtualization:cluster_delete' pk=cluster.pk %}" class="btn btn-danger">
|
{% delete_button cluster %}
|
||||||
<span class="fa fa-trash" aria-hidden="true"></span>
|
|
||||||
Delete this cluster
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ cluster }}{% endblock %}</h1>
|
<h1>{% block title %}{{ cluster }}{% endblock %}</h1>
|
||||||
|
@ -28,19 +28,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pull-right noprint">
|
<div class="pull-right noprint">
|
||||||
{% if perms.virtualization.add_virtualmachine %}
|
{% if perms.virtualization.add_virtualmachine %}
|
||||||
{% clone_button 'virtualization:virtualmachine_add' virtualmachine %}
|
{% clone_button virtualmachine %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.virtualization.change_virtualmachine %}
|
{% if perms.virtualization.change_virtualmachine %}
|
||||||
<a href="{% url 'virtualization:virtualmachine_edit' pk=virtualmachine.pk %}" class="btn btn-warning">
|
{% edit_button virtualmachine %}
|
||||||
<span class="fa fa-pencil"></span>
|
|
||||||
Edit this VM
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.virtualization.delete_virtualmachine %}
|
{% if perms.virtualization.delete_virtualmachine %}
|
||||||
<a href="{% url 'virtualization:virtualmachine_delete' pk=virtualmachine.pk %}" class="btn btn-danger">
|
{% delete_button virtualmachine %}
|
||||||
<span class="fa fa-trash"></span>
|
|
||||||
Delete this VM
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<h1>{% block title %}{{ virtualmachine }}{% endblock %}</h1>
|
<h1>{% block title %}{{ virtualmachine }}{% endblock %}</h1>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<a href="{% url add_url %}" class="btn btn-primary">
|
<a href="{{ add_url }}" class="btn btn-primary">
|
||||||
<span class="fa fa-plus" aria-hidden="true"></span> Add
|
<span class="fa fa-plus" aria-hidden="true"></span> Add
|
||||||
</a>
|
</a>
|
||||||
|
3
netbox/utilities/templates/buttons/delete.html
Normal file
3
netbox/utilities/templates/buttons/delete.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<a href="{{ url }}" class="btn btn-danger">
|
||||||
|
<span class="fa fa-trash" aria-hidden="true"></span> Delete
|
||||||
|
</a>
|
3
netbox/utilities/templates/buttons/edit.html
Normal file
3
netbox/utilities/templates/buttons/edit.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<a href="{{ url }}" class="btn btn-warning">
|
||||||
|
<span class="fa fa-pencil" aria-hidden="true"></span> Edit
|
||||||
|
</a>
|
@ -7,8 +7,80 @@ from utilities.utils import prepare_cloned_fields
|
|||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
def _get_viewname(instance, action):
|
||||||
|
"""
|
||||||
|
Return the appropriate viewname for adding, editing, or deleting an instance.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Validate action
|
||||||
|
assert action in ('add', 'edit', 'delete')
|
||||||
|
viewname = "{}:{}_{}".format(
|
||||||
|
instance._meta.app_label, instance._meta.model_name, action
|
||||||
|
)
|
||||||
|
|
||||||
|
return viewname
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Instance buttons
|
||||||
|
#
|
||||||
|
|
||||||
|
@register.inclusion_tag('buttons/clone.html')
|
||||||
|
def clone_button(instance):
|
||||||
|
viewname = _get_viewname(instance, 'add')
|
||||||
|
|
||||||
|
# Populate cloned field values
|
||||||
|
param_string = prepare_cloned_fields(instance)
|
||||||
|
if param_string:
|
||||||
|
url = '{}?{}'.format(reverse(viewname), param_string)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'url': url,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('buttons/edit.html')
|
||||||
|
def edit_button(instance, use_pk=False):
|
||||||
|
viewname = _get_viewname(instance, 'edit')
|
||||||
|
|
||||||
|
# Assign kwargs
|
||||||
|
if hasattr(instance, 'slug') and not use_pk:
|
||||||
|
kwargs = {'slug': instance.slug}
|
||||||
|
else:
|
||||||
|
kwargs = {'pk': instance.pk}
|
||||||
|
|
||||||
|
url = reverse(viewname, kwargs=kwargs)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'url': url,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('buttons/delete.html')
|
||||||
|
def delete_button(instance, use_pk=False):
|
||||||
|
viewname = _get_viewname(instance, 'delete')
|
||||||
|
|
||||||
|
# Assign kwargs
|
||||||
|
if hasattr(instance, 'slug') and not use_pk:
|
||||||
|
kwargs = {'slug': instance.slug}
|
||||||
|
else:
|
||||||
|
kwargs = {'pk': instance.pk}
|
||||||
|
|
||||||
|
url = reverse(viewname, kwargs=kwargs)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'url': url,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# List buttons
|
||||||
|
#
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/add.html')
|
@register.inclusion_tag('buttons/add.html')
|
||||||
def add_button(url):
|
def add_button(url):
|
||||||
|
url = reverse(url)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'add_url': url,
|
'add_url': url,
|
||||||
}
|
}
|
||||||
@ -16,27 +88,19 @@ def add_button(url):
|
|||||||
|
|
||||||
@register.inclusion_tag('buttons/import.html')
|
@register.inclusion_tag('buttons/import.html')
|
||||||
def import_button(url):
|
def import_button(url):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'import_url': url,
|
'import_url': url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/clone.html')
|
|
||||||
def clone_button(url, instance):
|
|
||||||
|
|
||||||
url = reverse(url)
|
|
||||||
param_string = prepare_cloned_fields(instance)
|
|
||||||
if param_string:
|
|
||||||
url = '{}?{}'.format(url, param_string)
|
|
||||||
|
|
||||||
return {
|
|
||||||
'url': url,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('buttons/export.html', takes_context=True)
|
@register.inclusion_tag('buttons/export.html', takes_context=True)
|
||||||
def export_button(context, content_type=None):
|
def export_button(context, content_type=None):
|
||||||
|
if content_type is not None:
|
||||||
export_templates = ExportTemplate.objects.filter(content_type=content_type)
|
export_templates = ExportTemplate.objects.filter(content_type=content_type)
|
||||||
|
else:
|
||||||
|
export_templates = []
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'url_params': context['request'].GET,
|
'url_params': context['request'].GET,
|
||||||
'export_templates': export_templates,
|
'export_templates': export_templates,
|
||||||
|
Reference in New Issue
Block a user