{% extends 'base.html' %}

{% load i18n %}

{% block title %}
    {% trans "Motion" %} {{ motion.identifier }}, {{ poll }} – {{ block.super }}
{% endblock %}

{% block content %}
<h1>
    {{ motion }}
    <br>
    <small>
    {% trans "Motion" %} {{ motion.identifier }}, {{ poll }}
    </small>
    <small class="pull-right">
    <div class="btn-toolbar">
        <a href="{% url 'motion_detail' motion.id %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to motion" %}</a>
        <!-- activate projector -->
        {% if perms.projector.can_manage_projector %}
            <a href="{% url 'projector_activate_slide' motion.sid %}" class="activate_link btn {% if motion.active %}btn-primary{% endif %} btn-mini" rel="tooltip" data-original-title="{% trans 'Show motion' %}">
                <i class="icon-facetime-video {% if motion.active %}icon-white{% endif %}"></i>
            </a>
        {% endif %}
    </div>
    </small>
</h1>

<p>
{% trans "Special values" %}: <span class="badge badge-success">-1</span> = {% trans 'majority' %} | <span class="badge">-2</span> = {% trans 'undocumented' %}
</p>
<form action="" method="post" class="small-form">{% csrf_token %}
    {{ pre_form }}
    <span id="poll_id" style="display:none">{{ poll.pk }}</span>
    <table class="table table-striped table-bordered" style="width: auto;">
        <tr>
            <th>{% trans "Option" %}</th>
            <th>{% trans "Votes" %}</th>
        </tr>
        {% for value in forms.0 %}
            <tr>
                <td>{{ value.label }}</td>
                <td>{{ value.errors }}{{ value }}</td>
            </tr>
        {% endfor %}
        <tr class="total">
            <td>{% trans "Invalid votes" %}</td>
            <td>{{ pollform.votesinvalid.errors }}{{ pollform.votesinvalid }}</td>
        </tr>
        <tr class="total">
            <td>{% trans "Votes cast" %}</td>
            <td>{{ pollform.votescast.errors }}{{ pollform.votescast }}</td>
        </tr>
    </table>

    {{ post_form }}

<!-- ballot paper button -->
<p>
<a href="{% url 'motion_poll_pdf' motion.id poll.poll_number %}" class="btn" target="_blank">
    <i class="icon-print"></i> {% trans 'Ballot paper as PDF' %}
</a>
</p>
<!-- Control buttons -->
<div class="control-group">
    <button type="submit" class="btn btn-primary">
        {% trans 'Save' %}
    </button>
    <button type="submit" name="apply" class="btn">
        {% trans 'Apply' %}
    </button>
    <a href="{% url 'motion_detail' motion.id %}" class="btn">
        {% trans 'Cancel' %}
    </a>
</div>
</form>
{% endblock %}
