Skip to content
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

refactor assessment permissions in django views and API #732

Merged
merged 36 commits into from
Feb 18, 2023

Conversation

shapiromatron
Copy link
Owner

@shapiromatron shapiromatron commented Nov 12, 2022

There were currently many patterns for checking permissions to view a page, edit content, or interact with the API. This PR begins consolidating permission checking approaches.

For django based views, whenever we can inherit permissions from an Assessment, we can now inherit from of the common base views in HAWC, instead of adding mixins or custom permission checks. These mixins are now removed:

  • LegacyAssessmentAdapterMixin
  • TeamMemberOrHigherMixin
  • ProjectManagerOrHigherMixin
  • CanCreateMixin

Renamed this method, it had a misleading name:

  • Assessment.user_is_part_of_team -> Assessment.user_is_reviewer_or_higher

Renamed this method in the hawc client, to be consistent with API:

  • riskofbias.data -> riskofbias.export
  • riskofbias.full_data -> riskofbias.full_export

@shapiromatron shapiromatron marked this pull request as draft November 12, 2022 05:55
@rabstejnek rabstejnek marked this pull request as ready for review January 12, 2023 21:58
# Conflicts:
#	hawc/apps/riskofbias/api.py
#	hawc/apps/study/views.py
@shapiromatron shapiromatron changed the title remove custom mixins in favor of AssessmentPermissionsMixin refactor assessment permissions in django views and API Feb 15, 2023
@shapiromatron shapiromatron merged commit efaa660 into main Feb 18, 2023
@shapiromatron shapiromatron deleted the no-team-member-mixin branch February 18, 2023 02:40
shapiromatron added a commit that referenced this pull request Apr 7, 2023
shapiromatron added a commit that referenced this pull request Apr 13, 2023
* prep release

* prep for updated client release

* update redis

* remove copy

* add build

* add twine

* fix manifest

* minor updates from release

* replace document ready with vanilla js

(cherry picked from commit 180a240)

* hawcprd -> hawc

(cherry picked from commit 728f577)

* fix admin export and write test

* fix template tag

* fix strange apis

* remove old endpoint tag list

* fix api issues

* fix errors w/ invalid user input

* fix view error

* fix another regression from #732

* add paginator to summary tables list

* update full text URL endpoint

* word edits

* standardize assessment get

* get assessment in query_params or body

* lint

* fix name
shapiromatron added a commit that referenced this pull request Apr 18, 2023
* upgrade to 3.11

* fix?

* fix shape

* prep release

* prep for updated client release

* update redis

* remove copy

* add build

* add twine

* fix manifest

* minor updates from release

* replace document ready with vanilla js

(cherry picked from commit 180a240)

* hawcprd -> hawc

(cherry picked from commit 728f577)

* fix admin export and write test

* fix template tag

* fix strange apis

* remove old endpoint tag list

* fix api issues

* fix errors w/ invalid user input

* fix view error

* fix another regression from #732

* fix deprecations

* remove extra venv

* update docs
shapiromatron added a commit that referenced this pull request Apr 18, 2023
* upgrade to 3.11

* fix?

* fix shape

* ruff

* prep release

* prep for updated client release

* update redis

* remove copy

* add build

* add twine

* fix manifest

* minor updates from release

* replace document ready with vanilla js

(cherry picked from commit 180a240)

* hawcprd -> hawc

(cherry picked from commit 728f577)

* fix admin export and write test

* fix template tag

* fix strange apis

* remove old endpoint tag list

* fix api issues

* fix errors w/ invalid user input

* fix view error

* fix another regression from #732

* fix deprecations

* remove extra venv

* update docs

* update versions

* black formatting changes

* add ruff flake8 + isort ruff config

* add pyupgrade to ruff (UP)

* black

* add RUF linter

* add flake8-bugbear

* add flake8-bandit

* add flake8-print

* show fixes when linting

* updates w/ new black plugin
shapiromatron added a commit that referenced this pull request May 8, 2023
* upgrade to 3.11

* fix?

* fix shape

* ruff

* prep release

* prep for updated client release

* update redis

* remove copy

* add build

* add twine

* fix manifest

* minor updates from release

* replace document ready with vanilla js

(cherry picked from commit 180a240)

* hawcprd -> hawc

(cherry picked from commit 728f577)

* fix admin export and write test

* fix template tag

* fix strange apis

* remove old endpoint tag list

* fix api issues

* fix errors w/ invalid user input

* fix view error

* fix another regression from #732

* fix deprecations

* remove extra venv

* update docs

* update versions

* black formatting changes

* add ruff flake8 + isort ruff config

* add pyupgrade to ruff (UP)

* black

* add RUF linter

* add flake8-bugbear

* add flake8-bandit

* add flake8-print

* install django 4.2

* git ls-files -- 'hawc/*.py' | xargs django-upgrade --target-version 3.2

* git ls-files -- 'hawc/*.py' | xargs django-upgrade --target-version 4.2

* fix errors from manual testing

* add color toggle

* revisions from code reviews

* layout

* updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants