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

{% block title %}Hanchans: {{ event.name }}{% endblock %}

{% block maincontent %}
<h2 class="grid_12">{% trans 'Played Hanchans' %}</h2>
<p>&nbsp;</p>
{% for hanchan in hanchan_list %}
    <h3 class="grid_12" id="{{ hanchan.pk }}">{{hanchan.start|time:'H:i'}}: {{ hanchan.player_names }}</h3>
    {% for player in hanchan.player_list %}
        <div class="grid_3">
            <a href="{% url 'player-ladder-score' player.user %}" class="avatar"><img
               src="{% thumbnail player.user.avatar|default:'unknown_profile.jpg' 'avatar' %}"
               width="70" height="70" alt="" title="{{ player.user }}"/></a>
            <a class="player" href="{% url 'player-ladder-score' player.user %}" title="{{ player.comment }}">{{ player.user }}</a>
            <ul class="fa-ul">
                <li><strong>{{ player.placement|ordinal }} {% trans 'Place' %}</strong></li>
                <li><strong>{% trans 'Score' %}:</strong> {{ player.game_score|intcomma }}</li>
                {% if player.dan_points != None %}
                <li><strong>{% trans 'Dan Points' %}:</strong> {{ player.dan_points }}</li>
                {% else %}
                <li><strong>{% trans 'Kyu Points' %}:</strong> {{ player.kyu_points|default:0 }}</li>
                {% endif %}
            </ul>
        </div>
    {% endfor %}
    {% if not hanchan.confirmed %}
        <p class="grid_12 error">Diese Hanchan wurde nicht anerkannt und wird daher nicht gezählt.</p>
    {% elif hanchan.comment %}
        <p class="grid_12">{{ hanchan.comment }}</p>
    {% endif %}
    <p class="grid_12 more_link">
        {% if perms.mahjong_ranking.delete_hanchan %}
            <a href="{% url 'delete-hanchan' hanchan.pk %}" class="button">
                <span class="fa fa-trash"></span>
                {% trans 'Delete Hanchan' %}
            </a>
        {% endif %}
        {% if perms.mahjong_ranking.change_hanchan %}
            <a href="{% url 'edit-hanchan' hanchan.pk %}" class="button">
                <span class="fa fa-pencil"></span>
                {% trans 'Edit Hanchan' %}
            </a>
        {% endif %}
    </p>
{% empty %}
    <h3 class="grid_12">{% trans 'No Hanchan has been added to this event yet.'%}</h3>
{% endfor %}
{% 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 %}