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

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

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

{% block submission_content %}
    <span id="vars" remoteUrl="{{ request.event.organiser.orga_urls.user_search }}"></span>

    {% has_perm "mail.send_queuedmail" request.user request.event as can_send_mails %}
    {% has_perm "submission.list_all_review" request.user request.event as can_view_all_reviews %}
    <form method="post" enctype="multipart/form-data">
        <fieldset>
            {% if not submission %}
                <legend>{% translate "Create proposal" %}</legend>
            {% endif %}

            {% if submission.access_code %}
                <div class="alert alert-info"><span></span><span>
                    {% blocktranslate trimmed %}
                        This proposal was created using an access code:
                    {% endblocktranslate %} <a href="{{ submission.access_code.urls.edit }}">{{ submission.access_code.code }}</a>
                </span></div>
            {% endif %}
            {% include "common/forms/errors.html" %}
            {% csrf_token %}

            {{ form.title.as_field_group }}

            {% if permission_action == "create" %}
                {{ form.state.as_field_group }}
                </fieldset>
                <fieldset>
                    <legend id="speaker">{% translate "Speaker" %}</legend>
                    {{ new_speaker_form }}
                </fieldset>
                <fieldset>
                    <legend id="proposal">{% translate "Proposal" %}</legend>
            {% endif %}
            {% if form.room %}
                <div id="show-if-state" {% if permission_action == "create" %}class="d-none"{% endif %}>
                    {{ form.room.as_field_group }}
                    {{ form.start.as_field_group }}
                    {{ form.end.as_field_group }}
                </div>
            {% endif %}
            {% if form.instance.median_score != None and can_view_all_reviews %}
                <div class="form-group row">
                    <label class="col-md-3 col-form-label">
                        {% translate "Reviews" %}
                    </label>
                    <div class="col-md-9">
                        <div class="pt-2">
                            {{ submission.reviews.count }} {% translate "reviews" %}
                        </div>
                    </div>
                </div>
            {% endif %}
            {{ form.submission_type.as_field_group }}
            {% if form.track %}{{ form.track.as_field_group }}{% endif %}
            {% if form.tags %}{{ form.tags.as_field_group }}{% endif %}
            {% if form.abstract %}{{ form.abstract.as_field_group }}{% endif %}
            {% if form.description %}{{ form.description.as_field_group }}{% endif %}
            {% if form.notes %}{{ form.notes.as_field_group }}{% endif %}
            {{ form.internal_notes.as_field_group }}
            {% if form.content_locale %}{{ form.content_locale.as_field_group }}{% endif %}
            {% if form.do_not_record %}{{ form.do_not_record.as_field_group }}{% endif %}
            {{ form.is_featured.as_field_group }}
            {{ form.duration.as_field_group }}
            {% if form.slot_count %}{{ form.slot_count.as_field_group }}{% endif %}
            {% if form.image %}{{ form.image.as_field_group }}{% endif %}
            {% if permission_action != "create" %}
                {% include "cfp/includes/submission_resources_form.html" %}
            {% endif %}
            {% if questions_form and questions_form.fields %}
                <div><legend id="custom">{{ phrases.cfp.custom_fields }}</legend></div>
                {{ questions_form }}
            {% endif %}
            {% for extra_form in extra_forms %}
                <fieldset>
                    {% if extra_form.label %}<legend>{{ extra_form.label }}</legend>{% endif %}
                    {{ extra_form }}
                </fieldset>
            {% endfor %}

            {% if not form.read_only %}
                {% include "orga/includes/submit_row.html" %}
            {% endif %}
        </fieldset></form>
{% endblock submission_content %}
