snapshot: preserve audit log and filtering phase

This commit is contained in:
Md Bayazid Bostame
2026-03-25 20:28:28 +01:00
parent 965531d155
commit a8f7eadbc6
9 changed files with 316 additions and 3 deletions

View File

@@ -0,0 +1,88 @@
{% extends 'workflows/base_shell.html' %}
{% load static i18n %}
{% block title %}{% trans "Audit Log" %}{% endblock %}
{% block extra_css %}
<link rel="stylesheet" href="{% static 'workflows/css/admin_tools.css' %}" />
{% endblock %}
{% block shell_body %}
{% include 'workflows/includes/app_header.html' with header_show_home=1 header_inside_shell=1 %}
<div class="toolbar">
<div>
<h1>{% trans "Audit Log" %}</h1>
<p class="sub">{% trans "Nachvollziehbarkeit aller wichtigen Admin-Aktionen im Portal." %}</p>
</div>
</div>
<div class="card">
<form method="get" class="grid" style="margin-bottom:12px;">
<div class="field">
<label for="action">{% trans "Aktion" %}</label>
<select id="action" name="action">
<option value="">{% trans "Alle" %}</option>
{% for value in action_choices %}
<option value="{{ value }}" {% if selected_action == value %}selected{% endif %}>{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="field">
<label for="user">{% trans "Nutzer" %}</label>
<input id="user" type="text" name="user" value="{{ user_query }}" placeholder="{% trans 'Name, Benutzername oder E-Mail' %}" />
</div>
<div class="field">
<label for="date_from">{% trans "Von Datum" %}</label>
<input id="date_from" type="date" name="date_from" value="{{ date_from }}" />
</div>
<div class="field">
<label for="date_to">{% trans "Bis Datum" %}</label>
<input id="date_to" type="date" name="date_to" value="{{ date_to }}" />
</div>
<div class="actions">
<button class="btn btn-primary" type="submit">{% trans "Filtern" %}</button>
<a class="btn btn-secondary" href="/admin-tools/audit-log/">{% trans "Zurücksetzen" %}</a>
</div>
</form>
<div class="table-wrap">
<table class="table-controls">
<thead>
<tr>
<th>{% trans "Zeit" %}</th>
<th>{% trans "Nutzer" %}</th>
<th>{% trans "Aktion" %}</th>
<th>{% trans "Typ" %}</th>
<th>{% trans "Ziel" %}</th>
<th>{% trans "Details" %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.created_at|date:"Y-m-d H:i:s" }}</td>
<td>{{ row.actor_display|default:"-" }}</td>
<td><code>{{ row.action }}</code></td>
<td>{{ row.target_type|default:"-" }}</td>
<td>
{% if row.target_label %}
{{ row.target_label }}
{% if row.target_id %}<div class="hint">#{{ row.target_id }}</div>{% endif %}
{% elif row.target_id %}
#{{ row.target_id }}
{% else %}
-
{% endif %}
</td>
<td><code>{{ row.details|default:"{}" }}</code></td>
</tr>
{% empty %}
<tr>
<td colspan="6">{% trans "Noch keine Audit-Einträge vorhanden." %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@@ -169,6 +169,14 @@ docker compose exec -T web django-admin compilemessages</code></pre>
<div class="note">
Dynamic content should use explicit DE/EN fields with German fallback, not machine translation at runtime.
</div>
<h3>Audit Trail</h3>
<ul>
<li>Model: <code>AdminAuditLog</code></li>
<li>Purpose: record staff-side mutations that affect operations or configuration.</li>
<li>Current hooks include builder edits, PDF generation, welcome-email actions, integration changes, mode toggles, tests, and request deletions.</li>
<li>Staff UI page: <code>/admin-tools/audit-log/</code></li>
<li>The current UI supports filtering by action, user, and date range. Keep filters server-side to avoid loading unbounded audit rows into the browser.</li>
</ul>
<h2 id="testing">11) Testing and Validation</h2>
<pre><code>docker compose exec -T web python manage.py check

View File

@@ -131,6 +131,11 @@
<a class="btn btn-secondary" href="/admin-tools/handbook/">{% trans "Öffnen" %}</a>
</section>
<section class="admin-card">
<h3>{% trans "Audit Log" %}</h3>
<p>{% trans "Wichtige Admin-Aktionen nachvollziehen und prüfen." %}</p>
<a class="btn btn-secondary" href="/admin-tools/audit-log/">{% trans "Öffnen" %}</a>
</section>
<section class="admin-card">
<h3>{% trans "Integrationen" %}</h3>
<p>{% trans "Nextcloud- und E-Mail-Setup." %}</p>
<a class="btn btn-secondary" href="/admin-tools/integrations/?kind=nextcloud">{% trans "Öffnen" %}</a>
@@ -192,4 +197,3 @@
</div>
</main>
{% endblock %}

View File

@@ -176,6 +176,7 @@
<li><strong>Einweisungs-Builder:</strong> manage custom checklist items for the intro PDF and live introduction checklist, including section, visibility, and conditional display logic.</li>
<li><strong>Integrations:</strong> Nextcloud, SMTP, default routing addresses, notification rules.</li>
<li><strong>Welcome Emails:</strong> scheduled jobs, pause/resume/cancel/trigger now.</li>
<li><strong>Audit Log:</strong> staff-only trace of important admin changes such as builder edits, settings updates, PDF generation, welcome-email operations, and request deletions. Supports filtering by action, user, and date range.</li>
<li><strong>Requests Dashboard:</strong> search records, open PDFs, delete records (single/bulk for staff).</li>
<li><strong>Einweisungs- und Übergabeprotokoll:</strong> staff-only <code>PDF erzeugen</code>, <code>Neu erzeugen</code>, and <code>PDF öffnen</code> actions directly on onboarding rows in the Requests Dashboard.</li>
<li><strong>Einweisung durchführen:</strong> staff-only live checklist page opened from onboarding rows, with draft/completed status, notes, progress tracking, and a separate live-status PDF export.</li>