This repository was archived by the owner on Jul 26, 2024. It is now read-only.
Open
Conversation
… permission, and made migration.
- Changed ClearCacheAdminView.test_func() to test for the permission (this is backward compatible with the previous test of “is_superuser”, since superusers have all permissions.
- Now test for the permission in admin/index.html template, to avoid displaying the clearcache section on Admin’s homepage if the user is not allowed to make use of clearcache.
- Added tests to check permissions with regular user:
Created “tests” folder.
Original tests unchanged to assert backward compatibility, as test_superuser.py
Just moved CACHE_EXPIRE_IN_SEC constant at module level to avoid PEP8 violation (all-caps constants not supposed to be in functions).
Additional test as test_regular_user.py.
1) Added python 3.11 and django 4.2 to test matrix. Since Django 4.2 is not supported on Python 3.7, I had to run 2 jobs in the workflow (python3.7 and all other python versions) and issue a different tox command in each one. 2) Added pytest and pytest-django in dependencies in tox.ini as required by “Missing dependency” tox warning. 3) Upgraded actions to v3 (checkout and python setup). v2 runs on node12 which is deprecated. 4) Added workflow_dispatch: event to be able to manually trigger the workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this pull request
As of v1.2.1:
Both issue are nicely solved by using a specific permission (
clearcache.use_clearcache), to control the access to both the service and the display its section in the Admin's homepage.Testing for the permission in the existing
test_func()of the view preserves the current behaviour as long as the permission is not granted to anyone, since superusers have all permissions.Changes summary
CustomPermissions” (without databasse tables) to createclearcache.use_clearcachepermission, and made migration.ClearCacheAdminView.test_func()to test for the permission (this is backward compatible with the previous test of “is_superuser”, since superusers have all permissions).admin/index.htmltemplate, to avoid displaying the clearcache section on Admin’s homepage if the user is not authorized.testsfolder.test_superuser.py. Just moved CACHE_EXPIRE_IN_SEC constant at module level to avoid PEP8 violation (all-caps constants not supposed to be in functions).test_regular_user.py.tox.inias required by “Missing dependency” tox warning.workflow_dispatch:event to be able to manually trigger the workflow. It could be removed, but I guess it doesn't hurt.All tests are ok.