{% extends "base.html" %}
{% load i18n %}
{% load bootstrap4 %}
{% load static %}

{% block title %}
    {% if event %}
        {% trans "Edit event" %}
    {% else %}
        {% trans "Create new event" %}
    {% endif %}
{% endblock %}

{% block content %}
    {% if inactive_events %}
        {% for event in inactive_events %}
            {% url "event_management:event_detail" event.pk as event_url %}
            {% trans "You have an unsaved event" as unsaved_message %}
            {% trans "View" as view_message %}
            {% bootstrap_alert unsaved_message|add:" ("|add:event.title|add:"). <a class='btn btn-light' href='"|add:event_url|add:"'>"|add:view_message|add:"</a>"|safe %}
        {% endfor %}
    {% endif %}
    <div class="page-header">
        {% if event %}
            <h1>{% trans "Edit event" %}</h1>
        {% else %}
            <h1>{% trans "Create new event" %}</h1>
        {% endif %}
    </div>
    <form method="post" class="form">
        {% csrf_token %}
        {% bootstrap_form form %}

        {% buttons %}
            {% if event %}
                <a role="button" class="btn btn-secondary" href="{% url "event_management:event_detail" event.pk%}">{% trans "Back" %}</a>
                <button type="submit" class="btn btn-primary float-right">{% trans "Save" %}</button>
            {% else %}
                <a role="button" class="btn btn-secondary" href="{% url "event_management:event_list" %}">{% trans "Cancel" %}</a>
                <button type="submit" class="btn btn-primary float-right">{% trans "Next" %}</button>
            {% endif %}

        {% endbuttons %}
    </form>
{% endblock %}
