2026-08-14 18:02:25 +02:00
{% extends "base.html" %}
2026-08-14 20:53:03 +02:00
{% block title %}Rôles et permissions — GMAO{% endblock %}
2026-08-14 18:02:25 +02:00
{% block content %}
< div class = "container-fluid" >
2026-08-14 20:53:03 +02:00
< div class = "d-flex justify-content-between align-items-center mb-4" >
< div >
< h1 class = "h3" > < i class = "bi bi-shield-check" > < / i > Rôles et permissions< / h1 >
2026-08-21 20:10:29 +02:00
< p class = "text-muted mb-0" > Gérez les rôles et les permissions métier de chaque domaine.< / p >
2026-08-14 18:02:25 +02:00
< / div >
2026-08-14 20:53:03 +02:00
< a href = "{{ url_for('admin.users') }}" class = "btn btn-outline-primary" > < i class = "bi bi-people" > < / i > Utilisateurs< / a >
< / div >
2026-08-14 18:02:25 +02:00
2026-08-14 20:53:03 +02:00
< div class = "alert alert-info" >
2026-08-21 20:10:29 +02:00
Les rôles peuvent cumuler plusieurs permissions. Le code technique reste affiché à titre secondaire pour le diagnostic.
2026-08-14 20:53:03 +02:00
< / div >
2026-08-14 18:02:25 +02:00
2026-08-14 20:53:03 +02:00
< div class = "row g-3" >
2026-08-21 18:46:19 +02:00
{% for role in roles_list %}
2026-08-14 20:53:03 +02:00
< div class = "col-xl-4 col-md-6" >
< div class = "card h-100" >
< div class = "card-header d-flex justify-content-between" >
2026-08-21 18:46:19 +02:00
< strong > {{ role.name }}< / strong >
< span class = "badge bg-secondary" > {{ role.user_links|length }} compte(s)< / span >
2026-08-14 18:02:25 +02:00
< / div >
< div class = "card-body" >
2026-08-21 20:10:29 +02:00
{% if role.slug == 'super_admin' %}
< div class = "alert alert-danger mb-0" > < strong > Super administrateur — accès complet< / strong > < br > < small > Ce rôle possède automatiquement toutes les permissions de l'application. Sa matrice n'est pas configurable.< / small > < / div >
{% else %}< h2 class = "h6" > Permissions< / h2 >
2026-08-21 18:46:19 +02:00
{% if role.permission_links|selectattr('permission.code', 'equalto', '*')|list %}
2026-08-14 20:53:03 +02:00
< span class = "badge bg-danger" > Accès complet< / span >
{% else %}
< div class = "d-flex flex-wrap gap-1 mb-3" >
2026-08-21 18:46:19 +02:00
{% for link in role.permission_links if link.effect == 'allow' and link.permission.is_active %}
2026-08-21 20:10:29 +02:00
< span class = "badge text-bg-light border" title = "{{ link.permission.description }}" > {{ link.permission.name }} < small class = "text-muted" > ({{ link.permission.code }})< / small > < / span >
2026-08-14 20:53:03 +02:00
{% endfor %}
< / div >
2026-08-21 20:10:29 +02:00
{% endif %}{% endif %}
2026-08-14 18:02:25 +02:00
2026-08-21 18:46:19 +02:00
{% if role.user_links %}
2026-08-14 20:53:03 +02:00
< hr >
2026-08-21 18:46:19 +02:00
{% for link in role.user_links %}{% set user = link.user %}
2026-08-14 20:53:03 +02:00
< form method = "post" action = "{{ url_for('admin.update_user_permissions', id=user.id) }}" class = "row g-2 align-items-center mb-2" >
< input type = "hidden" name = "csrf_token" value = "{{ csrf_token() }}" >
< div class = "col" > < span class = "small" > {{ user.full_name or user.username }}< / span > < / div >
< div class = "col-auto" >
2026-08-21 18:46:19 +02:00
< select name = "role_ids" class = "form-select form-select-sm" aria-label = "Rôle de {{ user.username }}" >
< option value = "{{ role.id }}" selected > {{ role.name }}< / option >
2026-08-14 20:53:03 +02:00
< / select >
2026-08-14 18:02:25 +02:00
< / div >
2026-08-14 20:53:03 +02:00
< div class = "col-auto" > < button class = "btn btn-sm btn-outline-primary" type = "submit" > Appliquer< / button > < / div >
< / form >
{% endfor %}
{% endif %}
2026-08-14 18:02:25 +02:00
< / div >
2026-08-14 20:53:03 +02:00
< / div >
2026-08-14 18:02:25 +02:00
< / div >
2026-08-14 20:53:03 +02:00
{% endfor %}
< / div >
2026-08-14 18:02:25 +02:00
< / div >
2026-08-14 20:53:03 +02:00
{% endblock %}