{% extends 'driver27/base.html' %}
{% load static i18n print_pos race_url %}
{% block dr27_content %}
    {{ block.super }}
    <div class="container-fluid">
        <div class="col-md-9">
            <div class="driver_image demo col-xs-12 col-md-3"><span class="placeholder-img-text">Photo</span></div>
            <div class="col-xs-12 col-md-9">
                <h1>
                    <small>{{ driver.first_name }}</small>
                    {{ driver.last_name }} <i class="flag2x {{ driver.country.flag_css }}"></i></h1>

            </div>
            <div class="clearfix"></div>
            <div class="col-md-12">
                {% if by_season %}
                    <h3>Stats by season</h3>
                    <table class="table table-striped text-right table-responsive">
                        <thead>
                        <tr>
                            <th>{% include 'driver27/_selector_competition.html' %}</th>
                            <th>Year</th>
                            <th>Teams</th>
                            <th>Races</th>
                            <th>P1</th>
                            <th>WIN</th>
                            <th>1-3</th>
                            <th>FL</th>
                            <th>Pts</th>
                            <th></th>
                        </tr>
                        </thead>

                        {% for season in by_season %}
                            <tr
                                    class="season-stat"
                                    data-competition="{{ season.competition.slug }}" data-year="{{ season.year }}">
                                <td>
                                    <a href="{{ season.competition.get_absolute_url }}">{{ season.competition }}</a>
                                </td>
                                <td>
                                    <a href="{{ season.get_absolute_url }}">{{ season.year }}</a>
                                </td>
                                <td>{{ season.teams }}</td>
                                <td>{{ season.stats.RACE }}</td>
                                <td>{{ season.stats.POLE }}</td>
                                <td>{{ season.stats.WIN }}</td>
                                <td>{{ season.stats.PODIUM }}</td>
                                <td>{{ season.stats.FASTEST }}</td>
                                <td>{{ season.stats.POINTS }}</td>
                                <td>{{ season.pos | print_pos | safe }}</td>
                            </tr>
                        {% endfor %}
                    </table>
                {% else %}
                    No results
                {% endif %}

            </div>

        </div>
        <div class="col-md-3 driver_summary">
            {% include 'driver27/_summary_profile.html' %}
        </div>
        <div class="clearfix"></div>
        <div class="col-md-9">
            {% if results %}
                <table class="table table-bordered table-striped profile-results-list">
                    <thead>
                    <tr>
                        <th>{% trans 'Race' %}</th>
                        <th>{% trans 'Grand Prix' %}</th>
                        <th>{% trans 'Country' %}</th>
                        <th>{% trans 'Qualifying' %}</th>
                        <th>{% trans 'Finish' %}</th>
                        <th>{% trans 'Retired' %}</th>
                        <th><i class="glyphicon glyphicon-time"></i> {% trans 'Fastest' %}</th>
                        <th>{% trans 'Points' %}</th>
                    </tr>

                    </thead>
                    {% for result in results %}
                        <tr class="profile-results"
                            data-race="{{ result.race_id }}"
                            data-qualifying="{{ result.qualifying }}"
                            data-finish="{{ result.finish }}"
                            data-retired="{{ result.retired }}"
                            data-fastest="{{ result.fastest_lap }}"
                            data-points="{{ result.points }}"

                        >
                            <td>{{ result.competition }}/{{ result.year }} {{ result.round|stringformat:"02d" }}</td>
                            <td><a href="{{ result.race_id|race_url }}">{{ result.grand_prix }}</a> {{ result.race }}</td>
                            <td class="text-center"><i class="{{ result.country.flag_css }}"></i></td>
                            <td>{{ result.qualifying }}</td>
                            <td>{{ result.finish|default_if_none:"-" }} </td>
                            <td>
                                <i class="glyphicon {% if result.retired %}text-danger glyphicon-remove-sign{% else %}glyphicon-flag{% endif %}"></i>
                            </td>
                            <td class="text-center">{% if result.fastest_lap %}
                                <i class="glyphicon glyphicon-time"></i>{% endif %}</td>
                            <td>{{ result.points|default_if_none:"0" }}</td>
                        </tr>
                    {% endfor %}
                </table>
            {% endif %}
        </div>


    </div>



{% endblock %}

{% block bootstrap3_extra_head %}
    {{ block.super }}
    <link rel="stylesheet" href="{% static 'flags/sprite-hq.css' %}">

{% endblock %}

{% block bootstrap3_extra_script %}
    {{ block.super }}
    <script src="{% static 'driver27/js/filter_season_by_competition.js' %}"></script>
{% endblock %}