1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Extend menu items and buttons to accept a list of required permissions

This commit is contained in:
Jeremy Stretch
2020-03-26 16:04:12 -04:00
parent 84d2db0d35
commit e7f7b14214
4 changed files with 38 additions and 27 deletions

View File

@@ -1,25 +1,22 @@
{% load helpers %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Plugins <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for section_name, menu_items in plugin_menu_items.items %}
<li class="dropdown-header">{{ section_name }}</li>
{% for menu_item in menu_items %}
{% if menu_item.permission %}
<li{% if not menu_item.permission in perms %} class="disabled"{% endif %}>
{% else %}
<li>
{% endif %}
{% if menu_item.buttons %}
<div class="buttons pull-right">
{% for button in menu_item.buttons %}
{% if not button.permission or button.permission in perms %}
<a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="fa {{ button.icon_class }}"></i></a>
{% endif %}
{% endfor %}
</div>
{% endif %}
<a href="{% url menu_item.link %}">{{ menu_item.link_text }}</a>
</li>
<li{% if menu_item.permissions and not request.user|has_perms:menu_item.permissions %} class="disabled"{% endif %}>
{% if menu_item.buttons %}
<div class="buttons pull-right">
{% for button in menu_item.buttons %}
{% if not button.permissions or request.user|has_perms:button.permissions %}
<a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="fa {{ button.icon_class }}"></i></a>
{% endif %}
{% endfor %}
</div>
{% endif %}
<a href="{% url menu_item.link %}">{{ menu_item.link_text }}</a>
</li>
{% endfor %}
{% if not forloop.last %}
<li class="divider"></li>