Skip to content

Commit

Permalink
Prepisovanie rieseni (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacspe authored Apr 13, 2024
1 parent 6b9be65 commit b5d75ec
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class ProblemViewSet(ModelViewSetWithSerializerContext):
queryset = Problem.objects.all()
serializer_class = ProblemSerializer
permission_classes = (ProblemPermission,)
MAX_SUBMITTED_SOLUTIONS = 10

def perform_create(self, serializer):
"""
Expand Down Expand Up @@ -271,18 +270,14 @@ def upload_solution(self, request, pk=None):
if len(existing_solutions) > 0 and late_tag is not None and not late_tag.can_resubmit:
raise exceptions.ValidationError(
detail='Túto úlohu už nie je možné odovzdať znova.')
Solution.objects.filter(
problem=problem, semester_registration=event_registration).delete()
solution = Solution.objects.create(
problem=problem,
semester_registration=event_registration,
late_tag=late_tag,
is_online=True
)

# delete solutions until there is less than allowed amount
while len(existing_solutions) > self.MAX_SUBMITTED_SOLUTIONS - 1:
Solution.objects.filter(
problem=problem, semester_registration=event_registration)\
.earliest('uploaded_at').delete()
solution.solution.save(
solution.get_solution_file_name(), file, save=True)

Expand Down

0 comments on commit b5d75ec

Please sign in to comment.