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

{% has_perm user site_settings.change_setting as can_edit_setting %}
{% has_perm user photos.add_photoset as can_add_photoset %}

{% if nav_object %}
    {% has_perm user photos.view_photoset nav_object as can_view_photoset %}
    {% has_perm user photos.change_photoset nav_object as can_edit_photoset %}
    {% has_perm user photos.delete_photoset nav_object as can_delete_photoset %}
{% else %}
    {% has_perm user photos.view_photoset as can_view_photoset %}
    {% has_perm user photos.change_photoset as can_edit_photoset %}
{% 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_PHOTOS_LABEL 'Photos' %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All Photos" %}</li>
            <li class="divider"></li>
        {% else %}
            <div>
            <ul class="dropdown-menu">
        {% endif %}
            {% if can_edit_setting %}
                <li><a href="{% url settings.index "module" "photos" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            <li><a href="{% url photoset_latest %}">{% trans "Search Sets" %}</a></li>
            {% if can_add_photoset %}
                <li><a href="{% url photoset_add %}">{% trans "Add Photo Set" %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_photoset or can_edit_photoset %}
            <ul>
                <li class="heading">{% trans "This Photo Set" %}</li>
                <li class="divider"></li>
                {% if can_view_photoset %}
                    <li><a href="{{ nav_object.get_absolute_url }}">{% trans "View Photo Set" %}</a></li>
                {% endif %}
                {% if can_edit_photoset %}
                    <li><a href="{% url photoset_edit nav_object.pk %}">{% trans "Edit Photo Set" %}</a></li>
                    <li class="divider"></li>
                    <li><a href="{% url photos_batch_add nav_object.pk %}">{% trans "Add Photos" %}</a></li>
                    <li><a href="{% url photos_batch_edit nav_object.pk %}">{% trans "Edit Photos in Set" %}</a></li>
                {% endif %}
                {% if can_delete_photoset %}
                    <li class="divider"></li>
                    <li><a class="delete" href="{% url photoset_delete nav_object.pk %}">{% trans "Delete Photo Set" %}</a></li>
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
</ul>
