{% 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 registry.plugin_menu_items.items %}
            <li class="dropdown-header">{{ section_name }}</li>
            {% for menu_item in menu_items %}
                <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="{{ 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>
            {% endif %}
        {% endfor %}
    </ul>
</li>
