digitalfabrik/integreat-cms

View on GitHub
integreat_cms/cms/templates/events/event_form.html

Summary

Maintainability
Test Coverage
{% extends "_base.html" %}
{% load i18n %}
{% load static %}
{% load widget_tweaks %}
{% load content_filters %}
{% load poi_filters %}
{% load rules %}
{% load render_bundle from webpack_loader %}
{% block content %}
    <form id="content_form"
          method="post"
          enctype="multipart/form-data"
          data-unsaved-warning
          {% if event_form.disabled %}data-disable-poi-query{% endif %}>
        {% csrf_token %}
        {% get_current_language as LANGUAGE_CODE %}
        {% get_language LANGUAGE_CODE as current_language %}
        <div class="flex flex-wrap justify-between gap-4 mb-4">
            <h1 class="heading overflow-hidden text-ellipsis">
                {% if event_form.instance.id %}
                    {% if event_translation_form.instance.id %}
                        {% with event_translation_form.instance.title as event_title %}
                            {% blocktranslate trimmed %}
                                Edit event "{{ event_title }}"
                            {% endblocktranslate %}
                        {% endwith %}
                        {% if LANGUAGE_CODE != language.slug %}
                            {% if event_form.instance.backend_translation %}
                                ({% translate "Title in" %} {% translated_language_name LANGUAGE_CODE %}: "{{ event_form.instance.backend_translation.title }}")
                            {% endif %}
                        {% endif %}
                    {% else %}
                        {% translate "Create new event translation" %}
                    {% endif %}
                {% else %}
                    {% translate "Create new event" %}
                {% endif %}
            </h1>
            {% if not disabled %}
                <div class="flex flex-wrap gap-4 ml-auto mr-0 items-center">
                    {% include "generic_auto_save_note.html" with form_instance=event_form.instance %}
                    {% if perms.cms.publish_event %}
                        <button name="status"
                                value="{{ DRAFT }}"
                                class="btn btn-outline no-premature-submission">
                            {% translate "Save as draft" %}
                        </button>
                        <button name="status"
                                value="{{ PUBLIC }}"
                                class="btn no-premature-submission">
                            {% if event_translation_form.instance.status == PUBLIC %}
                                {% translate "Update" %}
                            {% else %}
                                {% translate "Publish" %}
                            {% endif %}
                        </button>
                    {% else %}
                        <button name="status"
                                value="{{ REVIEW }}"
                                class="btn no-premature-submission">
                            {% translate "Submit for approval" %}
                        </button>
                    {% endif %}
                </div>
            {% endif %}
        </div>
        <div class="3xl:grid grid-cols-2 3xl:grid-cols-[minmax(0px,_1fr)_400px] 4xl:grid-cols-[minmax(0px,_1fr)_816px] gap-4">
            <div class="col-span-2 3xl:col-span-1 flex flex-wrap flex-col">
                {% include "_form_language_tabs.html" with target="edit_event" instance=event_form.instance content_field="event_id" %}
                <div class="w-full rounded border border-blue-500 bg-white shadow-2xl flex flex-col">
                    <div class="w-full p-4 flex flex-col flex-auto">
                        <div class="flex justify-between">
                            <label for="{{ event_translation_form.title.id_for_label }}"
                                   data-slugify-url="{% url 'slugify_ajax' region_slug=request.region.slug language_slug=language.slug model_type='event' %}"
                                   {% if event_form.instance.id %}data-model-id="{{ event_form.instance.id }}"{% endif %}>
                                {{ event_translation_form.title.label }}
                            </label>
                            {% if event_translation_form.instance.id %}
                                <div class="grid grid-cols-2 text-left">
                                    <div class="font-bold pr-2">
                                        {% translate "Version" %}:
                                    </div>
                                    <div>
                                        {{ event_translation_form.instance.version }}
                                        (<a href="{% url 'event_versions' event_id=event_form.instance.id region_slug=request.region.slug language_slug=language.slug %}"
   class="text-blue-500 hover:underline">{% translate "Show" %}</a>)
                                    </div>
                                    <div class="font-bold pr-2">
                                        {% translate "Publication status" %}:
                                    </div>
                                    <div>
                                        {% if event.archived %}
                                            {% translate "Archived" %}
                                        {% else %}
                                            {{ event_translation_form.instance.get_status_display }}
                                        {% endif %}
                                    </div>
                                </div>
                            {% endif %}
                        </div>
                        {% render_field event_translation_form.title|add_error_class:"border-red-500" class+="mb-2" %}
                        <div id="link-container" class="flex items-center">
                            <label for="{{ event_translation_form.slug.id_for_label }}" class="mr-2">
                                {{ event_translation_form.slug.label }}:
                            </label>
                            <a id="slug-link"
                               href="{{ url_link }}{{ event_translation_form.instance.slug }}"
                               class="text-blue-500 hover:underline">{{ url_link }}{{ event_translation_form.instance.slug }}</a>
                            {% if perms.cms.change_event %}
                                <a id="edit-slug-btn"
                                   title="{% translate "Edit" %}"
                                   class="ml-2 btn-icon">
                                    <i icon-name="pen-line"></i>
                                </a>
                            {% endif %}
                            <a id="copy-slug-btn"
                               data-copy-to-clipboard="{{ event_translation_form.instance.base_link }}{{ event_translation_form.instance.slug }}"
                               title="{% translate "Copy to clipboard" %}"
                               class="ml-2 btn-icon">
                                <i icon-name="copy"></i>
                                <i icon-name="check" class="hidden text-green-500"></i>
                            </a>
                            <div class="slug-field hidden">
                                <label for="{{ event_translation_form.slug.id_for_label }}">
                                    {{ url_link }}
                                </label>
                                {% render_field event_translation_form.slug|add_error_class:"slug-error" %}
                            </div>
                            <a id="save-slug-btn" class="ml-2 btn-icon hidden">
                                <i icon-name="save"></i>
                            </a>
                            <a id="restore-slug-btn" class="ml-2 btn-icon hidden">
                                <i icon-name="x-circle"></i>
                            </a>
                        </div>
                        <label for="{{ event_translation_form.content.id_for_label }}">
                            {{ event_translation_form.content.label }}
                        </label>
                        {% render_field event_translation_form.content|add_error_class:"border-red-500" class+="tinymce_textarea flex-auto" %}
                    </div>
                </div>
            </div>
            <div class="md:flex mt-4 3xl:mt-0 block 3xl:block 4xl:flex">
                <div id="left-sidebar-column"
                     class="md:mr-4 md:w-full 3xl:mr-0 md:mt-0 sm:block md:flex sm:mt-4 flex-wrap flex-col 4xl:mr-4"
                     {% if request.user.distribute_sidebar_boxes %}data-enable-automatic-sidebar-distribution{% endif %}>
                    {% if event_form.instance.id and perms.cms.change_event %}
                        {% include "./event_form_sidebar/minor_edit_box.html" with box_id="event-minor-edit" %}
                    {% endif %}
                    {% include "./event_form_sidebar/date_and_time_box.html" with box_id="event-date-time" %}
                </div>
                <div id="right-sidebar-column"
                     class="md:w-full 3xl:col-end-3 4xl:col-end-auto flex flex-wrap flex-col">
                    {% include "../ajax_poi_form/poi_box.html" with form=event_form box_id="event-venue" title=_("Venue") %}
                    {% include "./event_form_sidebar/icon_box.html" with box_id="event-icon" %}
                    {% if event_form.instance.id and perms.cms.change_event %}
                        {% include "./event_form_sidebar/actions_box.html" with box_id="event-actions" %}
                    {% endif %}
                </div>
            </div>
        </div>
    </form>
    <form id="ajax_poi_form"
          name="ajax_poi_form"
          method="post"
          enctype="multipart/form-data"
          data-unsaved-warning>
    </form>
    {{ media_config_data|json_script:"media_config_data" }}
    {% if disabled %}
        {% include "../_tinymce_config.html" with readonly=1 %}
    {% else %}
        {% include "../_tinymce_config.html" %}
        {% if event_form.instance.id %}
            {% include "../_content_edit_lock.html" with lock_key=event_form.instance.edit_lock_key %}
        {% endif %}
    {% endif %}
    {% if event_form.instance.id %}
        {% include "../generic_confirmation_dialog.html" %}
    {% endif %}
{% endblock content %}
{% block javascript %}
    {% render_bundle 'editor' 'js' %}
{% endblock javascript %}