fnp
/
edumed.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
618e0c5
)
just use unidecode for filenames
author
Jan Szejko
<janek37@gmail.com>
Mon, 16 Jan 2017 09:28:17 +0000
(10:28 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Mon, 16 Jan 2017 09:28:17 +0000
(10:28 +0100)
requirements.txt
patch
|
blob
|
history
stage2/views.py
patch
|
blob
|
history
diff --git
a/requirements.txt
b/requirements.txt
index
5382026
..
2a776b2
100644
(file)
--- a/
requirements.txt
+++ b/
requirements.txt
@@
-38,3
+38,5
@@
sorl-thumbnail>=12,<13
pyyaml
django-subdomains>=2.0.4,<2.1
pyyaml
django-subdomains>=2.0.4,<2.1
+
+unidecode
\ No newline at end of file
diff --git
a/stage2/views.py
b/stage2/views.py
index
ca9f935
..
e199de0
100644
(file)
--- 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 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
from stage2.forms import AttachmentForm, MarkForm
from stage2.models import Participant, Assignment, Answer, Attachment, Mark
@@
-54,9
+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())
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.strip()[:20].replace('\n', '').strip(), 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
response['Content-Length'] = response.tell()
return response