{% extends 'driver27/base.html' %}
{% load i18n %}
{% block dr27_menu %}
    {% include 'driver27/season/season-menu-pre.html' %}
    {% include 'driver27/team/team-menu.html' %}

{% endblock %}
{% block dr27_content %}
    {{ block.super }}
{% load champion_filter i18n %}
    <form method="POST" class="form-inline">
    {% csrf_token %}
        <div class="form-group">
        <label for="record" class="control-label">Record:</label>
            <select id="record" name="record" onchange="change_record()" class="form-control input-sm">
            {% if not record %}
                <option value="">---</option>
            {% endif %}

            <optgroup label="{% trans 'Total' %}">
                {% with rank_group='STATS' record_url='season-team-record' %}
                    {% include 'driver27/team/team-record-optgroup.html' %}
                {% endwith %}
            </optgroup>

            <optgroup label="{% trans 'Races with at least one' %}">
                {% with rank_group='RACES' record_url='season-team-record-races' %}
                    {% include 'driver27/team/team-record-optgroup.html' %}
                {% endwith %}
            </optgroup>

            <optgroup label="{% trans 'Races with doubles' %}">
                {% with rank_group='DOUBLES' record_url='season-team-record-doubles' record_codes=doubles_record_codes %}
                    {% include 'driver27/team/team-record-optgroup.html' %}
                {% endwith %}
            </optgroup>

            </select>
        </div>
        <div class="clear"></div>

    </form>
    {% if rank %}
{#        <span class="help-block">#}
{#        {% if races %}#}
{#            <a href="{% url 'season-team-record' season.competition.slug season.year record %}">#}
{#            {% trans 'Current record' %}</a>#}
{#        {% else %}#}
{#            <a href="{% url 'season-team-record-races' season.competition.slug season.year record %}">#}
{#            {% trans 'Current record by race' %}</a>#}
{#        {% endif %}#}
{#        </span>#}
<table class="table table-condensed table-striped table-hover">
    <tr>
        <th>{%  trans 'Count' %}</th>
        <th>{%  trans 'Team' %}</th>
    </tr>
    {% for count,team in rank %}
        <tr>
        <td>{{ count }}</td>
        <td>{{ team }}</td>
        </tr>
    {% endfor %}

    </table>
    {% endif %}
{% endblock %}

{% block bootstrap3_extra_script %}
    {{ block.super }}
    <script type="text/javascript">
        function change_record(){
            var record = $('#record').val();
            location.href = record;
        }
    </script>
{% endblock %}