Commit fd4ea679 authored by Martin Lehoux's avatar Martin Lehoux

strip accents for headers

parent 70cd185c
import datetime import datetime
import unicodedata
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
...@@ -558,8 +559,10 @@ def download_document(request, document_id): ...@@ -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.") 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) response = HttpResponse(content=document.file)
filename = unicodedata.normalize('NFD', document.name).encode('ascii', 'ignore').decode('utf-8')
response['Content-Type'] = 'application/pdf' response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"' response['Content-Disposition'] = 'inline; filename="'+filename+'.pdf"'
return response return response
...@@ -577,8 +580,10 @@ def download_correction(request, document_id): ...@@ -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.") 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) response = HttpResponse(content=document.correction)
filename = unicodedata.normalize('NFD', document.name).encode('ascii', 'ignore').decode('utf-8')
response['Content-Type'] = 'application/pdf' response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'inline; filename="'+document.name+'.pdf"' response['Content-Disposition'] = 'inline; filename="'+filename+'_corr.pdf"'
return response 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