Update web/templates/tools/audit_log.html

This commit is contained in:
Joshua Laymon 2025-08-31 13:11:30 +00:00
parent a107c677ef
commit 2842cbe1b7

View File

@ -21,6 +21,7 @@
{% for r in rows %}
<tr style="background:#fff; box-shadow:0 1px 3px rgba(0,0,0,0.08);">
<td style="padding:10px 14px; vertical-align:top;">{{ r.timestamp|date:"Y-m-d H:i:s" }}</td>
<td style="padding:10px 14px; vertical-align:top;">
{% if r.action == "delete" %}
<span style="color:#dc2626; font-weight:600;">#{{ r.entry_id }}</span>
@ -28,6 +29,7 @@
<a href="{% url 'view_entry' r.entry_id %}" class="pill-link" title="Open entry #{{ r.entry_id }}">#{{ r.entry_id }}</a>
{% endif %}
</td>
<td style="padding:10px 14px; vertical-align:top;">
{% if r.action == "create" %}
<span class="pill pill-green">Created</span>
@ -37,43 +39,65 @@
<span class="pill pill-red">Deleted</span>
{% endif %}
{% if r.action == "update" and r.changes %}
{% if r.changes %}
<div class="muted" style="margin-top:8px;">
{# --- Created: look for the __created__ entry --- #}
{% if r.action == "create" %}
{% for k, v in r.changes.items %}
{% if k == "__created__" %}
<details>
<summary class="small">Show created fields</summary>
<ul class="diff-list">
{% for f, val in v.items %}
<li><strong>{{ f }}</strong>: <code>{{ val }}</code></li>
{% endfor %}
</ul>
</details>
{% endif %}
{% endfor %}
{% endif %}
{# --- Deleted: look for the __deleted__ entry --- #}
{% if r.action == "delete" %}
{% for k, v in r.changes.items %}
{% if k == "__deleted__" %}
<details open>
<summary class="small">Deleted record snapshot</summary>
<ul class="diff-list">
{% for f, val in v.items %}
<li><strong>{{ f }}</strong>: <code>{{ val }}</code></li>
{% endfor %}
</ul>
</details>
{% endif %}
{% endfor %}
{% endif %}
{# --- Updated: render per-field diffs (other keys) --- #}
{% if r.action == "update" %}
<ul class="diff-list">
{% for field, pair in r.changes.items %}
{% if field != "__created__" and field != "__deleted__" %}
<li>
<strong>{{ field }}</strong>:
<span class="chip chip-old">{{ pair.0 }}</span>
<span style="margin: 0 6px;"></span>
<span class="chip chip-new">{{ pair.1 }}</span>
</li>
{% endif %}
{% endfor %}
</ul>
{% elif r.action == "create" and r.changes.__created__ %}
<details>
<summary class="small">Show created fields</summary>
<ul class="diff-list">
{% for k, v in r.changes.__created__.items %}
<li><strong>{{ k }}</strong>: <code>{{ v }}</code></li>
{% endfor %}
</ul>
</details>
{% elif r.action == "delete" and r.changes.__deleted__ %}
<details open>
<summary class="small">Deleted record snapshot</summary>
<ul class="diff-list">
{% for k, v in r.changes.__deleted__.items %}
<li><strong>{{ k }}</strong>: <code>{{ v }}</code></li>
{% endfor %}
</ul>
</details>
{% endif %}
</div>
{% endif %}
</td>
<td style="padding:10px 14px; vertical-align:top;">{{ r.username|default:"—" }}</td>
</tr>
{% empty %}
<tr><td colspan="4" class="muted" style="padding:12px 14px;">No audit entries yet.</td></tr>
{% endfor %}
</tbody>
</tbody>
</table>
</div>
</div>