runique 2.1.21

A Django-inspired web framework for Rust with ORM, templates, and comprehensive security middleware
Documentation
{% extends "admin_base.html" %}
{% block title %}{{ resource.title | default(value="Éléments") }}{% endblock %}
{% block breadcrumb %}
  <span class="admin-topbar__sep">/</span>
  <a href="{{ admin_prefix }}">{% if admin_list_breadcrumb_admin %}{{ admin_list_breadcrumb_admin }}{% endif %}</a>
  {% if parent_key %}
  <span class="admin-topbar__sep">/</span>
  <a href="{{ parent_base }}/{{ parent_id }}/detail">{{ parent_title }}</a>
  {% endif %}
  <span class="admin-topbar__sep">/</span>
  <span>{{ resource.title | default(value="Éléments") }}</span>
{% endblock %}
{% block content %}
  {% set_global can_create = false %}
  {% if current_user %}
    {% if current_user.is_superuser %}
      {% set_global can_create = true %}
    {% else %}
      {% for groupe in current_user.groupes %}
        {% for perm in groupe.permissions %}
          {% if perm.resource_key == resource.key and perm.can_create %}
            {% set_global can_create = true %}
          {% endif %}
        {% endfor %}
      {% endfor %}
    {% endif %}
  {% endif %}

  {% block list_header %}
  <div class="admin-page__header">
    <div>
      <h1 class="admin-page__title">{{ resource.title | default(value="Éléments") }}</h1>
      <p class="admin-page__subtitle">{{ total | default(value=0) }} {% if total == 1 %}{{ admin_list_entries_count_one }}{% else %}{{ admin_list_entries_count_many }}{% endif %}</p>
    </div>

    {% if can_create %}
    {# Desktop : bouton plein. Mobile : masqué (≤600px), l'action passe dans le kebab
       de ligne ; pour une liste vide, un bouton de repli est rendu dans l'état vide. #}
    <a href="{{ resource_base }}/create" class="btn btn-primary admin-page__create-btn">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="15" height="15">
        <line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
      </svg>
      {% if admin_list_btn_create %}{{ admin_list_btn_create }}{% endif %}
    </a>
    {% endif %}
  </div>
  {% endblock %}

  {% include "admin/list_partial.html" %}

  <script {% csp %} src="{{ "js/admin/admin-actions.js" | runique_static }}"></script>
  <script {% csp %} src="{{ "js/admin/admin-kebab.js" | runique_static }}"></script>
  <script {% csp %} src="{{ "js/admin/admin-list.js" | runique_static }}"></script>
  <script {% csp %} src="{{ "js/admin/admin-bulk.js" | runique_static }}"></script>
{% endblock %}

{% block extra_js %}
{{ super() }}
<script {% csp %}>htmx = { config: { allowEval: false } };</script>
<script {% csp %} src="https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous" defer></script>
{% endblock %}