-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin revert enabled/disabled, view only permissions #631
Conversation
Codecov Report
@@ Coverage Diff @@
## master #631 +/- ##
=========================================
Coverage ? 97.99%
=========================================
Files ? 17
Lines ? 946
Branches ? 140
=========================================
Hits ? 927
Misses ? 7
Partials ? 12
Continue to review full report at Codecov.
|
@erikvw this is just an updated version of your last PR right? Any chance that it'd be ready to merge soon? I'd love to see this feature in a current build. |
I also am in need of this PR, as it would resolve this issue: #704 |
This needs to be rebased. |
@erikvw This needs to be rebased. |
No functional changes, just a mechanical rebase of the changes in jazzband#631 onto the latest master branch. Co-authored-by: erikvw <[email protected]>
@jeking3 I rebased the changes onto latest master and put the resulting commit up as a separate PR here: #915. I haven't run the full test suite or made any functional changes, so I'm not sure if anything has broken in the year and a half since this PR was originally opened. @erikvw if you like, you can pull the rebased commit into your branch to continue addressing review feedback; I'm just hoping to help move this along however I can, as I'd really like to be able to use this feature eventually. |
@rolandcrosby-check re #915 that needs to be rebased on master so CI tests can run. |
see #1017 , this might be a better option. |
In some scenarios, it is not ideal to allow users to revert a model instance to a previous version.
Django 2.1 introduced view permissions which, if integrated into DSH, would give an administrator the ability to allow a user to add/change a model but not revert to a previous instance through the model's history.
Related to:
related to #529 and #632
Description
The
SimpleHistoryAdmin
reviews the historical model instance permissions instead of just the model instance by overriding thehas_xxxx_permission
methods in ModelAdmin.enable this feature through settings (SIMPLE_HISTORY_PERMISSIONS_ENABLED);
honor
superuser
privileges;user/group permissions granted for the historical model cannot exceed those of the model. That is, granting
view
andchange
permissions for the historical model but onlyview
permission for the model means the user hasview
permission only for the historical model;text on the changelist and form becomes context sensitive (change permission vs view permission);
setting
SIMPLE_HISTORY_REVERT_DISABLED=True
limits all users (other than superuser) to view access. (this works for all Django versions)the [Revert] button is changed to a [Close] button if the user has:
-- if Django >= 2.1, feature is disabled, and has
view
on model;-- if Django >= 2.1, feature is enable and has
view
model permission andview
historical model permission;-- if
settings. SIMPLE_HISTORY_REVERT_DISABLED = True
(regardless of Django version).How Has This Been Tested?
See tests in
test_admin_with_permissions.py
A few tests in
test_admin.py
required very minor modifications.Screenshots (if appropriate):
For a user with "view" only permission on a historical object, the changelist looks like this:
and the form looks like this:
Types of changes
Checklist:
make format
command to format my codeAUTHORS.rst
CHANGES.rst