Skip to content

Commit

Permalink
Added Facility Delete Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed May 13, 2021
1 parent 8debd3c commit 872b08a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions care/facility/api/viewsets/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class FacilityViewSet(
mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
"""Viewset for facility CRUD operations."""
Expand All @@ -96,6 +97,11 @@ def get_serializer_class(self):
else:
return FacilitySerializer

def destroy(self, request, *args, **kwargs):
if request.user.is_superuser or request.user.user_type >= User.TYPE_VALUE_MAP["DistrictLabAdmin"]:
return super().destroy(request, *args, **kwargs)
return Response({"permission": "denied"}, status=status.HTTP_403_FORBIDDEN)

def list(self, request, *args, **kwargs):
"""
Facility List
Expand Down

0 comments on commit 872b08a

Please sign in to comment.