Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Jan 23, 2024
2 parents 8a4ce18 + 1f3c933 commit 1d7f208
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/api/v1/v1_users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from rest_framework.views import APIView
from rest_framework_simplejwt.tokens import RefreshToken

from api.v1.v1_forms.models import FormApprovalAssignment
from api.v1.v1_data.models import PendingDataApproval
from api.v1.v1_profile.constants import UserRoleTypes
from api.v1.v1_profile.models import Access, Administration, Levels
from api.v1.v1_users.models import SystemUser, Organisation, \
Expand Down Expand Up @@ -493,6 +495,8 @@ def delete(self, request, user_id, version):
if login_user.id == instance.id:
return Response({'message': "Could not do self deletion"},
status=status.HTTP_409_CONFLICT)
FormApprovalAssignment.objects.filter(user=instance).delete()
PendingDataApproval.objects.filter(user=instance).delete()
instance.deleted_at = timezone.now()
instance.save()
return Response(status=status.HTTP_204_NO_CONTENT)
Expand All @@ -506,6 +510,8 @@ def delete(self, request, user_id, version):
summary='To update user')
def put(self, request, user_id, version):
if request.data.get("role") == UserRoleTypes.super_admin:
FormApprovalAssignment.objects.filter(user_id=user_id).delete()
PendingDataApproval.objects.filter(user_id=user_id).delete()
request.data.update({
"administration":
Administration.objects.filter(level__level=0).first().id
Expand Down

0 comments on commit 1d7f208

Please sign in to comment.