{% extends "chimere/base.html" %}
{% load i18n adminmedia chimere_tags inline_formset %}
{% block extra_head %}
    {{ form.media }}
    {{ block.super }}
    {% head_chimere %}
    {% if dated %}
        <!--script type="text/javascript" src="{{extra_url}}media/js/core.js"></script-->
        <script type="text/javascript" src="{{ STATIC_URL }}chimere/js/utils.js"></script>
        <script type="text/javascript">
        window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
        </script>
    {% endif %}
{% endblock %}

{% block content %}
    {{ block.super }}
    {% if submited %}{% submited %}{% endif %}
    {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
    {% if is_modification and is_superuser %}<div class='warning'><p>{% trans "You are logged as an administrator. Your modifications will be taking into account immediately." %}</p></div>{% endif %}
    <fieldset class='edit'>
    <legend>{% if is_modification %}{% trans "Modify a route" %}{% else %}{% trans "Add a route" %}{% endif %}</legend>
    <form enctype="multipart/form-data" method='post' action='.'>
    {% csrf_token %}
    <div class='rightWrapper'>
        <div class='rightform'>
            <div class="fieldWrapper">
                <label for="id_route">{% trans "Route"%} *</label>
                {%if form.point.errors %}<ul class="errorlist"><li>{% trans "Select a location for this new site" %}</li></ul>{%endif%}
                {{route_widget}}
            </div>
        </div>
    </div>
    <div class='leftform'>
        <p>* {% trans "indicates a mandatory field" %}</p>
        <div class="fieldWrapper">
            <label for="id_name">{% trans "Name"%} *</label>
            {{ form.name.errors }}
            {{ form.name }}
        </div>
        <div class="fieldWrapper">
            <label for="id_subcategory">{% trans "Categories" %} *</label>
            {{ form.categories.errors }}
            {{ form.categories }}
        </div>
        <div class="fieldWrapper">
            <label for="id_description">{% trans "Description" %} *</label>
            {{ form.description.errors }}
            {{ form.description }}
        </div>
        {% if dated %}
        <div class="fieldWrapper">
            <label for="id_start_date">{% trans "Start date" %}</label>
            {{ form.start_date.errors }}
            {{ form.start_date }}
            <p class="help">{{ form.start_date.help_text }}</p>
        </div>
        <div class="fieldWrapper">
            <label for="id_end_date">{% trans "End date" %}</label>
            {{ form.end_date.errors }}
            {{ form.end_date }}
            <p class="help">{{ form.end_date.help_text }}</p>
        </div>
        {% endif %}
    </div>
    <div class='bottomform'>
        {%for field in form%}{%for property in properties%}{%ifequal field.name property%}
        <div class="fieldWrapper">
            <label for="id_{{field.name}}">{% trans field.label %}</label>
            {{ field.errors }}
            {{ field }}
        </div>
        {%endifequal%}{%endfor%}{%endfor%}

        {% inline_formset "Multimedia files" formset_multi %}
        {% inline_formset "Picture files" formset_picture %}

        <p><input type='submit' onclick='saveExtent();' value="{% trans 'Propose'%}"/></p>
    </div>
    </form>
    </fieldset>
    </div>
{% endblock %}
