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

{% has_perm user site_settings.change_setting as can_edit_setting %}
{% has_perm user stories.add_story as can_add_story %}

{% if nav_object %}
    {% has_perm user stories.view_story nav_object as can_view_story %}
    {% has_perm user stories.change_story nav_object as can_edit_story %}
    {% has_perm user stories.delete_story nav_object as can_delete_story %}
{% else %}
    {% has_perm user stories.view_story as can_view_story %}
    {% has_perm user stories.change_story as can_edit_story %}
    {% has_perm user stories.delete_story as can_delete_story %}
{% 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_STORIES_LABEL 'Stories' %}</a>
        {% if nav_object %}
        <div class="dropdown-menu">
        <ul class="first">
            <li class="heading">{% trans "All Stories" %}</li>
            <li class="divider"></li>
            {% else %}
            <div>
            <ul class="dropdown-menu">
            {% endif %}
            {% if can_edit_setting %}
                <li><a href="{% url settings.index "module" "stories" %}">{% trans "Settings" %}</a></li>
            {% endif %}
            <li><a href="{% url stories %}">{% trans "Story List" %}</a></li>
            {% if can_add_story %}
                <li><a href="{% url story.add %}">{% trans "Add Story" %}</a></li>
            {% endif %}
            {% if user.profile.is_superuser %}
                <li><a href="{% url story.export %}">{% trans "Export Stories" %}</a></li>
            {% endif %}
        </ul>
        {% if nav_object %}
            {% if can_view_story or can_edit_story %}
            <ul>
                <li class="heading">{% trans "This Story" %}</li>
                <li class="divider"></li>
                {% if can_view_story %}
                    <li><a href="{% url story nav_object.pk %}">{% trans "View Story" %}</a></li>
                {% endif %}
                {% if can_edit_story %}
                    <li><a href="{% url story.edit nav_object.pk %}">{% trans "Edit Story" %}</a></li>
                <!--<li><a href="{% url category.update nav_object.opt_app_label nav_object.opt_module_name nav_object.pk %}">{% trans "Edit Categories" %}</a></li>-->
                {% endif %}
                {% if can_delete_story %}
                    <li class="divider"></li>
                    <li><a class="delete" href="{% url story.delete story.pk %}">{% trans "Delete Story" %}</a></li>
                {% endif %}
            </ul>
            {% endif %}
        {% endif %}
        </div>
    </li>
    {% if MODULE_ARTICLES_ENABLED %}
    <li><a href="{% url articles %}">{{ MODULE_ARTICLES_LABEL }}</a></li>
    {% endif %}
    {% if MODULE_NEWS_ENABLED %}
    <li><a href="{% url news %}">{{ MODULE_NEWS_LABEL }}</a></li>
    {% endif %}
</ul>
