{% extends "admin_base.html" %} {% block title %}{% if admin_dashboard_title %}{{ admin_dashboard_title }}{% endif %}{% endblock %} {% block breadcrumb %} / {% if admin_dashboard_title %}{{ admin_dashboard_title }}{% endif %} {% endblock %} {% block content %} {% block dashboard_header %}

{% if admin_dashboard_title %}{{ admin_dashboard_title }}{% endif %}

{% if admin_dashboard_subtitle %}{{ admin_dashboard_subtitle }}{% endif %}

{% if admin_has_session_override %} ← Template configuré {% endif %}
{% endblock %} {% block dashboard_stats %} {% if resources %} {# KPIs agrégés calculés depuis resource_counts (déjà dans le contexte) — pas de calcul Rust. #} {% set_global total_entries = 0 %} {% set_global max_count = 0 %} {% set_global max_name = "—" %} {% for resource in resources %} {% set c = resource_counts[resource.key] | int(default=0) %} {% set_global total_entries = total_entries + c %} {% if c > max_count %}{% set_global max_count = c %}{% set_global max_name = resource.title %}{% endif %} {% endfor %}
{{ resources | length }}
{{ admin_dashboard_kpi_resources | default(value="Ressources") }}
{{ total_entries }}
{{ admin_dashboard_kpi_entries | default(value="Entrées totales") }}
{{ max_count }}
{{ admin_dashboard_kpi_largest | default(value="Plus grande") }}
{{ max_name }}
{% else %}

{% if admin_dashboard_empty_title %}{{ admin_dashboard_empty_title }}{% endif %}

{% if admin_dashboard_empty_desc %}{{ admin_dashboard_empty_desc }}{% endif %}

{% endif %} {% endblock %} {% block dashboard_table %} {% if resources %}

{% if admin_dashboard_card_resources %}{{ admin_dashboard_card_resources }}{% endif %}

{% for resource in resources %} {% endfor %}
{% if admin_dashboard_th_resource %}{{ admin_dashboard_th_resource }}{% endif %} {{ admin_dashboard_th_count | default(value="Entrées") }} {% if admin_dashboard_th_key %}{{ admin_dashboard_th_key }}{% endif %} {% if admin_dashboard_th_permissions %}{{ admin_dashboard_th_permissions }}{% endif %} {% if admin_dashboard_th_actions %}{{ admin_dashboard_th_actions }}{% endif %}
{{ resource.title }} {{ resource_counts[resource.key] | default(value="—") }} {{ resource.key }} {% if resource_groups[resource.key] %} {% for grp in resource_groups[resource.key] %} {{ grp }} {% endfor %} {% endif %}
{{ admin_dashboard_btn_list }} {% set_global can_create_resource = false %} {% if current_user %} {% if current_user.is_superuser %} {% set_global can_create_resource = 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_resource = true %} {% endif %} {% endfor %} {% endfor %} {% endif %} {% endif %} {% if can_create_resource %} {{ admin_dashboard_btn_create }} {% endif %}
{% endif %} {% endblock %} {% if current_page %}{% set current_page = current_page | default(value="list") %}{% endif %} {% endblock %}