{% extends "events/event_detail.html" %}
{% load i18n comments humanize thumbnail %}

{% block title %}{% trans "Tournament Ranking" %}: {{ event.name }}{% endblock %}
{% block teaser %}<h1>{% trans "Tournament Ranking" %}: {{ event.name }}</h1>{% endblock %}

{% block maincontent %}
<div class="grid_12">
<table>
<thead>
<tr>
 <th rowspan="2">{% trans "Rank" %}</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 'Hanchans' %}</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 eventranking_list %}
  <tr>
      <td class="center">{{player.placement}}.</td>
      <td><a href="{{ player.get_absolute_url }}?season={{season}}"><img
             src="{% thumbnail player.user.avatar|default:'unknown_profile.jpg' 'avatar' %}"
             width="70" height="70" class="avatar" alt=""/></a></td>
      <td><a href="{{ player.get_absolute_url }}?season={{season}}">{{player.user}}</a></td>
      <td>{% if user.is_authenticated %}{{player.user.last_name}}
         {{player.user.first_name}}{% else %}---{% endif %}</td>
      <td class="center">{{player.avg_placement|floatformat:2}}</td>
      <td class="right">{{player.avg_score|floatformat:0|intcomma }}</td>
      <td class="right">{{player.hanchan_count}}</td>
      <td class="right">{{player.good_hanchans}}</td>
      <td class="right">{{player.won_hanchans}}</td>
  </tr>
{% empty %}
  <tr><td colspan="9">Leider hat es noch niemand in das Ranking geschafft.</td></tr>
{% endfor %}
</table>
</div>
{% endblock %}

{% block buttonbar %}
{% if perms.mahjong_ranking.add_hanchan %}
<a class="button" href="{{event.get_edit_url}}"><span class="fa fa-pencil"></span> {% trans 'Edit Event' %}</a>
<a class="button" href="{% url 'add-hanchan-form' event.id %}"><span class="fa fa-plus-circle"></span> {% trans 'Add Hanchan' %}</a>
{% endif %}
{% endblock %}