{% extends 'admin/base_site.html' %}

{% load i18n admin_urls static admin_list %}

{% block stylesheets %}
    {{ media.css }}

    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static 'adminlte2_admin/css/change_list.css' %}">
{% endblock %}

{% block javascripts %}
    {{ media.js }}

    {{ block.super }}
    {% if cl.formset or action_form %}
        <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
    {% endif %}
    <script type="text/javascript" src="{% static 'adminlte2_admin/js/change_list.js' %}"></script>
{% endblock javascripts %}

{% block body_class %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock body_class %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></li>
        <li><a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ cl.opts.app_config.verbose_name }}</a></li>
        <li>{{ cl.opts.verbose_name_plural|capfirst }}</li>
    {% endblock breadcrumbs %}
{% endif %}

{% block content %}

<div id="content-main" class="container-fluid">

    {% if cl.formset and cl.formset.errors %}
        <div class="alert alert-danger alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon fa fa-ban"></i> Alert!</h4>
            {% if cl.formset.total_error_count == 1 %}
                {% trans "Please correct the error below." %}
            {% else %}
                {% trans "Please correct the errors below." %}
            {% endif %}
            {{ cl.formset.non_form_errors }}
        </div>
    {% endif %}

    {# Search #}
    <div class="row">
        <div class="col-xs-12">
            {% block search %}{% search_form cl %}{% endblock %}
            {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %}
            <ul class="object-tools">
                {% block object-tools-items %}
                    {% change_list_object_tools %}
                {% endblock %}
            </ul>
        </div>
    </div>

    {# Main content #}
    <div id="changelist" class="row module{% if cl.has_filters %} filtered{% endif %}">

        {# Table #}
        <div class="{% if cl.has_filters %}col-sm-9 col-md-10 col-lg-10{% else %}col-xs-12{% endif %}">

            <form id="changelist-form" method="post" {% if cl.formset and cl.formset.is_multipart %}
                  enctype="multipart/form-data" {% endif %} novalidate>{% csrf_token %}

                <div class="box box-primary">

                    {% block result_list %}
                        {% if action_form and actions_on_top and cl.show_admin_actions %}
                            <div class="box-header with-border">
                                {% admin_actions %}
                            </div>
                        {% endif %}

                        <div class="box-body">
                            <div class="table-responsive">
                                {% result_list cl %}
                            </div>
                            {% block pagination %}{% pagination cl %}{% endblock %}
                        </div>

                        {% if action_form and actions_on_bottom and cl.show_admin_actions %}
                            <div class="box-footer">
                                {% admin_actions %}
                            </div>
                        {% endif %}
                    {% endblock %}
                </div>
            </form>
        </div>

        {# Filters #}
        {% block filters %}
            {% if cl.has_filters %}
                <div class="col-sm-3 col-md-2 col-lg-2">
                    <div id="changelist-filter" class="box box-default">
                        <div class="box-header with-border">
                            <h2 class="box-title">{% trans 'Filter' %}</h2>
                        </div>
                        <div class="box-body">
                            {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
                        </div>
                    </div>
                </div>
            {% endif %}
        {% endblock filters %}
    </div>
</div>
{% endblock %}
