{% extends "base.html" %}
{% load i18n comments humanize thumbnail %}

{% block teaser %} <h1>{% trans 'Mai-Star Ranking' %} - {% trans 'Season' %} {{season}}</h1> {% endblock %}

{% block content %}
    <table>
        <thead>
        <tr>
            <th rowspan="2">{% trans "Placement" %}</th>
            <th rowspan="2">{% trans "Avatar" %}</th>
            <th rowspan="2">{% trans "Nickname" %}</th>
            <th rowspan="2">{% trans "Name" %}</th>
            <th colspan="2">{% trans 'Average' %}</th>
            <th colspan="3">{% trans 'Games' %}</th>
        </tr>
        <tr>
            <th>{% trans 'Placement' %}</th>
            <th>{% trans "Score" %}</th>
            <th>{% trans "count" %}</th>
            <th>{% trans "good" %}</th>
            <th>{% trans "won" %}</th>
        </tr>
        </thead>
        {% for player in ranking_list %}
        {% with player.user.get_profile as profile %}
        <tr>
            <td class="center">{{ player.placement|ordinal }}</td>
            <td><a href="{{ player.get_absolute_url }}"><img
                    src="{% thumbnail player.user.avatar|default:'unknown_profile.jpg' 'avatar' %}"
                    width="70" height="70" class="avatar" alt="{{ player.user }}"/></a></td>
            <td><a href="{{ player.get_absolute_url }}">{{player.user}}</a></td>
            <td>{% if user.is_authenticated %}{{profile.last_name}} {{profile.first_name}}{% else %} ---{% endif %}</td>
            <td class="right">{{player.avg_placement|floatformat:0 }}</td>
            <td class="right">{{player.avg_score|intcomma }}</td>
            <td class="right">{{player.games_count}}</td>
            <td class="right">{{player.games_good}}</td>
            <td class="right">{{player.games_won}}</td>
        </tr>
        {% endwith %}
        {% empty %}
        <tr>
            <td colspan="9">{% blocktrans %}Unfortunately, nobody has it been done in the ranking.
                A player must have 6 games done, to be added to the ranking.{% endblocktrans %}
            </td>
        </tr>
        {% endfor %}
    </table>
{% endblock %}

{% block redbox %}
<h2>{% trans 'Latest Games' %}</h2>
<ul class="fa-ul">
    {% for game in latest_games %}
    <li>
        <span class="fa-li fa fa-glass"></span>
        <a href="{% url 'maistar-game-list' game.event.pk %}">{{game.event.start|date:'SHORT_DATE_FORMAT'}}:</a>
        <small>{{game.player_names}}</small>
    </li>
    {% endfor %}
</ul>

<h3>{% trans 'Latest Events' %}</h3>
<ul class="fa-ul">
    {% for event in latest_events %}
    <li><span class="fa-li fa fa-calendar-o"></span> <a href="{% url 'maistar-game-list' event.pk %}">{{event.name}}</a></li>
    {% endfor %}
</ul>

<h3>{% trans 'Ladder Archive' %}</h3>
<form name="season_select">
    <label for="season">{% trans 'Season' %}</label>
        <select id="season" name="season" size="1" onChange="window.location.href = document.season_select.season.options[document.season_select.season.selectedIndex].value;">
        {% for season_link in season_list%}
        <option
          {% ifequal season season_link %} selected="selected"{% endifequal %}
          value="{% url 'maistar-ranking' season=season_link %}" >{{ season_link }}</option>
        {% endfor %}
        </select>
</form>

{% endblock %}