Skip to content

Commit b1b46d7

Browse files
committed
Improved documentation for #1017
1 parent fcecd7c commit b1b46d7

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

CHANGES.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Changes
44
Unreleased
55
----------
66

7+
- Added feature to evaluate ``history`` model permissions explicitly when
8+
``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``True``
9+
in ``settings`` (gh-1017).
710

811
3.3.0 (2023-03-08)
912
------------------
@@ -25,9 +28,6 @@ Unreleased
2528
- Started using ``exists`` query instead of ``count`` in ``populate_history`` command (gh-982)
2629
- Add basic support for many-to-many fields (gh-399)
2730
- Added support for Django 4.1 (gh-1021)
28-
- Added feature to evaluate ``history`` model permisions explicitly when
29-
``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``True``
30-
in ``settings`` (gh-1017).
3131

3232
3.1.1 (2022-04-23)
3333
------------------

docs/admin.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ admin class
7272
Disabling the option to revert an object
7373
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7474

75-
By default, an object can be reverted to its previous version. To disable this option globally update your settings with the following:
75+
By default, an object can be reverted to its previous version. To disable this option
76+
globally, update your settings with the following:
7677

7778
.. code-block:: python
7879
@@ -82,19 +83,20 @@ When ``SIMPLE_HISTORY_REVERT_DISABLED`` is set to ``True``, the revert button is
8283

8384
.. image:: screens/10_revert_disabled.png
8485

85-
Enabling history model permissions in Admin
86+
Enforcing history model permissions in Admin
8687
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8788

88-
To have admin evaluate history model permissions explicitly, updating your settings
89-
with the following:
89+
To make the Django admin site evaluate history model permissions explicitly,
90+
update your settings with the following:
9091

9192
.. code-block:: python
9293
9394
SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS = True
9495
95-
By default ``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``False``.
96-
When set to ``False``, permissions applied to the ``Poll`` model also apply to the
97-
history model. That is, granting view and change permissions to the ``Poll`` model
96+
By default, ``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``False``.
97+
When set to ``False``, permissions applied to the ``Poll`` model
98+
(from the examples above), also apply to the history model.
99+
That is, granting view and change permissions to the ``Poll`` model
98100
implicitly grants view and change permissions to the ``Poll`` history model.
99101

100102
The user below has view and change permissions to the ``Poll`` model and the ``Poll``
@@ -118,11 +120,11 @@ in admin.
118120
Permission.objects.get(codename="view_poll"),
119121
)
120122
121-
When ``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``True``, permissions to
122-
history models are assigned and evaluated explicitly.
123+
When ``SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS`` is set to ``True``,
124+
permissions to history models are assigned and evaluated explicitly.
123125

124-
The user below *does not have* permission to the ``Poll`` history model in admin even
125-
though they *have* view permission to the ``Poll`` model.
126+
The user below *does not have* view permission to the ``Poll`` history model in admin,
127+
even though they *have* view permission to the ``Poll`` model.
126128

127129
.. code-block:: python
128130
@@ -144,9 +146,9 @@ history model.
144146
Permission.objects.get(codename="view_historicalpoll"),
145147
)
146148
147-
The user below has view permission to the ``Poll`` history model but will need to
148-
access the instance with a direct url since the ``Poll`` model will not be listed in
149-
the admin application index page nor the ``Poll`` changelist.
149+
The user below has view permission to the ``Poll`` history model, but will need to
150+
access the page with a direct URL, since the ``Poll`` model will not be listed on
151+
the admin application index page, nor the ``Poll`` changelist.
150152

151153
.. code-block:: python
152154

simple_history/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def content_type_model_cls(self):
234234
return django_apps.get_model("contenttypes.contenttype")
235235

236236
def revert_disabled(self, request, obj=None):
237-
"""If true, hides the `Revert` button in the submit_line template."""
237+
"""If `True`, hides the "Revert" button in the `submit_line.html` template."""
238238
if getattr(settings, "SIMPLE_HISTORY_REVERT_DISABLED", False):
239239
return True
240240
elif self.has_view_history_permission(

0 commit comments

Comments
 (0)