Skip to content

Commit 02a1ba5

Browse files
C4ptainCrunchclaude
andcommitted
Improve document history display with readable field labels and old/new values
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent af8ce39 commit 02a1ba5

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

moderation/models.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ class Meta:
6666
def __str__(self):
6767
return f"{self.user.get_short_name()} a fait une action le {self.timestamp.strftime('%d/%m/%Y')}"
6868

69-
### Action translation logic ###
69+
FIELD_LABELS = {
70+
"name": "titre",
71+
"description": "description",
72+
"tags": "tags",
73+
"hidden": "visibilité",
74+
}
7075

7176
@property
7277
def action_text(self):
@@ -83,7 +88,18 @@ def action_text(self):
8388
return "a refusé la demande de"
8489
elif self.target_field == "reupload":
8590
return "a re-uploadé"
86-
return f"a modifié '{self.target_field}' sur"
91+
label = self.FIELD_LABELS.get(self.target_field, self.target_field)
92+
return f"a modifié '{label}' sur"
93+
94+
@property
95+
def document_action_text(self):
96+
"""Action text for document history context (no trailing 'sur')."""
97+
if self.target_field == "reupload":
98+
return "re-upload"
99+
if self.target_field == "hidden":
100+
return "caché" if str(self.new_value) == "True" else "rendu visible"
101+
label = self.FIELD_LABELS.get(self.target_field, self.target_field)
102+
return f"modifié {label}"
87103

88104
@property
89105
def action_color(self):

moderation/templates/moderation/document_history.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ <h1 class="mb-0">Historique de modération</h1>
3131
<th class="ps-4">Date</th>
3232
<th>Modérateur</th>
3333
<th>Action</th>
34+
<th>Détails</th>
3435
</tr>
3536
</thead>
3637
<tbody>
@@ -44,16 +45,21 @@ <h1 class="mb-0">Historique de modération</h1>
4445
</td>
4546
<td>
4647
<span class="badge bg-{{ log.action_color }} bg-opacity-10 text-{{ log.action_color }} border border-{{ log.action_color }}">
47-
{{ log.action_text }}
48+
{{ log.document_action_text }}
4849
</span>
49-
{% if log.details_text %}
50-
<div class="mt-1 small text-muted fst-italic">{{ log.details_text }}</div>
50+
</td>
51+
<td class="small text-muted">
52+
{% if log.old_value and log.new_value and log.target_field != "reupload" %}
53+
<span class="text-decoration-line-through">{{ log.old_value|truncatewords:15 }}</span>
54+
&rarr; {{ log.new_value|truncatewords:15 }}
55+
{% elif log.target_field == "reupload" %}
56+
{{ log.new_value }}
5157
{% endif %}
5258
</td>
5359
</tr>
5460
{% empty %}
5561
<tr>
56-
<td colspan="3" class="text-center text-muted py-5">
62+
<td colspan="4" class="text-center text-muted py-5">
5763
Aucune action de modération enregistrée sur ce document.
5864
</td>
5965
</tr>

0 commit comments

Comments
 (0)