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

{% extends "cfp/event/base.html" %}

{% load event_tags %}
{% load i18n %}
{% load orga_edit_link %}
{% load rich_text %}
{% load rules %}

{% block content %}
    {% with cfp=request.event.cfp %}
        {% has_perm "submission.list_featured_submission" request.user request.event as can_view_featured_submissions %}
        {% has_perm "event.update_event" request.user request.event as can_edit_cfp %}
        <div class="d-flex align-items-start">
            <h1>{{ cfp.headline|default:"" }}</h1>
            {% if can_edit_cfp %}
                {% orga_edit_link request.event.cfp.urls.text %}
            {% endif %}
        </div>
        {{ cfp.text|rich_text }}
        {% if request.event.cfp.settings.show_deadline %}
            <p>
                <strong>
                    {% if cfp.is_open and request.event.cfp.max_deadline %}
                        {% blocktranslate with deadline=cfp.max_deadline|date:"SHORT_DATETIME_FORMAT" timezone=request.timezone until_string=cfp.max_deadline|timeuntil trimmed %}
                            Submissions close on {{ deadline }} ({{ timezone }}), {{ until_string }} from now.
                        {% endblocktranslate %}
                    {% else %}
                        {% if cfp.before_opening %}
                            {% blocktranslate with opening=cfp.opening|date:"SHORT_DATETIME_FORMAT" timezone=request.timezone trimmed %}
                                Submissions open on {{ opening }} ({{ timezone }}).
                            {% endblocktranslate %}
                        {% elif cfp.after_deadline %}
                            {% blocktranslate with deadline=cfp.max_deadline|date:"SHORT_DATETIME_FORMAT" timezone=request.timezone trimmed %}
                                Submissions closed on {{ deadline }} ({{ timezone }}).
                            {% endblocktranslate %}
                        {% endif %}
                    {% endif %}
                </strong>
            </p>
        {% endif %}
        <div class="url-links">
            {% if request.event.current_schedule and request.event|get_feature_flag:"show_schedule" %}
                <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.schedule }}">
                    {{ phrases.agenda.view_schedule }}
                </a>
            {% elif can_view_featured_submissions and has_featured %}
                <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.featured }}">
                    {{ phrases.agenda.view_schedule_preview }}
                </a>
            {% endif %}
            {% if has_submissions or request.user.is_anonymous %}
                <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.user_submissions }}">
                    {{ phrases.agenda.view_own_submissions }}
                </a>
            {% endif %}
            <a class="btn btn-success btn-lg btn-block {% if not cfp.is_open and not access_code.is_valid %}disabled{% endif %}"
               href="{{ request.event.urls.submit }}{{ submit_qs }}">
                {% if cfp.is_open or access_code.is_valid %}
                    {% translate "Submit a proposal" %}
                {% else %}
                    {% translate "Proposals are closed" %}
                {% endif %}
            </a>
        </div>
    {% endwith %}
{% endblock content %}
