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

Allow district admin to delete users #1738

Merged
merged 1 commit into from
Dec 7, 2023
Merged

Allow district admin to delete users #1738

merged 1 commit into from
Dec 7, 2023

Conversation

Ashesh3
Copy link
Member

@Ashesh3 Ashesh3 commented Dec 3, 2023

Frontend PR: coronasafe/care_fe#6781

Proposed Changes

In this commit, a new filter condition has been added specifically for the DistrictAdmin user type in the users API viewsets. More specifically, in the destroy function. Previously, if a user had a request that passed through this function, it would only check if the user's type is less than StateAdmin and hence not a superuser.

Now, besides the pre-existing conditions (user type is less than StateAdmin and not a superuser), if the user type is DistrictAdmin, an additional filter is applied. The filter checks if the district field of the user matches the district of the request.user and also verifies if the user type is less than DistrictAdmin and not a superuser.

Thus, this commit essentially grants a finer degree of control to the District Administrators in managing users under their jurisdiction i.e., the same district. It is important to note that this patch restricts the DistrictAdmin from deleting users of the same type or higher and the superusers, thus putting checks on their privileges.

Associated Issue

@coronasafe/care-backend-maintainers @coronasafe/care-backend-admins

Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8bdbb42) 60.76% compared to head (8c4dbf3) 60.75%.

Files Patch % Lines
care/users/api/viewsets/users.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1738      +/-   ##
==========================================
- Coverage   60.76%   60.75%   -0.02%     
==========================================
  Files         210      210              
  Lines       11531    11533       +2     
  Branches     1642     1643       +1     
==========================================
  Hits         7007     7007              
- Misses       4283     4284       +1     
- Partials      241      242       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vigneshhari vigneshhari merged commit 26d5a6d into master Dec 7, 2023
9 of 11 checks passed
@vigneshhari vigneshhari deleted the del-user-perms branch December 7, 2023 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants