Skip to content

Commit

Permalink
Added user uploaded solution size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Mihálik committed Dec 9, 2023
1 parent 810eb91 commit 119fbe1
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 119fbe1

Please sign in to comment.