Skip to content

Commit da87859

Browse files
committed
Renamed admin's action_list to historical_records
This is a more accurate name for the contents of the queryset. Also did a small cleanup of `_object_history_list.html`, incl. removing the `scope` attribute of a `<td>` tag, as it's been deprecated for those tags (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td#scope).
1 parent 4d39103 commit da87859

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

simple_history/admin.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ def history_view(self, request, object_id, extra_context=None):
4646
pk_name = opts.pk.attname
4747
history = getattr(model, model._meta.simple_history_manager_attribute)
4848
object_id = unquote(object_id)
49-
action_list = history.filter(**{pk_name: object_id})
49+
historical_records = history.filter(**{pk_name: object_id})
5050
if not isinstance(history.model.history_user, property):
5151
# Only select_related when history_user is a ForeignKey (not a property)
52-
action_list = action_list.select_related("history_user")
52+
historical_records = historical_records.select_related("history_user")
5353
history_list_display = getattr(self, "history_list_display", [])
5454
# If no history was found, see whether this object even exists.
5555
try:
5656
obj = self.get_queryset(request).get(**{pk_name: object_id})
5757
except model.DoesNotExist:
5858
try:
59-
obj = action_list.latest("history_date").instance
60-
except action_list.model.DoesNotExist:
59+
obj = historical_records.latest("history_date").instance
60+
except historical_records.model.DoesNotExist:
6161
raise http.Http404
6262

6363
if not self.has_view_history_or_change_history_permission(request, obj):
6464
raise PermissionDenied
6565

66-
# Set attribute on each action_list entry from admin methods
66+
# Set attribute on each historical record from admin methods
6767
for history_list_entry in history_list_display:
6868
value_for_entry = getattr(self, history_list_entry, None)
6969
if value_for_entry and callable(value_for_entry):
70-
for list_entry in action_list:
71-
setattr(list_entry, history_list_entry, value_for_entry(list_entry))
70+
for record in historical_records:
71+
setattr(record, history_list_entry, value_for_entry(record))
7272

7373
content_type = self.content_type_model_cls.objects.get_for_model(
7474
get_user_model()
@@ -80,7 +80,7 @@ def history_view(self, request, object_id, extra_context=None):
8080
)
8181
context = {
8282
"title": self.history_view_title(request, obj),
83-
"action_list": action_list,
83+
"historical_records": historical_records,
8484
"module_name": capfirst(force_str(opts.verbose_name_plural)),
8585
"object": obj,
8686
"root_path": getattr(self.admin_site, "root_path", None),

simple_history/templates/simple_history/_object_history_list.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,32 @@
1717
</tr>
1818
</thead>
1919
<tbody>
20-
{% for action in action_list %}
20+
{% for record in historical_records %}
2121
<tr>
22-
<td><a href="{% url opts|admin_urlname:'simple_history' object.pk action.pk %}">{{ action.history_object }}</a></td>
22+
<td>
23+
<a href="{% url opts|admin_urlname:'simple_history' object.pk record.pk %}">
24+
{{ record.history_object }}
25+
</a>
26+
</td>
2327
{% for column in history_list_display %}
24-
<td scope="col">{{ action|getattribute:column }}</th>
28+
<td>{{ record|getattribute:column }}</td>
2529
{% endfor %}
26-
<td>{{ action.history_date }}</td>
27-
<td>{{ action.get_history_type_display }}</td>
30+
<td>{{ record.history_date }}</td>
31+
<td>{{ record.get_history_type_display }}</td>
2832
<td>
29-
{% if action.history_user %}
30-
{% url admin_user_view action.history_user_id as admin_user_url %}
33+
{% if record.history_user %}
34+
{% url admin_user_view record.history_user_id as admin_user_url %}
3135
{% if admin_user_url %}
32-
<a href="{{ admin_user_url }}">{{ action.history_user }}</a>
36+
<a href="{{ admin_user_url }}">{{ record.history_user }}</a>
3337
{% else %}
34-
{{ action.history_user }}
38+
{{ record.history_user }}
3539
{% endif %}
3640
{% else %}
3741
{% trans "None" %}
3842
{% endif %}
3943
</td>
4044
<td>
41-
{{ action.history_change_reason }}
45+
{{ record.history_change_reason }}
4246
</td>
4347
</tr>
4448
{% endfor %}

simple_history/templates/simple_history/object_history.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% if not revert_disabled %}<p>
1111
{% blocktrans %}Choose a date from the list below to revert to a previous version of this object.{% endblocktrans %}</p>{% endif %}
1212
<div class="module">
13-
{% if action_list %}
13+
{% if historical_records %}
1414
{% display_list %}
1515
{% else %}
1616
<p>{% trans "This object doesn't have a change history." %}</p>

0 commit comments

Comments
 (0)