{% extends 'tournaments/base.html' %}

{% block head_title %}Matchs du {{ tournament.display_name }}{% endblock %}
{% block first_title %}{{ tournament.event.display_name }}{% endblock %}
{% block second_title %}{{ tournament.display_name }}{% endblock %}

{% block content %}

    {% if tournament.display_matches %}
        {% include 'tournaments/navigation_tournament.html' %}

        {% if tournament.display_matches or tournament.display_group_stages %}

            {% regroup match_groups.matches by start_date|date:"l d F Y" as matches_by_date %}

            {% for date in matches_by_date %}

                {% regroup date.list by start_date|date:"H:i" as matches_by_hour %}

                {% for hour_group in matches_by_hour %}
                <h1 class="club my-block topmargin20">{{ date.grouper }} {{ hour_group.grouper }}</h1>

                    {% regroup hour_group.list by court_index as matches_by_court %}

                    <div class="grid-x">
                        {% for court in matches_by_court|dictsort:"grouper" %}
                            {% for match_data in court.list %}
                                {% with match=match_data.match %}
                                    {% include 'tournaments/match_cell.html' %}
                                {% endwith %}
                            {% endfor %}
                        {% endfor %}
                    </div>
                {% endfor %}
            {% endfor %}


        {% endif %}
    {% endif %}
{% endblock %}
