{% load tournament_tags %}
{% with status=tournament.get_online_registration_status %}
    <a href="{% url 'tournament' tournament.id %}">
        <div class="table-row-5-colums-tournament vertical-padding">
            <div class="table-row-element tournament-date center">
                <div class="small">{{ tournament.week_day }}</div>
                <div class="very-large">{{ tournament.day }}</div>
                <div class="small">{{ tournament.month }}</div>
            </div>
            <div class="table-row-element tournament-type">
                <div class="very-large">{{ tournament.short_level }}</div>
                {% if tournament.category %}
                <div class="small">{{ tournament.category }}</div>
                {% endif %}
                {% if tournament.age %}
                <div class="small">{{ tournament.age }}</div>
                {% endif %}
            </div>
            <div class="table-row-element tournament-name">
                <div class="very-large club-name">{{ tournament.event.club.name }}</div>
                {% if tournament.event.name %}
                    <div class="small event-name">{{ tournament.event.name }}</div>
                {% endif %}
                {% if tournament.name %}
                    <div class="small event-name">{{ tournament.name }}</div>
                {% endif %}
                {% if tournament.has_started or tournament.has_ended %}
                    <div class="small">{{ tournament.localized_day_duration }}</div>
                {% else %}
                    <div class="small">{{ tournament.localized_start_time }} | {{ tournament.localized_day_duration }}</div>
                {% endif %}
            </div>
            <div class="table-row-element tournament-status center">
                {% if user.is_authenticated %}
                {% with user_registration_status=tournament|get_player_status:user %}
                    {% if user_registration_status %}
                        <div class="small">{{ user_registration_status.header }}</div>
                        <div class="very-large">{{ user_registration_status.position }}</div>
                        {% if user_registration_status.display_box %}
                            <div class="box small {{ user_registration_status.box_class }}">
                                {{ user_registration_status.short_label }}
                            </div>
                        {% endif %}
                    {% else %}
                        <div class="small">Équipes</div>
                        <div class="very-large">{{ tournament.get_tournament_status_team_count }}</div>
                        {% if status.display_box %}
                            <div class="box small {{ status.box_class }}">
                                {{ status.short_label }}
                            </div>
                        {% endif %}
                    {% endif %}
                {% endwith %}
                {% else %}
                    <div class="small">Équipes</div>
                    <div class="very-large">{{ tournament.get_tournament_status_team_count }}</div>
                    {% if status.display_box %}
                    <div class="box small {{ status.box_class }}">
                        {{ status.short_label }}
                    </div>
                    {% endif %}
                {% endif %}

            </div>
        </div>
    </a>
    {% if not forloop.last %}
    <hr/>
    {% endif %}
{% endwith %}
