Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Authors
- David Grochowski (`ThePumpingLemma <https://github.com/ThePumpingLemma>`_)
- David Hite
- David Smith
- David Toulmin (`davidtoulmin <https://github.com/davidtoulmin>`_)
- `ddabble <https://github.com/ddabble>`_
- Dmytro Shyshov (`xahgmah <https://github.com/xahgmah>`_)
- Edouard Richard (`vied12 <https://github.com/vied12>` _)
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Unreleased
version is lower than 4.2 (gh-1261)
- Small performance optimization of the ``clean-duplicate_history`` command (gh-1015)
- Support Simplified Chinese translation (gh-1281)
- Added a running diff to the _object_history_list.html so users can see a list of all field changes made in each change

3.4.0 (2023-08-18)
------------------
Expand Down
9 changes: 9 additions & 0 deletions simple_history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ def history_view(self, request, object_id, extra_context=None):
for list_entry in action_list:
setattr(list_entry, history_list_entry, value_for_entry(list_entry))

previous = None
for list_entry in reversed(action_list):
if previous:
value = list_entry.diff_against(previous).changes
else:
value = ""
setattr(list_entry, "diff", value)
previous = list_entry

content_type = self.content_type_model_cls.objects.get_for_model(
get_user_model()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{% for column in history_list_display %}
<th scope="col">{% trans column %}</th>
{% endfor %}
<th scope="col">{% trans 'Changes from previous' %}</th>
<th scope="col">{% trans 'Date/time' %}</th>
<th scope="col">{% trans 'Comment' %}</th>
<th scope="col">{% trans 'Changed by' %}</th>
Expand All @@ -21,8 +22,9 @@
<tr>
<td><a href="{% url opts|admin_urlname:'simple_history' object.pk action.pk %}">{{ action.history_object }}</a></td>
{% for column in history_list_display %}
<td scope="col">{{ action|getattribute:column }}</th>
<td scope="col">{{ action|getattribute:column }}</td>
{% endfor %}
<td>{% include "simple_history/diff_table.html" with diff=action.diff %}</td>
<td>{{ action.history_date }}</td>
<td>{{ action.get_history_type_display }}</td>
<td>
Expand Down
21 changes: 21 additions & 0 deletions simple_history/templates/simple_history/diff_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% load i18n %}
{% if diff %}
<table>
<thead>
<th>{% trans 'Field' %}</th>
<th>{% trans 'Old Value' %}</th>
<th>{% trans 'New Value' %}</th>
</thead>
<tbody>
{% for change in diff %}
<tr>
<td>{{ change.field }}</td>
<td>{{ change.old }}</td>
<td>{{ change.new }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
{% trans 'No Change' %}
{% endif %}