From 6f5ef35fc42846564e9a0ea8ed03ae339e49d1d1 Mon Sep 17 00:00:00 2001 From: meua Date: Tue, 30 Jan 2024 20:58:11 +0800 Subject: [PATCH] bugfix: Fixed the bug where the exception was swallowed and the time field was taken incorrectly --- apps/challenges/views.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/challenges/views.py b/apps/challenges/views.py index 3e832e5724..215eaae19b 100644 --- a/apps/challenges/views.py +++ b/apps/challenges/views.py @@ -2891,7 +2891,6 @@ def get_aws_credentials_for_participant_team(request, phase_pk): @permission_classes((permissions.IsAuthenticated, HasVerifiedEmail)) @authentication_classes((JWTAuthentication, ExpiringTokenAuthentication)) def invite_users_to_challenge(request, challenge_pk): - challenge = get_challenge_model(challenge_pk) if not challenge.is_active or not challenge.approved_by_admin: @@ -4600,8 +4599,11 @@ def create_or_update_challenge_phase(request, challenge_host_team_pk, challenge_ serializer.save() response_data["dataset_split"] = serializer.data else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - + logger.error(serializer.errors) + response_data = { + "error": "Internal error in the service. Failed to create Challenge Dataset Split." + " Please contact the administrator."} + raise RuntimeError(response_data) data = { "challenge_phase": challenge_phase.pk, "leaderboard": 21, # Todo Destroy the magic number @@ -4615,10 +4617,18 @@ def create_or_update_challenge_phase(request, challenge_host_team_pk, challenge_ serializer.save() response_data["challenge_phase_split"] = serializer.data else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + logger.error(serializer.errors) + response_data = { + "error": "Internal error in the service. Failed to create Challenge Phase Split." + " Please contact the administrator."} + raise RuntimeError(response_data) return Response(response_data, status=status.HTTP_201_CREATED) else: - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + logger.error(serializer.errors) + response_data = { + "error": "Internal error in the service. Failed to create Challenge Phase." + " Please contact the administrator."} + raise RuntimeError(response_data) except Exception as exc: return Response({"error": str(exc)}, status=status.HTTP_400_BAD_REQUEST) else: @@ -4640,7 +4650,7 @@ def create_or_update_challenge_phase(request, challenge_host_team_pk, challenge_ challenge_phase.is_public = request.data.get("is_public") challenge_phase.is_submission_public = request.data.get("is_submission_public") challenge_phase.start_date = datetime.strptime(request.data.get("start_date"), "%Y-%m-%dT%H:%M:%S%z") - challenge_phase.end_date = datetime.strptime(request.data.get("start_date"), "%Y-%m-%dT%H:%M:%S%z") + challenge_phase.end_date = datetime.strptime(request.data.get("end_date"), "%Y-%m-%dT%H:%M:%S%z") challenge_phase.test_annotation_file = request.data.get("test_annotation_file") challenge_phase.max_submissions_per_day = request.data.get("max_submissions_per_day") challenge_phase.max_submissions_per_month = request.data.get("max_submissions_per_month")