{% extends "tournamentcontrol/competition/base.html" %}
{% load i18n humanize %}
{% load common competition %}

{% block content %}
	{% trans "TBA" as tba context "abbreviation: to be advised" %}
	{% trans "TBC" as tbc context "abbreviation: to be confirmed" %}

	<table class="draw">
		<tbody>
			{% for match in object_list %}
				<tr class="{% if forloop.first %}first {% endif %}{% cycle "odd" "even" %}{% if forloop.last %} last{% endif %}{% ifchanged match.round %} group{% endifchanged %}">
					<td>{{ match.stage.division.title }}</td>

					<td class="label">
						{% if match.label %}
							{% trans match.label %}
						{% elif not match.is_final %}
							{% blocktrans with num=match.round %}Round {{ num }}{% endblocktrans %}
						{% endif %}
					</td>

					<td class="time">{{ match.datetime|date:"G:i"|default:tba }}</td>
					<td class="field">{{ match.play_at.title|default:tba }}</td>

					<td class="team right {{ match.home_team.club.slug|cssify }}">
						{% if match.home_team %}
							{% url application.name|add:":team" competition=competition.slug season=season.slug division=match.stage.division.slug team=match.home_team.slug as url1 %}
							{% url application.name|add:":team" season=season.slug division=match.stage.division.slug team=match.home_team.slug as url2 %}
							{% url application.name|add:":team" division=match.stage.division.slug team=match.home_team.slug as url3 %}
							<a href="{{ url1|default:url2|default:url3 }}">{% trans match.home_team.title %}</a>
						{% else %}
							{% trans match.get_home_team.title %}
						{% endif %}
					</td>

					<td class="score center">{{ match.home_team_score|default_if_none:"-" }}</td>
					<td class="versus center">{% trans "vs" context "abbreviation: versus" %}</td>
					<td class="score center">{{ match.away_team_score|default_if_none:"-" }}</td>

					<td class="team {{ match.away_team.club.slug|cssify }}">
						{% if match.away_team %}
							{% url application.name|add:":team" competition=competition.slug season=season.slug division=match.stage.division.slug team=match.away_team.slug as url1 %}
							{% url application.name|add:":team" season=season.slug division=match.stage.division.slug team=match.away_team.slug as url2 %}
							{% url application.name|add:":team" division=match.stage.division.slug team=match.away_team.slug as url3 %}
							<a href="{{ url1|default:url2|default:url3 }}">{% trans match.away_team.title %}</a>
						{% else %}
							{% trans match.get_away_team.title %}
						{% endif %}
					</td>

					<td class="report{% if not match.statistics_count %} none{% endif %}">
						{% if match.statistics_count %}
							{% url application.name|add:":match" competition=competition.slug season=season.slug division=match.stage.division.slug match=match.pk as url1 %}
							{% url application.name|add:":match" season=season.slug division=match.stage.division.slug match=match.pk as url2 %}
							{% url application.name|add:":match" division=match.stage.division.slug match=match.pk as url3 %}
							<a href="{{ url1|default:url2|default:url3 }}">{% trans "Detail" %}</a>
						{% endif %}
					</td>
				</tr>
			{% endfor %}
		</tbody>
	</table>
{% endblock %}
