From d2408a2d5e61b89109b695598fd418ba4944d388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D1=83=D0=BC?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Mon, 3 Mar 2025 15:02:11 +0300 Subject: [PATCH] feat: added max attempts handling --- services/backend/api/v1/task/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/backend/api/v1/task/views.py b/services/backend/api/v1/task/views.py index 9a57a7f..d34d88e 100644 --- a/services/backend/api/v1/task/views.py +++ b/services/backend/api/v1/task/views.py @@ -108,6 +108,11 @@ def submit_task( UserAchievement.objects.create( user=user, achievement=first_steps_achievement ) + + total_attempts = CompetitionTaskSubmission.objects.filter(user=user, task=task).count() + if task.max_attempts == total_attempts: + return status.FORBIDDEN, ForbiddenError() + if task.type == CompetitionTask.CompetitionTaskType.INPUT: submission = CompetitionTaskSubmission.objects.create( user=user,