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

{% has_perm user site_settings.change_setting as can_edit_setting %}
{% has_perm user locations.add_location as can_add_location %}

{% if nav_object %}
	{% has_perm user locations.view_location nav_object as can_view_location %}
	{% has_perm user locations.change_location nav_object as can_edit_location %}
	{% has_perm user locations.delete_location nav_object as can_delete_location %}
{% else %}
	{% has_perm user locations.view_location as can_view_location %}
	{% has_perm user locations.change_location as can_edit_location %}
{% 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_LOCATIONS_LABEL_PLURAL 'Locations' %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All" %} {% firstof MODULE_LOCATIONS_LABEL_PLURAL 'Locations' %}</li>
            <li class="divider"></li>
        {% else %}
            <div>
            <ul class="dropdown-menu">
        {% endif %}
            {% if can_edit_setting %}
                <li><a href="{% url settings.index "module" "locations" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            <li><a href="{% url locations %}">{% trans "List of " %} {% firstof MODULE_LOCATIONS_LABEL_PLURAL 'Locations' %}</a></li>
            <li><a href="{% url location.nearest %}">{% trans "Nearest" %} {% firstof MODULE_LOCATIONS_LABEL_PLURAL 'Locations' %}</a></li>
            {% if can_add_location %}
                <li><a href="{% url location.add %}">{% trans "Add" %} {% firstof MODULE_LOCATIONS_LABEL 'Location' %}</a></li>
                <li class="divider"></li>
                <li><a href="{% url locations_import_upload_file %}">{% trans "Import" %} {% firstof MODULE_LOCATIONS_LABEL 'Locations' %}</a></li>
            {% endif %}
            {% if user.profile.is_superuser %}
                <li><a href="{% url locations_export %}">{% trans "Export" %} {% firstof MODULE_LOCATIONS_LABEL 'Locations' %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_location or can_edit_location %}
            <ul>
                <li class="heading">{% trans "This" %} {% firstof MODULE_LOCATIONS_LABEL 'Location' %}</li>
                <li class="divider"></li>
                {% if can_view_location %}
                    <li><a href="{{ nav_object.get_absolute_url }}">{% trans "View" %} {% firstof MODULE_LOCATIONS_LABEL 'Location' %}</a></li>
                {% endif %}
                {% if can_edit_location %}
                    <li><a href="{% url location.edit nav_object.pk %}">{% trans "Edit" %} {% firstof MODULE_LOCATIONS_LABEL 'Location' %}</a></li>
                {% endif %}
                {% if can_delete_location %}
                    <li class="divider"></li>
                    <li><a class="delete" href="{% url location.delete nav_object.pk %}">{% trans "Delete" %} {% firstof MODULE_LOCATIONS_LABEL 'Location' %}</a></li>
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
</ul>
