{% extends "orga/cfp/base.html" %}
{% load bootstrap4 %}
{% load compress %}
{% load i18n %}
{% load static %}

{% block scripts %}
    {% compress js %}
        <script defer src="{% static "vendored/moment-with-locales.js" %}"></script>
        <script defer src="{% static "vendored/moment-timezone-with-data-2012-2022.js" %}"></script>
        <script defer src="{% static "vendored/datetimepicker/bootstrap-datetimepicker.js" %}"></script>
        <script defer src="{% static "orga/js/datetimepicker.js" %}"></script>
    {% endcompress %}
{% endblock %}

{% block cfp_content %}
    <h2>
        {% if form.instance.pk %}
            {% translate "Edit access code" %}
        {% else %}
            {% translate "New access code" %}
        {% endif %}
    </h2>
    {% if form.instance.submissions.exists %}
        <div class="alert alert-info">
            <span>
                {% blocktranslate trimmed %}
                    This access code has already been used. You can't delete it, but you can disable it by setting an expiration date.
                {% endblocktranslate %}
                <ul>
                    {% for submission in form.instance.submissions.all %}
                        <li><a href="{{ submission.orga_urls.base }}">{{ submission.title }} ({{submission.display_speaker_names}})</a></li>
                    {% endfor %}
                </ul>
            </span>
        </div>
    {% endif %}
    <form method="post">
        {% csrf_token %}
        {% bootstrap_form_errors form %}
        {% bootstrap_form form layout='event' %}
        <div class="submit-group panel">
            <span>
                {% if form.instance.pk and not form.instance.submissions.exists %}
                    <a class="btn btn-outline-danger btn-lg" href="{{ form.instance.urls.delete }}">
                        <i class="fa fa-trash"></i> {% translate "Delete" %}
                    </a>
                {% endif %}
            </span>
            <span>
                <button type="submit" class="btn btn-success btn-lg">
                    <i class="fa fa-check"></i>
                    {% translate "Save" %}
                </button>
            </span>
        </div>
    </form>

{% endblock %}

