Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13 from firstziiz/feat/solve-page
Browse files Browse the repository at this point in the history
Fix exception about submission is error
  • Loading branch information
heyfirst authored Sep 29, 2018
2 parents 3670a8c + 88514ff commit a24422f
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions luna-gateway/luna_gateway/answers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,26 @@ def post(self, request):
"submission": submisison,
}

if (submisison['pass'] is True):
try:
Answer.objects.get(
task=task,
owned_by=request.user,
)

return Response({"answered": True, **response})

except Answer.DoesNotExist:
Answer.objects.create(
task=task,
source_code=data['code'],
owned_by=request.user,
duration=timedelta(seconds=duration),
)

try:
if (submisison['pass'] is True):
try:
Answer.objects.get(
task=task,
owned_by=request.user,
)

return Response({"answered": True, **response})

except Answer.DoesNotExist:
Answer.objects.create(
task=task,
source_code=data['code'],
owned_by=request.user,
duration=timedelta(seconds=duration),
)

return Response(response)
else:
return Response(response)
else:
except Exception:
return Response(response)

0 comments on commit a24422f

Please sign in to comment.