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

{% 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 %}
    <a class="grid_1" href="{% url 'player-ladder-score' player.user %}"><img
            src="{% if player.user.avatar %}{{player.user.thumbnail.url}}{% else %}{{STATIC_URL}}img/unknown_thumbnail.png{% endif %}"
            class="avatar" alt="{{ player.user }}" title="{{ player.user }}"/></a>
    <div class="grid_2">
        <p><a class="player" href="{% url 'player-ladder-score' player.user %}" title="{{ player.comment }}">{{ player.user }}</a></p>
        <p><strong>{{ player.placement|ordinal }} {% trans 'Place' %}</strong><br />
            <strong>{% trans 'Score' %}:</strong> {{ player.game_score|intcomma }}<br />
            {% if player.dan_points != None %}
            <strong>{% trans 'Dan Points' %}:</strong> {{ player.dan_points }}
            {% else %}
            <strong>{% trans 'Kyu Points' %}:</strong> {{ player.kyu_points|default:0 }}
            {% endif %}
        </p>
    </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 %}