Skip to content

Commit

Permalink
bugfix: Fixed the bug where the exception was swallowed and the time …
Browse files Browse the repository at this point in the history
…field was taken incorrectly
  • Loading branch information
meua committed Jan 30, 2024
1 parent e12cee4 commit 6f5ef35
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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")
Expand Down

0 comments on commit 6f5ef35

Please sign in to comment.