From 26d5a6d29c3d7739042f1e399212ae1b4b711bdd Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:15:54 +0530 Subject: [PATCH] Allow district admin to delete users (#1738) --- care/users/api/viewsets/users.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/care/users/api/viewsets/users.py b/care/users/api/viewsets/users.py index 9d590b546d..ff0a325c61 100644 --- a/care/users/api/viewsets/users.py +++ b/care/users/api/viewsets/users.py @@ -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"}