Commit d5c6b7bc authored by Martin Lehoux's avatar Martin Lehoux

Merge branch 'dev' into 'master'

Bugfix: no accent in pdf headers

See merge request !35
parents 70cd185c fd4ea679
import datetime
import unicodedata
from django.shortcuts import render, redirect
from django.core.exceptions import ObjectDoesNotExist
......@@ -558,8 +559,10 @@ def download_document(request, document_id):
return error(request, "Vous essayez de télécharger un document non validé, mais vous n'êtes pas modérateur.")
response = HttpResponse(content=document.file)
filename = unicodedata.normalize('NFD', document.name).encode('ascii', 'ignore').decode('utf-8')
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"'
response['Content-Disposition'] = 'inline; filename="'+filename+'.pdf"'
return response
......@@ -577,8 +580,10 @@ def download_correction(request, document_id):
return error(request, "Vous essayez de télécharger un document non validé, mais vous n'êtes pas modérateur.")
response = HttpResponse(content=document.correction)
filename = unicodedata.normalize('NFD', document.name).encode('ascii', 'ignore').decode('utf-8')
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"'
response['Content-Disposition'] = 'inline; filename="'+filename+'_corr.pdf"'
return response
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment