{% load base_tags %}
{% load perm_tags %}
{% load i18n %}

{% has_perm user site_settings.change_setting as can_edit_setting %}
{% has_perm user articles.add_article as can_add_article %}

{% if nav_object %}
    {% has_perm user articles.view_article nav_object as can_view_article %}
    {% has_perm user articles.change_article nav_object as can_edit_article %}
    {% has_perm user articles.delete_article nav_object as can_delete_article %}
{% else %}
    {% has_perm user articles.view_article as can_view_article %}
    {% has_perm user articles.change_article as can_edit_article %}
{% endif %}

<ul id="module-tabs" class="tabs">
    {% if user.is_authenticated %}
    <li class="dropdown" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% trans "Tendenci" %}</a>
        <ul class="dropdown-menu">
            <a href="{% url dashboard %}" title="Tendenci Home Page">{% trans "Dashboard" %}</a>
            <li><a href="{% url profile.index %}">{% trans "My Profile" %}</a></li>
            <li><a href="{% url auth_logout %}">{% trans "Log Off" %}</a></li>
        </ul>
    </li>
    {% endif %}
    <li class="dropdown active" data-dropdown="dropdown">
        <a href="#" class="dropdown-toggle">{% firstof MODULE_ARTICLES_LABEL_PLURAL 'Articles' %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All" %} {% firstof MODULE_ARTICLES_LABEL_PLURAL 'Articles' %}</li>
            <li class="divider"></li>
        {% else %}
            <div>
            <ul class="dropdown-menu">
        {% endif %}
            {% if can_edit_setting %}
                <li><a href="{% url settings.index "module" "articles" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            <li><a href="{% url articles %}">{% trans "Latest" %} {% firstof MODULE_ARTICLES_LABEL_PLURAL 'Articles' %}</a></li>
            {% if can_add_article %}
                <li><a href="{% url article.add %}">{% trans "Add" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</a></li>
            {% endif %}
            {% if request.user.is_superuser %}
                <li><a href="{% url article.export %}">{% trans "Export" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_article or can_edit_article %}
            <ul>
                <li class="heading">{% trans "This" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</li>
                <li class="divider"></li>
                {% if can_view_article %}
                    <li><a href="{{ nav_object.get_absolute_url }}">{% trans "View" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</a></li>
                {% endif %}
                {% if can_edit_article %}
                    <li><a href="{% url article.edit nav_object.pk %}">{% trans "Edit" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</a></li>
                    <li><a href="{% url article.edit.meta nav_object.pk %}">{% trans "Edit Meta" %}</a></li>
                    <li><a href="{% url category.update nav_object.opt_app_label article.opt_module_name nav_object.pk %}">{% trans "Edit Categories" %}</a></li>
                {% endif %}
                {% if can_delete_article %}
                    <li class="divider"></li>
                    <li><a class="delete" href="{% url article.delete nav_object.pk %}">{% trans "Delete" %} {% firstof MODULE_ARTICLES_LABEL 'Article' %}</a></li>
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
    {% if MODULE_NEWS_ENABLED %}
    <li><a href="{% url news %}">{% firstof MODULE_NEWS_LABEL trans 'News' %}</a></li>
    {% endif %}
</ul>
