handle deleted user scenario in complete task api

This commit is contained in:
jain
2023-08-18 11:45:21 +05:30
parent dd2890bca6
commit ef4c459229
2 changed files with 4 additions and 1 deletions

View File

@ -99,7 +99,8 @@ ERROR_CODE = {
"2070": "You did not find as a guardian",
"2071": "You did not find as a junior",
"2072": "You can not approve or reject this task because junior does not exist in the system",
"2073": "You can not approve or reject this junior because junior does not exist in the system"
"2073": "You can not approve or reject this junior because junior does not exist in the system",
"2074": "You can not complete this task because you does not exist in the system"
}
"""Success message code"""

View File

@ -339,6 +339,8 @@ class CompleteJuniorTaskAPIView(views.APIView):
task_queryset = JuniorTask.objects.filter(id=task_id, junior__auth__email=self.request.user
).select_related('guardian', 'junior').last()
if task_queryset:
if task_queryset.junior.is_deleted:
return custom_error_response(ERROR_CODE['2074'], response_status=status.HTTP_400_BAD_REQUEST)
# use CompleteTaskSerializer serializer
if task_queryset.task_status in [str(NUMBER['four']), str(NUMBER['five'])]:
"""Already request send """