{% extends "base.html" %}

{% load i18n %}

{% block  content %}
	<div class="card bg-body shadow">
        <div class="card-header text-center">
            <h5>{% trans "Ranking" %}</h5>
        </div>
        <div class="card-body">
            <table class="table table-striped text-center">
                <thead>
                    <tr>
                        <th>{% trans "Rank" %}</th>
                        <th>{% trans "team"|capfirst %}</th>
                        <th>{% trans "Note" %}</th>
                        <th>{% trans "Including bonus / malus" %}</th>
                        <th>{% trans "Add bonus / malus" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for participation, note in notes %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ participation.team }}</td>
                            <td>{{ note.note|floatformat }}</td>
                            <td>{% if note.tweak >= 0 %}+{% endif %}{{ note.tweak }}</td>
                            <td>
                                <div class="btn-group">
                                    <a href="{% url 'participation:tournament_harmonize_note' pk=tournament.pk round=round action="add" trigram=participation.team.trigram %}"
                                       class="btn btn-sm btn-success">
                                        +1
                                    </a>
                                    <a href="{% url 'participation:tournament_harmonize_note' pk=tournament.pk round=round action="remove" trigram=participation.team.trigram %}"
                                       class="btn btn-sm btn-danger">
                                        -1
                                    </a>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <div class="card-footer text-center">
            <a class="btn btn-secondary" href="{% url 'participation:tournament_detail' pk=tournament.pk %}">
                <i class="fas fa-arrow-left-long"></i>
                {% trans "Back to tournament page" %}
            </a>
        </div>
    </div>
{% endblock %}
