Skip to content

Commit

Permalink
Allow district admin to delete users (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Dec 7, 2023
1 parent df576b0 commit 26d5a6d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions care/users/api/viewsets/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ def destroy(self, request, *args, **kwargs):
user_type__lt=User.TYPE_VALUE_MAP["StateAdmin"],
is_superuser=False,
)
elif request.user.user_type == User.TYPE_VALUE_MAP["DistrictAdmin"]:
queryset = queryset.filter(
district=request.user.district,
user_type__lt=User.TYPE_VALUE_MAP["DistrictAdmin"],
is_superuser=False,
)
else:
return Response(
status=status.HTTP_403_FORBIDDEN, data={"permission": "Denied"}
Expand Down

0 comments on commit 26d5a6d

Please sign in to comment.