Skip to content

Commit 16b7de7

Browse files
committed
Made object history list template overridable
Including renaming it to remove the `_` prefix (indicating that it's internal / not meant for usage by library users), and adding an `object_history_list_template` field to the admin class. This rename also changed the order of messages in the translation files. Also deprecated the template tag `simple_history_admin_list.display_list`, as it's now entirely unused within the project.
1 parent da87859 commit 16b7de7

File tree

18 files changed

+304
-261
lines changed

18 files changed

+304
-261
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Unreleased
55
----------
66

77
- Support custom History ``Manager`` and ``QuerySet`` classes (gh-1280)
8+
- Renamed the (previously internal) admin template
9+
``simple_history/_object_history_list.html`` to
10+
``simple_history/object_history_list.html``, and added the field
11+
``SimpleHistoryAdmin.object_history_list_template`` for overriding it (gh-1128)
12+
- Deprecated the undocumented template tag ``simple_history_admin_list.display_list()``;
13+
it will be removed in version 3.8 (gh-1128)
814

915
3.5.0 (2024-02-19)
1016
------------------

docs/admin.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ admin class
6969
7070
.. image:: screens/5_history_list_display.png
7171

72+
73+
Customizing the History Admin Templates
74+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75+
76+
If you'd like to customize the HTML of ``SimpleHistoryAdmin``'s object history pages,
77+
you can override the following attributes with the names of your own templates:
78+
79+
- ``object_history_template``: The main object history page, which includes (inserts)
80+
``object_history_list_template``.
81+
- ``object_history_list_template``: The table listing an object's historical records and
82+
the changes made between them.
83+
- ``object_history_form_template``: The form pre-filled with the details of an object's
84+
historical record, which also allows you to revert the object to a previous version.
85+
86+
If you'd like to only customize certain parts of the mentioned templates, look for
87+
``block`` template tags in the source code that you can override.
88+
89+
7290
Disabling the option to revert an object
7391
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7492

simple_history/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
class SimpleHistoryAdmin(admin.ModelAdmin):
2222
object_history_template = "simple_history/object_history.html"
23+
object_history_list_template = "simple_history/object_history_list.html"
2324
object_history_form_template = "simple_history/object_history_form.html"
2425

2526
def get_urls(self):
@@ -80,6 +81,7 @@ def history_view(self, request, object_id, extra_context=None):
8081
)
8182
context = {
8283
"title": self.history_view_title(request, obj),
84+
"object_history_list_template": self.object_history_list_template,
8385
"historical_records": historical_records,
8486
"module_name": capfirst(force_str(opts.verbose_name_plural)),
8587
"object": obj,

simple_history/locale/ar/LC_MESSAGES/django.po

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,6 @@ msgstr "تغيير"
6060
msgid "Deleted"
6161
msgstr "تمت إزالته"
6262

63-
#: simple_history/templates/simple_history/_object_history_list.html:9
64-
msgid "Object"
65-
msgstr "عنصر"
66-
67-
#: simple_history/templates/simple_history/_object_history_list.html:13
68-
msgid "Date/time"
69-
msgstr "التاريخ/الوقت"
70-
71-
#: simple_history/templates/simple_history/_object_history_list.html:14
72-
msgid "Comment"
73-
msgstr "تعليق"
74-
75-
#: simple_history/templates/simple_history/_object_history_list.html:15
76-
msgid "Changed by"
77-
msgstr "تغير من قبل"
78-
79-
#: simple_history/templates/simple_history/_object_history_list.html:16
80-
msgid "Change reason"
81-
msgstr "سبب التغير"
82-
83-
#: simple_history/templates/simple_history/_object_history_list.html:37
84-
msgid "None"
85-
msgstr "فارغ"
86-
8763
#: simple_history/templates/simple_history/object_history.html:11
8864
msgid ""
8965
"Choose a date from the list below to revert to a previous version of this "
@@ -121,6 +97,30 @@ msgstr "اضغط على زر 'استرجاع' ادناه للاسترجاع له
12197
msgid "Press the 'Change History' button below to edit the history."
12298
msgstr "اضغط على زر 'تعديل سجل التغيرات' ادناه لتعديل التاريخ."
12399

100+
#: simple_history/templates/simple_history/object_history_list.html:9
101+
msgid "Object"
102+
msgstr "عنصر"
103+
104+
#: simple_history/templates/simple_history/object_history_list.html:13
105+
msgid "Date/time"
106+
msgstr "التاريخ/الوقت"
107+
108+
#: simple_history/templates/simple_history/object_history_list.html:14
109+
msgid "Comment"
110+
msgstr "تعليق"
111+
112+
#: simple_history/templates/simple_history/object_history_list.html:15
113+
msgid "Changed by"
114+
msgstr "تغير من قبل"
115+
116+
#: simple_history/templates/simple_history/object_history_list.html:16
117+
msgid "Change reason"
118+
msgstr "سبب التغير"
119+
120+
#: simple_history/templates/simple_history/object_history_list.html:42
121+
msgid "None"
122+
msgstr "فارغ"
123+
124124
#: simple_history/templates/simple_history/submit_line.html:4
125125
msgid "Revert"
126126
msgstr "استرجاع"

simple_history/locale/cs_CZ/LC_MESSAGES/django.po

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,6 @@ msgstr "Změněno"
5959
msgid "Deleted"
6060
msgstr "Smazáno"
6161

62-
#: simple_history/templates/simple_history/_object_history_list.html:9
63-
msgid "Object"
64-
msgstr "Objekt"
65-
66-
#: simple_history/templates/simple_history/_object_history_list.html:13
67-
msgid "Date/time"
68-
msgstr "Datum/čas"
69-
70-
#: simple_history/templates/simple_history/_object_history_list.html:14
71-
msgid "Comment"
72-
msgstr "Komentář"
73-
74-
#: simple_history/templates/simple_history/_object_history_list.html:15
75-
msgid "Changed by"
76-
msgstr "Změnil"
77-
78-
#: simple_history/templates/simple_history/_object_history_list.html:16
79-
msgid "Change reason"
80-
msgstr "Důvod změny"
81-
82-
#: simple_history/templates/simple_history/_object_history_list.html:37
83-
msgid "None"
84-
msgstr "Žádné"
85-
8662
#: simple_history/templates/simple_history/object_history.html:11
8763
msgid ""
8864
"Choose a date from the list below to revert to a previous version of this "
@@ -121,6 +97,30 @@ msgstr "Stisknutím tlačítka 'Vrátit změny' se vrátíte k této verzi objek
12197
msgid "Press the 'Change History' button below to edit the history."
12298
msgstr "Chcete-li historii upravit, stiskněte tlačítko 'Změnit historii'"
12399

100+
#: simple_history/templates/simple_history/object_history_list.html:9
101+
msgid "Object"
102+
msgstr "Objekt"
103+
104+
#: simple_history/templates/simple_history/object_history_list.html:13
105+
msgid "Date/time"
106+
msgstr "Datum/čas"
107+
108+
#: simple_history/templates/simple_history/object_history_list.html:14
109+
msgid "Comment"
110+
msgstr "Komentář"
111+
112+
#: simple_history/templates/simple_history/object_history_list.html:15
113+
msgid "Changed by"
114+
msgstr "Změnil"
115+
116+
#: simple_history/templates/simple_history/object_history_list.html:16
117+
msgid "Change reason"
118+
msgstr "Důvod změny"
119+
120+
#: simple_history/templates/simple_history/object_history_list.html:42
121+
msgid "None"
122+
msgstr "Žádné"
123+
124124
#: simple_history/templates/simple_history/submit_line.html:4
125125
msgid "Revert"
126126
msgstr "Vrátit změny"

simple_history/locale/de/LC_MESSAGES/django.po

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,6 @@ msgstr "Geändert"
4848
msgid "Deleted"
4949
msgstr "Gelöscht"
5050

51-
#: simple_history/templates/simple_history/_object_history_list.html:9
52-
msgid "Object"
53-
msgstr "Objekt"
54-
55-
#: simple_history/templates/simple_history/_object_history_list.html:13
56-
msgid "Date/time"
57-
msgstr "Datum/Uhrzeit"
58-
59-
#: simple_history/templates/simple_history/_object_history_list.html:14
60-
msgid "Comment"
61-
msgstr "Kommentar"
62-
63-
#: simple_history/templates/simple_history/_object_history_list.html:15
64-
msgid "Changed by"
65-
msgstr "Geändert von"
66-
67-
#: simple_history/templates/simple_history/_object_history_list.html:16
68-
msgid "Change reason"
69-
msgstr "Änderungsgrund"
70-
71-
#: simple_history/templates/simple_history/_object_history_list.html:37
72-
msgid "None"
73-
msgstr "Keine/r"
74-
7551
#: simple_history/templates/simple_history/object_history.html:11
7652
msgid ""
7753
"Choose a date from the list below to revert to a previous version of this "
@@ -108,6 +84,30 @@ msgstr ""
10884
msgid "Or press the 'Change History' button to edit the history."
10985
msgstr "Oder wählen Sie 'Historie ändern', um diese zu bearbeiten."
11086

87+
#: simple_history/templates/simple_history/object_history_list.html:9
88+
msgid "Object"
89+
msgstr "Objekt"
90+
91+
#: simple_history/templates/simple_history/object_history_list.html:13
92+
msgid "Date/time"
93+
msgstr "Datum/Uhrzeit"
94+
95+
#: simple_history/templates/simple_history/object_history_list.html:14
96+
msgid "Comment"
97+
msgstr "Kommentar"
98+
99+
#: simple_history/templates/simple_history/object_history_list.html:15
100+
msgid "Changed by"
101+
msgstr "Geändert von"
102+
103+
#: simple_history/templates/simple_history/object_history_list.html:16
104+
msgid "Change reason"
105+
msgstr "Änderungsgrund"
106+
107+
#: simple_history/templates/simple_history/object_history_list.html:42
108+
msgid "None"
109+
msgstr "Keine/r"
110+
111111
#: simple_history/templates/simple_history/submit_line.html:3
112112
msgid "Revert"
113113
msgstr "Wiederherstellen"

simple_history/locale/fr/LC_MESSAGES/django.po

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,6 @@ msgstr "Modifié"
5959
msgid "Deleted"
6060
msgstr "Effacé"
6161

62-
#: .\simple_history\templates\simple_history\_object_history_list.html:9
63-
msgid "Object"
64-
msgstr "Objet"
65-
66-
#: .\simple_history\templates\simple_history\_object_history_list.html:13
67-
msgid "Date/time"
68-
msgstr "Date/heure"
69-
70-
#: .\simple_history\templates\simple_history\_object_history_list.html:14
71-
msgid "Comment"
72-
msgstr "Commentaire"
73-
74-
#: .\simple_history\templates\simple_history\_object_history_list.html:15
75-
msgid "Changed by"
76-
msgstr "Modifié par"
77-
78-
#: .\simple_history\templates\simple_history\_object_history_list.html:16
79-
msgid "Change reason"
80-
msgstr "Raison de la modification"
81-
82-
#: .\simple_history\templates\simple_history\_object_history_list.html:37
83-
msgid "None"
84-
msgstr "Aucun"
85-
8662
#: .\simple_history\templates\simple_history\object_history.html:11
8763
msgid ""
8864
"Choose a date from the list below to revert to a previous version of this "
@@ -125,6 +101,30 @@ msgid "Press the 'Change History' button below to edit the history."
125101
msgstr ""
126102
"Cliquez sur le bouton 'Historique' ci-dessous pour modifier l'historique."
127103

104+
#: .\simple_history\templates\simple_history\object_history_list.html:9
105+
msgid "Object"
106+
msgstr "Objet"
107+
108+
#: .\simple_history\templates\simple_history\object_history_list.html:13
109+
msgid "Date/time"
110+
msgstr "Date/heure"
111+
112+
#: .\simple_history\templates\simple_history\object_history_list.html:14
113+
msgid "Comment"
114+
msgstr "Commentaire"
115+
116+
#: .\simple_history\templates\simple_history\object_history_list.html:15
117+
msgid "Changed by"
118+
msgstr "Modifié par"
119+
120+
#: .\simple_history\templates\simple_history\object_history_list.html:16
121+
msgid "Change reason"
122+
msgstr "Raison de la modification"
123+
124+
#: .\simple_history\templates\simple_history\object_history_list.html:42
125+
msgid "None"
126+
msgstr "Aucun"
127+
128128
#: .\simple_history\templates\simple_history\submit_line.html:4
129129
msgid "Revert"
130130
msgstr "Rétablir"

simple_history/locale/id/LC_MESSAGES/django.po

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,6 @@ msgstr "Diubah"
5858
msgid "Deleted"
5959
msgstr "Dihapus"
6060

61-
#: .\simple_history\templates\simple_history\_object_history_list.html:9
62-
msgid "Object"
63-
msgstr "Objek"
64-
65-
#: .\simple_history\templates\simple_history\_object_history_list.html:13
66-
msgid "Date/time"
67-
msgstr "Tanggal/waktu"
68-
69-
#: .\simple_history\templates\simple_history\_object_history_list.html:14
70-
msgid "Comment"
71-
msgstr "Komentar"
72-
73-
#: .\simple_history\templates\simple_history\_object_history_list.html:15
74-
msgid "Changed by"
75-
msgstr "Diubah oleh"
76-
77-
#: .\simple_history\templates\simple_history\_object_history_list.html:16
78-
msgid "Change reason"
79-
msgstr "Alasan perubahan"
80-
81-
#: .\simple_history\templates\simple_history\_object_history_list.html:37
82-
msgid "None"
83-
msgstr "Tidak ada"
84-
8561
#: .\simple_history\templates\simple_history\object_history.html:11
8662
msgid ""
8763
"Choose a date from the list below to revert to a previous version of this "
@@ -122,6 +98,30 @@ msgstr ""
12298
msgid "Press the 'Change History' button below to edit the history."
12399
msgstr "Tekan tombol 'Ubah Riwayat' di bawah ini untuk mengubah riwayat."
124100

101+
#: .\simple_history\templates\simple_history\object_history_list.html:9
102+
msgid "Object"
103+
msgstr "Objek"
104+
105+
#: .\simple_history\templates\simple_history\object_history_list.html:13
106+
msgid "Date/time"
107+
msgstr "Tanggal/waktu"
108+
109+
#: .\simple_history\templates\simple_history\object_history_list.html:14
110+
msgid "Comment"
111+
msgstr "Komentar"
112+
113+
#: .\simple_history\templates\simple_history\object_history_list.html:15
114+
msgid "Changed by"
115+
msgstr "Diubah oleh"
116+
117+
#: .\simple_history\templates\simple_history\object_history_list.html:16
118+
msgid "Change reason"
119+
msgstr "Alasan perubahan"
120+
121+
#: .\simple_history\templates\simple_history\object_history_list.html:42
122+
msgid "None"
123+
msgstr "Tidak ada"
124+
125125
#: .\simple_history\templates\simple_history\submit_line.html:4
126126
msgid "Revert"
127127
msgstr "Kembalikan"

0 commit comments

Comments
 (0)