{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_list admin_urls suit_list %}
{% load url from future %}

{% block extrastyle %}
  {{ block.super }}
  {#  <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />#}
  {% if cl.formset %}
    {#    <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />#}
  {% endif %}
  {% if cl.formset or action_form %}
    {% url 'admin:jsi18n' as jsi18nurl %}
    <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
  {% endif %}
  {{ media.css }}
  {% if not actions_on_top and not actions_on_bottom %}
    <style>
      {#      #changelist table thead th:first-child {width: inherit}#}
    </style>
  {% endif %}
{% endblock %}

{% block extrahead %}
  {{ block.super }}
  {{ media.js }}
  {% if action_form %}{% if actions_on_top or actions_on_bottom %}
    <script type="text/javascript">
      (function ($) {
        $(document).ready(function ($) {
          $("tr input.action-select").actions();
        });
      })(django.jQuery);
    </script>
  {% endif %}{% endif %}
{% endblock %}

{% block bodyclass %}change-list{% endblock %}

{% if not is_popup %}
  {% block breadcrumbs %}
    <ul class="breadcrumb">
      <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
        <span class="divider">&raquo;</span></li>
      <li>
        <a href="{% url 'admin:app_list' app_label=cl.opts.app_label %}">{{ app_label|capfirst|escape }}</a>
        <span class="divider">&raquo;</span></li>
      <li class="active">{{ cl.opts.verbose_name_plural|capfirst }}</li>
    </ul>
  {% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}

{% block content %}

  <div id="content-main">

    <div class="inner-center-column">
      <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">

        <div class="toolbar-content clearfix">
          {% block object-tools %}
            {% if has_add_permission %}
              <div class="object-tools">
                {% block object-tools-items %}
                  <a href="{% url cl.opts|admin_urlname:'add' %}{% if is_popup %}?_popup=1{% endif %}" class="btn btn-success">
                    <i class="icon-plus-sign icon-white"></i>&nbsp;
                    {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
                  </a>
                {% endblock %}
              </div>
            {% endif %}
          {% endblock %}

          {% block search %}{% search_form cl %}{% endblock %}
        </div>

        {% block date_hierarchy %}
          {% if cl.date_hierarchy %}
            {% date_hierarchy cl %}
          {% endif %}
        {% endblock %}

        {% if cl.formset.errors %}
          <div class="alert alert-error errornote">
            {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
          </div>
          {{ cl.formset.non_form_errors }}
        {% endif %}

        <form id="changelist-form" action="" method="post"
            {% if cl.formset.is_multipart %}
              enctype="multipart/form-data"{% endif %} class="form-inline">{% csrf_token %}
          {% if cl.formset %}
            <div>{{ cl.formset.management_form }}</div>
          {% endif %}

          {% block result_list %}
            {% if cl.result_count %}
              {% if action_form and actions_on_top and cl.full_result_count %}
                {% admin_actions %}{% endif %}
              {% result_list_with_context cl %}

              {% if action_form and actions_on_bottom and cl.full_result_count %}
                {% admin_actions %}{% endif %}
            {% else %}
              <div class="alert alert-block alert-info">
                {% if cl.full_result_count %}
                  <h4>{% trans 'Nothing found' %}!</h4>
                  <br>
                  <a href="?{% if cl.is_popup %}pop=1{% endif %}">{% trans 'Reset search and filters' %}</a>
                {% else %}
                  {% blocktrans with cl.opts.verbose_name_plural|capfirst as name_plural %}{{ name_plural }} are not created yet{% endblocktrans %}.
                  {% if has_add_permission %}<a href="{% url cl.opts|admin_urlname:'add' %}{% if is_popup %}?_popup=1{% endif %}">
                    {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a>{% endif %}
                {% endif %}
              </div>
            {% endif %}
          {% endblock %}

          {% block pagination %}
            {% if cl.result_count %}
              {% if action_form and actions_on_bottom and cl.full_result_count %}
                <div class="below-actions">
              {% endif %}
              {% pagination cl %}
              {% if action_form and actions_on_bottom and cl.full_result_count %}
                </div>
              {% endif %}
            {% endif %}
          {% endblock %}
        </form>
      </div>
    </div>
  </div>
{% endblock %}
