Automatically update user permission groups to users when they are added as managers to orgs/facilities #425
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.
Configuration
The names of the groups can be configured in the django settings module:
FACILITY_MANAGER_GROUPNAME
for managing facilities (defaults to "Facility Manager")ORGANIZATION_MANAGER_GROUPNAME
for managing organizations (defaults to "Organization Manager")Auto group assignment
Whenever a user becomes a manager (or admin) of a organization, they are now added to the organization manager permission group "Organization Manager" (when it exists in the DB). When the user is removed as manager (or admin) of an organization, and they are no longer an manager (or admin) of any other org, they are removed from the organization manager group.
Likewise, when a becomes a manager (or admin) of a facility, they are now added to the facility manager permission group "Facility Manager" (when it exists in the DB). When the user is removed as manager (or admin) of an facility, and they are no longer an manager (or admin) of any other facility, they are removed from the facility manager group.
Note: when a user becomes a manager of a organization or facility, they are assigned the
is_staff
user attribute to grant them access to django admin. However, when a user is removed from any of beforementioned groups,is_staff
won't be changed, since it can not be known, if the user is granted this attribute because of any other reason.When the respective groups do not exist, nothing is done (
is_staff
won't be changed, too).Migration
is_staff
is not changed during the migration, this remains a manual step.