{% extends 'assignment/base_assignment.html' %}

{% load i18n %}

{% block title %}{{ block.super }} – {% trans "Election" %} "{{ assignment }}" – {{ ballotnumber }}. {% trans "ballot" %}{% endblock %}

{% block content %}
    <h1>{{ assignment }} – {{ ballotnumber }}. {% trans "ballot" %}</h1>
    {% if assignment.polldescription %}
        <p><b>{% trans "Short description (for ballot paper)" %}:</b> {{ assignment.polldescription }}</p>
    {% endif %}
    <i class="helptext">{% trans "Special values" %}: -1 = {% trans 'majority' %}; -2 = {% trans 'undocumented' %}</i>

    <form action="" method="post" class="small-form">{% csrf_token %}

    <table style="width:auto">
        <tr>
            <th>{% trans "Candidates" %}</th>
            {% for value in poll.get_vote_values %}
                <th>{% trans value %}</th>
            {% endfor %}
        </tr>
        {% for form in forms %}
        <tr>
            <td>{{ form.option }}</td>
            {% for value in form %}
            <td>
                {{ value.errors }}
                {{ value }}
            </td>
            {% endfor %}
        </tr>
        {% endfor %}
            <tr class="total">
                <td>{% trans "Invalid votes" %}</td>
                {% for value in poll.get_vote_values %}
                    {% if forloop.first %}
                        <td>{{ pollform.votesinvalid.errors }}{{ pollform.votesinvalid }}</td>
                    {% else %}
                        <td></td>
                    {% endif %}
                {% endfor %}
            </tr>
            <tr class="total">
                <td>{% trans "Votes cast" %}</td>
                {% for value in poll.get_vote_values %}
                    {% if forloop.first %}
                        <td>{{ pollform.votescast.errors }}{{ pollform.votescast }}</td>
                    {% else %}
                        <td></td>
                    {% endif %}
                {% endfor %}
            </tr>
    </table>

    <p>
    <a href='{% url print_assignment_poll poll.id %}'>
    <button class="button" type="button" onclick="window.location='{% url print_assignment_poll poll.id %}'">
        <span class="icon pdf">{% trans 'Ballot paper as PDF' %}</span>
    </button>
    </a>
    </p>

    <p>
    <button class="button" type="submit">
        <span class="icon ok">{% trans 'Save' %}</span>
    </button>
    <button class="button" type="submit" name="apply">
        <span class="icon apply">{% trans 'Apply' %}</span>
    </button>
    <a href='{% url assignment_view poll.assignment.id %}'>
    <button class="button" type="button" onclick="window.location='{% url assignment_view poll.assignment.id %}'">
        <span class="icon cancel">{% trans 'Cancel' %}</span>
    </button>
    </a>
    </p>

    </form>
{% endblock %}
