{% extends "base.html" %}

{% load tags %}
{% load i18n %}
{% load staticfiles %}

{% block header %}
    <link type="text/css" rel="stylesheet" media="all" href="{% static 'styles/assignment.css' %}" />
    <script type="text/javascript" src="{% static 'javascript/assignment.js' %}"></script>
{% endblock %}

{% block submenu %}
    {% url assignment_overview as url_assignment_overview %}
    <h4 class="sectiontitle">{% trans "Elections" %}</h4>
    <ul>
        <li class="{% if request.path == url_assignment_overview %}selected{% endif %}"><a href="{% url assignment_overview %}">{% trans "All elections" %}</a></li>
        {% if perms.assignment.can_manage_assignment %}
            <li class="{% active request '/assignment/new' %}"><a href="{% url assignment_new %}">{% trans "New election" %}</a></li>
        {% endif %}
        <li><a href="{% url print_assignment %}"><img src="{% static 'images/icons/pdf.png' %}"> {% trans 'All elections as PDF' %}</a></li>
    </ul>

    {# second submenu #}
    {% if assignment %}
        <br>
        <h3>{{assignment}}</h3>
        <ul>
            {# view assignemnt #}
            {% url assignment_view assignment.id as url_assignmentview %}
            <li class="{% if request.path == url_assignmentview %}selected{% endif %}">
                <a href="{% url assignment_view assignment.id  %}">{% trans 'View election' %}</a>
            </li>

            {% if perms.assignment.can_manage_assignment %}

                {# edit assignemnt #}
                {% url assignment_edit assignment.id as url_assignmentedit %}
                <li class="{% if request.path == url_assignmentedit %}selected{% endif %}">
                    <a href="{% url assignment_edit assignment.id  %}"><img src="{% static 'images/icons/edit.png' %}"> {% trans 'Edit election' %}</a>
                </li>

                {# delete assignment #}
                <li>
                    <a href="{% url assignment_delete assignment.id  %}"><img src="{% static 'images/icons/delete.png' %}"> {% trans 'Delete election' %}</a>
                </li>
            {% endif %}

            {# PDF #}
            <li>
                <a href="{% url print_assignment assignment.id  %}"><img src="{% static 'images/icons/pdf.png' %}"> {% trans 'Election as PDF' %}</a>
            </li>

            {# activate #}
            {% if perms.projector.can_manage_projector %}
            <li>
                <a class="activate_link {% if item.active %}active{% endif %}" href="{% url projector_activate_slide assignment.sid  %}"><img src="{% static 'images/icons/projector.png' %}"> {% trans 'Show election' %}</a>
            </li>
            {% endif %}

            {# agenda #}
            {% if perms.agenda.can_manage_agenda %}
            <li>
                <a href="{% url assignment_create_agenda assignment.id  %}">{% trans 'New agenda item' %}</a>
            </li>
            {% endif %}

            {# polls #}
            {% if perms.assignment.can_manage_assignment %}
            {% for poll in polls %}
                {% url assignment_poll_view poll.id as url_assignmentpollview %}
                <li class="{% if request.path == url_assignmentpollview %}selected{% endif %}"><a href="{% url assignment_poll_view poll.id %}"><img src="{% static 'images/icons/edit.png' %}"> {{ forloop.counter }}. {% trans "ballot" %}</a></li>
            {% endfor %}
            {% endif %}
        </ul>
    {% endif %}
{% endblock %}
