{% extends "nexus/admin/base_site.html" %}

{% load i18n admin_modify adminmedia %}
{% load nexus_admin %}

{% block head %}
    {{ block.super }}
    {% url admin:jsi18n as jsi18nurl %}
    <script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
    <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/widgets.css" />
    {{ media }}
{% endblock %}

{% if not is_popup %}
    {% block breadcrumb_bits %}
        <li><a href="../../../">{% trans "Model Admin" %}</a></li>
        <li><a href="../../">{{ app_label|capfirst|escape }}</a></li>
        <li>
            {% if has_change_permission %}
                <a href="../">{{ opts.verbose_name_plural|capfirst }}</a>
            {% else %}
                <span>{{ opts.verbose_name_plural|capfirst }}</span>
            {% endif %}
        </li>
        <li>
            {% if add %}
                <span>{% trans "Add" %} {{ opts.verbose_name }}</span>
            {% else %}
                <span>{{ original|truncatewords:"18" }}</span>
            {% endif %}
        </li>
    {% endblock %}
{% endif %}

{% block content %}
    {% block object-tools %}
    {% if change and not is_popup %}
        <ul class="object-tools">
            <li><a href="history/" class="button small historylink">{% trans "History" %}</a></li>
            {% if has_absolute_url %}
                <li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="button small viewsitelink">{% trans "View on site" %}</a></li>
            {% endif%}
        </ul>
    {% endif %}
    {% endblock %}
    <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
    <div>
    {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
    {% if save_on_top %}{% submit_row %}{% endif %}
    {% if errors %}
        <p class="errornote">
        {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
        </p>
        {{ adminform.form.non_field_errors }}
    {% endif %}

    {% for fieldset in adminform %}
      {% include "admin/includes/fieldset.html" %}
    {% endfor %}

    {% block after_field_sets %}{% endblock %}

    {% for inline_admin_formset in inline_admin_formsets %}
        {% include inline_admin_formset.opts.template %}
    {% endfor %}

    {% block after_related_objects %}{% endblock %}

    {% submit_row %}

    {% if adminform and add %}
       <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
    {% endif %}

    {# JavaScript for prepopulated fields #}
    {% prepopulated_fields_js %}

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