{% extends "base.html" %}
{% load i18n template_tools %}

{% block head %}
    {{ block.super }}
    <link rel="stylesheet" href="{{ STATIC_URL }}trainings/css/django-admin-widgets.css" type="text/css" media="screen" charset="utf-8" />

    <script type="text/javascript" src="{{ STATIC_URL }}common/js/ajax-modal.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}trainings/js/django-admin.multiselect.js"></script>
    <script type="text/javascript">
        $(function(){
            jQuery.each($("select[multiple]"), function () {
                SelectFilter.init(this.id, "{% trans 'Trainer groups' %}", 0, "/static/admin/");
            });
        });
    </script>
{% endblock %}

{% block subtitle %}
    {% if training.pk %}
        {% trans 'Training:' %} {{ training.name }}
        <span class="label label-default" style="display:inline-block">
            <i class="fa fa-{% nospaces %}
                {% if training.version_state == training.VERSION_STATES.DRAFT %}pencil{% endif %}
                {% if training.version_state == training.VERSION_STATES.PUBLISHED %}paper-plane{% endif %}
                {% if training.version_state == training.VERSION_STATES.ARCHIVED %}archive{% endif %}
            {% endnospaces %}"></i>
            {{ training.get_version_state_display }}
        </span>
        {% include 'trainings/training_actions.html' %}
    {% else %}
        {% trans 'New training' %}
    {% endif %}
{% endblock %}

{% block actions %}
    <a class="btn btn-default" href="{% url 'trainings:training-list' %}">{% trans 'Back to the list of trainings' %}</a>
    {% if user.is_trainer and user_can_have_survey %}
        <a class="btn btn-primary" href="{{ training.get_survey_url }}">{% trans 'Survey' %}</a>
    {% endif %}
{% endblock %}

{% block main %}
    {% if training.pk and not training.is_editable %}
        <div class="alert alert-info">
            <i class="fa fa-lock"></i>
            {% blocktrans with training_name=training.name training_version_state=training.get_version_state_display %}
                The training "{{ training_name }}" is "{{ training_version_state }}". Therefore, edition is not allowed anymore. In order to bring changes to it, you need to create a new draft with the button above.
            {% endblocktrans %}
        </div>
    {% endif %}
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="{% if current_sub_section == 'general_informations' %}active{% endif %}">
            <a href="{{ training.get_edit_url }}">
                <h5>{% trans 'General informations' %}</h5>
            </a>
        </li>
        {% if training.pk %}
            <li role="presentation" class="{% if current_sub_section == 'activities' %}active{% endif %}">
                <a href="{{ training.get_activity_list_url }}">
                    <h5>{% trans 'Course content' %}</h5>
                </a>
            </li>
        {% endif %}
    </ul>
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active">
            {% block section_heading %}{% endblock %}
            {% block section_content %}{% endblock %}
        </div>
    </div>
{% endblock %}
