{% extends "admin/change_form.html" %}
{% load i18n admin_static admin_modify admin_urls %}


{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
&rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
&rsaquo;<a href="{% url opts|admin_urlname:'change' race.pk %}">{{ race }}</a>
&rsaquo; {{ title }}
</div>
{% endblock %}

{% block content %}

    <h3>{{ race.circuit }}</h3>
    <label for="select-all">{% trans 'Select all' %}</label>
    <input type="checkbox" id="select-all" value="1"/>

    <form method="POST">
    {% csrf_token %}
        <table>
            <tr>
                <th>{% trans 'Entry' %}</th>
                <th>{% trans 'Driver' %}</th>
                <th>{% trans 'Team' %}</th>
                <th>{% trans 'Qualifying' %}</th>
                <th>{% trans 'Finish' %}</th>
                <th>{% trans 'Fastest lap' %}</th>
                <th>{% trans 'Retired' %}</th>
                <th>{% trans 'Wildcard' %}</th>
                <th>{% trans 'Points' %}</th>
                <th>{% trans 'Season points' %}*</th>
            </tr>
            {% for entry in entries %}
            <tr>
                <td><input type="checkbox" name="entry[]" value="{{ entry.seat }}" class="entry" {% if entry.checked %}checked{% endif %}></td>
                <td>{{ entry.driver_name }}</td>
                <td>{{ entry.team }}</td>
                <td><input type="integer" name="seat-{{ entry.seat }}-qualifying" value="{% if entry.qualifying %}{{ entry.qualifying }}{% endif %}" size="3"></td>
                <td><input type="integer" name="seat-{{ entry.seat }}-finish" value="{% if entry.finish %}{{ entry.finish }}{% endif %}" size="3"></td>
                <td><input type="checkbox" name="seat-{{ entry.seat }}-fastest-lap" value="1" {% if entry.fastest_lap %}checked{% endif %}></td>
                <td><input type="checkbox" name="seat-{{ entry.seat }}-retired" value="1" {% if entry.retired %}checked{% endif %}></td>
                <td><input type="checkbox" name="seat-{{ entry.seat }}-wildcard" value="1" {% if entry.wildcard %}checked{% endif %}></td>
                <td>{% if entry.points %}{{ entry.points }}{% endif %}</td>
                <td>{% if entry.season_points %}{{ entry.season_points }}{% endif %}</td>
            </tr>
       {% endfor %}
    </table>
    <input type="submit" value="{% trans 'Send entries' %}"/>
    </form>


{% endblock %}

{% block extrahead %}
    {{ block.super }}
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('#select-all').click(function() {
                var c = this.checked;
                $('.entry').prop('checked',c);
            });
        });
    </script>
{% endblock %}