|
1
|
{% extends "base.html" %} |
|
2
|
{% load humanize %} |
|
3
|
{% block title %}Audit Log — Fossilrepo{% endblock %} |
|
4
|
|
|
5
|
{% block content %} |
|
6
|
<div class="md:flex md:items-center md:justify-between mb-6"> |
|
7
|
<div> |
|
8
|
<h1 class="text-2xl font-bold text-gray-100">Audit Log</h1> |
|
9
|
<p class="mt-1 text-sm text-gray-400">History of changes across all tracked models.</p> |
|
10
|
</div> |
|
11
|
</div> |
|
12
|
|
|
13
|
<!-- Filter by model type --> |
|
14
|
<div class="flex flex-wrap gap-2 mb-6"> |
|
15
|
<a href="{% url 'organization:audit_log' %}" |
|
16
|
class="rounded-md px-3 py-2 text-sm font-medium {% if not model_filter %}bg-brand text-white{% else %}bg-gray-700 text-gray-300 ring-1 ring-inset ring-gray-600 hover:bg-gray-600{% endif %}"> |
|
17
|
All |
|
18
|
</a> |
|
19
|
{% for model_name in available_models %} |
|
20
|
<a href="{% url 'organization:audit_log' %}?model={{ model_name }}" |
|
21
|
class="rounded-md px-3 py-2 text-sm font-medium {% if model_filter == model_name %}bg-brand text-white{% else %}bg-gray-700 text-gray-300 ring-1 ring-inset ring-gray-600 hover:bg-gray-600{% endif %}"> |
|
22
|
{{ model_name }} |
|
23
|
</a> |
|
24
|
{% endfor %} |
|
25
|
</div> |
|
26
|
|
|
27
|
<!-- Audit entries table --> |
|
28
|
<div class="overflow-x-auto rounded-lg border border-gray-700 bg-gray-800 shadow-sm"> |
|
29
|
<table class="min-w-full divide-y divide-gray-700"> |
|
30
|
<thead class="bg-gray-900"> |
|
31
|
<tr> |
|
32
|
<th class="px-6 py-3 text-left text-xs font-medium uppercase text-gray-400">Date</th> |
|
33
|
<th class="px-6 py-3 text-left text-xs font-medium uppercase text-gray-400">User</th> |
|
34
|
<th class="px-6 py-3 text-left text-xs font-medium uppercase text-gray-400">Action</th> |
|
35
|
<th class="px-6 py-3 text-left text-xs font-medium uppercase text-gray-400">Model</th> |
|
36
|
<th class="px-6 py-3 text-left text-xs font-medium uppercase text-gray-400">Object</th> |
|
37
|
</tr> |
|
38
|
</thead> |
|
39
|
<tbody class="divide-y divide-gray-700 bg-gray-800"> |
|
40
|
{% for entry in entries %} |
|
41
|
<tr class="hover:bg-gray-700/50"> |
|
42
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400" title="{{ entry.date|date:'Y-m-d H:i:s' }}"> |
|
43
|
{{ entry.date|naturaltime }} |
|
44
|
</td> |
|
45
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-300"> |
|
46
|
{% if entry.user %}{{ entry.user.username }}{% else %}<span class="text-gray-500">system</span>{% endif %} |
|
47
|
</td> |
|
48
|
<td class="px-6 py-4 whitespace-nowrap text-sm"> |
|
49
|
{% if entry.action == "Created" %} |
|
50
|
<span class="inline-flex rounded-full bg-green-900/50 px-2 text-xs font-semibold leading-5 text-green-300">Created</span> |
|
51
|
{% elif entry.action == "Changed" %} |
|
52
|
<span class="inline-flex rounded-full bg-yellow-900/50 px-2 text-xs font-semibold leading-5 text-yellow-300">Changed</span> |
|
53
|
{% elif entry.action == "Deleted" %} |
|
54
|
<span class="inline-flex rounded-full bg-red-900/50 px-2 text-xs font-semibold leading-5 text-red-300">Deleted</span> |
|
55
|
{% else %} |
|
56
|
<span class="inline-flex rounded-full bg-gray-700 px-2 text-xs font-semibold leading-5 text-gray-300">{{ entry.action }}</span> |
|
57
|
{% endif %} |
|
58
|
</td> |
|
59
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-400">{{ entry.model }}</td> |
|
60
|
<td class="px-6 py-4 text-sm text-gray-300 max-w-xs truncate">{{ entry.object_repr }}</td> |
|
61
|
</tr> |
|
62
|
{% empty %} |
|
63
|
<tr> |
|
64
|
<td colspan="5" class="px-6 py-8 text-center text-sm text-gray-400">No audit entries found{% if model_filter %} for {{ model_filter }}{% endif %}.</td> |
|
65
|
</tr> |
|
66
|
{% endfor %} |
|
67
|
</tbody> |
|
68
|
</table> |
|
69
|
</div> |
|
70
|
{% with extra_params="&model="|add:model_filter %} |
|
71
|
{% include "includes/_pagination_manual.html" %} |
|
72
|
{% endwith %} |
|
73
|
{% endblock %} |
|
74
|
|