{% extends 'cradmin_legacy/viewhelpers/listbuilder/itemvalue/edit-delete.django.html' %}

{% load i18n %}
{% load cradmin_legacy_tags %}
{% load devilry_core_tags %}

{% block title %}
    <div class="devilry-heading-with-buttons">
        <h2 class="devilry-heading-with-buttons__heading devilry-admin-period-tags-listbuilder-itemvalue-title">
            {% if me.value.prefix == '' %}
                {{ me.get_title }}
            {% else %}
                {{ me.get_title }} (imported)
            {% endif %}
        </h2>
        {% if me.value.prefix == '' %}
            <div class="devilry-heading-with-buttons__buttons">
                {% block editbutton %} {{ block.super }} {% endblock %}
                {% block deletebutton %} {{ block.super }} {% endblock %}
            </div>
        {% else %}
            <div class="devilry-heading-with-buttons__buttons">
                {% if me.value.is_hidden == True %}
                    <a href="{% cradmin_instance_url appname='manage_tags' viewname='toggle_visibility' %}?tag_id={{ me.value.id }}"
                       class="btn btn-default btn-sm devilry-admin-manage-tags-imported-tag-show-button">
                        {% trans 'Show' %}
                    </a>
                {% else %}
                    <a href="{% cradmin_instance_url appname='manage_tags' viewname='toggle_visibility'%}?tag_id={{ me.value.id }}"
                        class="btn btn-default btn-sm devilry-admin-manage-tags-imported-tag-hide-button">
                        {% trans 'Hide' %}
                    </a>
                {% endif %}
            </div>
        {% endif %}
    </div>
{% endblock title %}

{% block description %}
    <p class="text-muted">
        {% devilry_relatedusers_on_period_tag me.value %}
    </p>
{% endblock %}

{% block end-of-content %}
    {% if me.value.prefix == '' %}
        <div class="devilry-dashboard-container-withtopmargin">
            <p class="paragraph paragraph--nomargin">
                <a href="{% cradmin_instance_url appname='manage_tags' viewname='add_students' tag_id=me.value.id %}"
                        id="devilry_admin_period_manage_tags_add_students_{{ me.value.tag }}"
                        class="btn btn--fixedwidth btn--fixedwidth-wide btn-default btn-sm">
                    {% trans 'Add students' %}
                </a>
                <a href="{% cradmin_instance_url appname='manage_tags' viewname='add_examiners' tag_id=me.value.id %}"
                        id="devilry_admin_period_manage_tags_add_examiners_{{ me.value.tag }}"
                        class="btn btn--fixedwidth btn--fixedwidth-wide btn-default btn-sm">
                    {% trans 'Add examiners' %}
                </a>
            </p>
            <p class="paragraph paragraph--nomargin">
                {% if me.value.relatedstudents.count > 0 %}
                    <a href="{% cradmin_instance_url appname='manage_tags' viewname='remove_students' tag_id=me.value.id %}"
                            id="devilry_admin_period_manage_tags_remove_students_{{ me.value.tag }}"
                            class="btn btn--fixedwidth btn--fixedwidth-wide btn--danger-muted btn-sm">
                        {% trans 'Remove students' %}
                    </a>
                {% endif %}
                {% if me.value.relatedexaminers.count > 0 %}
                    <a href="{% cradmin_instance_url appname='manage_tags' viewname='remove_examiners' tag_id=me.value.id %}"
                            id="devilry_admin_period_manage_tags_remove_examiners_{{ me.value.tag }}"
                            class="btn btn--fixedwidth btn--fixedwidth-wide btn--danger-muted btn-sm">
                        {% trans 'Remove examiners' %}
                    </a>
                {% endif %}
            </p>
        </div>
    {% elif me.value.is_hidden %}
        <em class="text-warning">
            {% trans "Hidden tag - not visible anywhere except in this list." %}
        </em>
    {% endif %}
{% endblock end-of-content %}
