From 5d56f8180aeb5e30d6a0cb1b1fc72abe35bd993a Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Fri, 3 Jul 2026 10:24:40 +0200 Subject: [PATCH] feat(admin): add /admin/journal audit log page --- src/pages/admin/journal.py | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/pages/admin/journal.py diff --git a/src/pages/admin/journal.py b/src/pages/admin/journal.py new file mode 100644 index 0000000..0a0e4ea --- /dev/null +++ b/src/pages/admin/journal.py @@ -0,0 +1,58 @@ +import dash_bootstrap_components as dbc +from dash import dash_table, html, register_page + +from src.admin.db import list_actions +from src.admin.guard import is_admin +from src.pages.admin._shell import admin_nav, not_admin + +register_page( + __name__, + path="/admin/journal", + title="Journal admin | colibre", + name="Journal admin", + description="Panneau d'administration interne.", +) + + +def _rows(): + rows = [] + for action in list_actions(): + target = action["target_user_id"] + rows.append( + { + "date": action["created_at"], + "admin": action["admin_email"], + "action": action["action"], + "user": f"[{target}](/admin/user/{target})" if target else "", + "détails": action["details"] or "", + } + ) + return rows + + +def layout(**_): + if not is_admin(): + return not_admin() + return dbc.Container( + [ + html.H2("Journal des actions admin"), + admin_nav("journal"), + dash_table.DataTable( + id="admin-journal-table", + columns=[ + {"name": "Date", "id": "date"}, + {"name": "Admin", "id": "admin"}, + {"name": "Action", "id": "action"}, + {"name": "User", "id": "user", "presentation": "markdown"}, + {"name": "Détails", "id": "détails"}, + ], + data=_rows(), + sort_action="native", + page_action="native", + page_size=20, + markdown_options={"link_target": "_self"}, + ), + ], + fluid=True, + className="py-4", + )