Skip to content

Commit

Permalink
Merge pull request #321 from ZdruzenieSTROM/solution-size-limit
Browse files Browse the repository at this point in the history
Added user uploaded solution size limit
  • Loading branch information
kovacspe authored Dec 9, 2023
2 parents f4ecfce + 119fbe1 commit 09e0e4e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions competition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,17 @@ def upload_solution(self, request, pk=None):
detail='Túto úlohu už nie je možné odovzdať.')
event_registration = EventRegistration.get_registration_by_profile_and_event(
request.user.profile, problem.series.semester)

if 'file' not in request.FILES:
raise exceptions.ParseError(detail='Request neobsahoval súbor')

file = request.FILES['file']

if file.size > 20971520: # 20 MB
raise exceptions.ParseError(
detail='Riešenie prekročilo maximálnu povolenú veľkosť',
)

if mime_type(file) != 'application/pdf':
raise exceptions.ParseError(
detail='Riešenie nie je vo formáte pdf')
Expand Down

0 comments on commit 09e0e4e

Please sign in to comment.