{% extends "base.html" %}

{% load i18n %}

{% block content %}
{% trans "any" as any %}
    <div class="card bg-body shadow">
        <div class="card-header text-center">
            <h4>{% trans "Participation of team" %} {{ participation.team.name }} ({{ participation.team.trigram }})</h4>
        </div>
        <div class="card-body">
            <dl class="row">
                <dt class="col-sm-2">{% trans "Team:" %}</dt>
                <dd class="col-sm-10"><a href="{% url "participation:team_detail" pk=participation.team.pk %}">{{ participation.team }}</a></dd>

                <dt class="col-sm-2">{% trans "Tournament:" %}</dt>
                <dd class="col-sm-10">
                    {% if participation.tournament %}
                        <a href="{% url "participation:tournament_detail" pk=participation.tournament.pk %}">{{ participation.tournament }}</a>
                    {% else %}
                        {% trans "any" %}
                    {% endif %}
                </dd>

                <dt class="col-sm-2">{% trans "Solutions:" %}</dt>
                <dd class="col-sm-10">
                    <ul>
                        {% for solution in participation.solutions.all %}
                            <li><a href="{{ solution.file.url }}">{{ solution }}</a></li>
                        {% empty %}
                            <li>{% trans "No solution was uploaded yet." %}</li>
                        {% endfor %}
                        <li>
                            <a href="{% url "participation:participation_solutions" team_id=participation.team_id %}"
                               class="btn btn-sm btn-info">
                                <i class="fas fa-archive"></i> {% trans "Download as ZIP" %}
                            </a>
                        </li>
                    </ul>
                </dd>

                {% if participation.pools.all %}
                    <dt class="col-sm-2">{% trans "Pools:" %}</dt>
                    <dd class="col-sm-10">
                        <ul>
                            {% for pool in participation.pools.all %}
                                <li><a href="{{ pool.get_absolute_url }}">{{ pool }}{% if not forloop.last %}, {% endif %}</a></li>
                            {% endfor %}
                        </ul>
                    </dd>
                {% endif %}
            </dl>
        </div>
        <div class="card-footer text-center">
            {% if participation.final %}
                <div class="alert alert-info">
                    {% trans "If you upload a solution, this will replace the version for the final tournament." %}
                </div>
            {% endif %}
            <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#uploadSolutionModal">{% trans "Upload solution" %}</button>
        </div>
    </div>

    {% trans "Upload solution" as modal_title %}
    {% trans "Upload" as modal_button %}
    {% url "participation:upload_solution" pk=participation.pk as modal_action %}
    {% include "base_modal.html" with modal_id="uploadSolution" modal_enctype="multipart/form-data" %}
{% endblock %}

{% block extrajavascript %}
    <script>
        document.addEventListener('DOMContentLoaded', () => {
            initModal("uploadSolution", "{% url "participation:upload_solution" pk=participation.pk %}")
        })
    </script>
{% endblock %}
