{% load i18n admin_extras favorites %}

{% if app_list %}
  {% favorite_map as favorites_map %}
  {% dashboard_model_status_map app_list as model_statuses %}
  {% if show_favorites is not False %}
    {% with show_model_badges=False %}
      {% cached_dashboard_favorites app_list favorites_map as favorites_block %}
      {{ favorites_block }}
    {% endwith %}
  {% endif %}
  {% with show_model_badges=show_model_badges|default:True %}
  {% celery_feature_enabled as celery_enabled %}
  {% for app in app_list %}
    {% if app.app_label != 'django_celery_beat' or celery_enabled %}
    <div class="app-{{ app.app_label }} module{% if app.app_url in request.path|urlencode %} current-app{% endif %}" data-app-label="{{ app.app_label }}">
      <table>
        <caption class="app-caption">
          <div class="app-caption-inner">
            <a
              class="section app-caption-link"
              href="{{ app.app_url }}"
              title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}"
            >
              {{ app.name }}
            </a>
          </div>
        </caption>
        <thead class="visually-hidden">
          <tr>
            <th scope="col">{% translate 'Model name' %}</th>
            <th scope="col">{% translate 'Model actions' %}</th>
            <th scope="col">{% translate 'Add link' %}</th>
            <th scope="col">{% translate 'Change or view list link' %}</th>
          </tr>
        </thead>
        <tbody id="app-{{ app.app_label }}-models">
        {% for model in app.models %}
          {% model_app_label model app.app_label as model_app_label %}
          {% with model_name=model.object_name|lower %}
            {% favorite_ct_id model_app_label model.object_name as ct_id %}
            {% favorite_from_map favorites_map ct_id as fav %}
            {% include "admin/includes/dashboard_model_row.html" with app_label=app.app_label model=model fav=fav ct_id=ct_id model_app_label=model_app_label model_name=model_name row_dom_id=model_app_label|add:"-"|add:model_name show_model_badges=show_model_badges model_statuses=model_statuses %}
          {% endwith %}
        {% endfor %}
        </tbody>
      </table>
    </div>
    {% endif %}
  {% endfor %}
  {% endwith %}
{% else %}
  <p>{% translate 'You don’t have permission to view or edit anything.' %}</p>
{% endif %}
