<!--
SPDX-FileCopyrightText: 2018-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms
-->

{% extends "orga/schedule/base.html" %}

{% load i18n %}
{% load static %}

{% block extra_title %}{% translate "Release new schedule" %} :: {% endblock extra_title %}

{% block stylesheets %}
    <link rel="stylesheet" href="{% static "orga/css/ui/release.css" %}" />
{% endblock %}

{% block schedule_content %}
    <form method="post">
        {% include "common/forms/errors.html" %}
        {% csrf_token %}
        <h2>
            {% translate "Release new schedule" %}
        </h2>
        <div class="mb-3">
            {{ form.version.as_field_group }}
        </div>
        {% if warnings.unconfirmed or warnings.unscheduled or warnings.no_track or warnings.talk_warnings %}
            <div class="alert alert-warning">
                <span></span><span>
                    {% blocktranslate trimmed %}
                        There are still warnings about the release of this schedule. Please review them carefully!
                    {% endblocktranslate %}
                </span>
            </div>
        {% endif %}

        <ul>
            <li>
                {% if request.event.wip_schedule.previous_schedule.version %}
                    {% blocktranslate with prev=request.event.wip_schedule.previous_schedule.version since=request.event.wip_schedule.previous_schedule.published|timesince trimmed %}
                        The previous schedule ({{ prev }}) was released {{ since }} ago.
                    {% endblocktranslate %}
                {% else %}
                    {% translate "This will be the very first schedule release." %}
                {% endif %}
            </li>
            <li>
                {% if notifications %}
                    {% blocktranslate trimmed count count=notifications %}
                        When releasing this new schedule, <strong>one notifications email
                        </strong> can be generated and placed in the outbox, to tell speakers about their
                        session slots.
                    {% plural %}
                        When releasing this new schedule, <strong>{{ count }} notifications emails
                        </strong> can be generated and placed in the outbox, to tell speakers about their
                        session slots.
                    {% endblocktranslate %}
                    <br>
                    {% translate "Email template" %}: <a href="{{ notification_template.urls.base }}">{% translate "New schedule version" %}</a>
                {% else %}
                    {% blocktranslate trimmed %}
                        This schedule release would result in <strong>no notification emails</strong> for
                        speakers.
                    {% endblocktranslate %}
                {% endif %}
            </li>
            {% if warnings.unconfirmed %}
                <li>{% blocktranslate trimmed count count=warnings.unconfirmed %}
                    One session is still <strong>unconfirmed</strong> and will not show up
                    on the public schedule.
                {% plural %}
                    {{ count }} sessions are still <strong>unconfirmed</strong> and will not show up
                    on the public schedule.
                {% endblocktranslate %} <a href="{{ request.event.orga_urls.submissions }}?state=accepted&state=pending_state__accepted&state=pending_state__confirmed">{% translate "See all unconfirmed sessions." %}</a></li>
            {% endif %}
            {% if warnings.unscheduled %}
                <li>{% blocktranslate trimmed count count=warnings.unscheduled %}
                    One session has <strong>not yet been scheduled</strong>.
                {% plural %}
                    {{ count }} sessions have <strong>not yet been scheduled</strong>.
                {% endblocktranslate %}</li>
            {% endif %}
            {% if warnings.no_track %}
                <li>{% blocktranslate trimmed count count=warnings.no_track|length %}
                    One session has <strong>not yet been assigned a track</strong>.
                {% plural %}
                    {{ count }} sessions have <strong>not yet been assigned a track</strong>.
                {% endblocktranslate %}
                    <ul>
                        {% for talk in warnings.no_track %}
                            <li><a href="{{ talk.submission.orga_url }}">{{ quotation_open }}{{ talk.submission.title }}{{ quotation_close }}</a></li>
                        {% endfor %}
                    </ul>
                </li>
            {% endif %}
        </ul>
        {% if warnings.talk_warnings %}
            <details>
                <summary class="pb-1">
                    <h4 class="d-inline-flex">{{ warnings.talk_warnings|length }} {% translate "Warnings" %}</h4>
                    <hr class="ml-3 mr-3 mt-0 mr-0">
                </summary>
                <ul>
                    {% for talk in warnings.talk_warnings %}
                        {% for warning in talk.warnings %}
                            <li><a href="{{ warning.url }}">{{ quotation_open }}{{ talk.talk.submission.title }}{{ quotation_close }}</a>: {{ warning.message }}</li>
                        {% endfor %}
                    {% endfor %}
                </ul>
            </details>

        {% endif %}

        <details open>
            <summary class="pb-3">
                <div class="d-inline-flex flex-column">
                    <h4>{% translate "Public changelog" %}</h4>
                    {% translate "This is how the new schedule version will appear in the public changelog and in the RSS feed." %}
                    {% translate "You can include a comment here." %}
                </div>
                <hr class="ml-3 mr-3 mt-0 mr-0">
            </summary>

            <div id="fake-changelog">
                <h4>
                    {{ phrases.schedule.version }}  {{ suggested_version }}
                </h4>
                <div class="flex-next-column">
                    {{ form.comment.as_field_group }}
                </div>
                {% include "agenda/changelog_block.html" with schedule=request.event.wip_schedule %}
            </div>
        </details>

        <div id="release">
            {% include "orga/includes/submit_row.html" with extra_content_right=form.notify_speakers.as_field_group %}
        </div>
    </form>

{% endblock schedule_content %}
