diff --git a/base/messages.py b/base/messages.py index 37aa49a..db1fdd5 100644 --- a/base/messages.py +++ b/base/messages.py @@ -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""" diff --git a/junior/views.py b/junior/views.py index 7620963..7a83b0a 100644 --- a/junior/views.py +++ b/junior/views.py @@ -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 """