X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/4d579bfcf20ca69d142c3bcc9eb96feb72888d63..205ab78251b8219e78b684d15adafb72720003d8:/stage2/views.py diff --git a/stage2/views.py b/stage2/views.py index 6b04a57..e199de0 100644 --- a/stage2/views.py +++ b/stage2/views.py @@ -6,6 +6,7 @@ from django.http.response import HttpResponseRedirect, HttpResponse, HttpRespons from django.shortcuts import get_object_or_404, render from django.utils import timezone from django.views.decorators.http import require_POST +from unidecode import unidecode from stage2.forms import AttachmentForm, MarkForm from stage2.models import Participant, Assignment, Answer, Attachment, Mark @@ -54,8 +55,8 @@ def upload(request, assignment_id, participant_id, key): def attachment_download(attachment): response = HttpResponse(content_type='application/force-download') response.write(attachment.file.read()) - base, ext = attachment.filename().rsplit('.', 1) - response['Content-Disposition'] = 'attachment; filename="%s.%s"' % (base[:10].replace('\n', ''), ext) + # workaround to this: https://code.djangoproject.com/ticket/20889 + response['Content-Disposition'] = 'attachment; filename="%s"' % unidecode(attachment.filename().replace('\n', ' ')) response['Content-Length'] = response.tell() return response