Skip to content

Commit cf668c8

Browse files
committed
unidecode filenames for sponsorship contract export
1 parent 861e536 commit cf668c8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

base-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ django-import-export==2.7.1
5454

5555
pypandoc==1.12
5656
panflute==2.3.0
57+
Unidecode==1.3.8

sponsors/contracts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.http import HttpResponse
55
from django.template.loader import render_to_string
66
from django.utils.dateformat import format
7+
from unidecode import unidecode
78

89
import pypandoc
910

@@ -70,7 +71,7 @@ def render_contract_to_docx_response(request, contract, **context):
7071
)
7172
response[
7273
"Content-Disposition"
73-
] = f"attachment; filename={'sponsorship-renewal' if contract.sponsorship.renewal else 'sponsorship-contract'}-{contract.sponsorship.sponsor.name.replace(' ', '-').replace('.', '')}.docx"
74+
] = f"attachment; filename={'sponsorship-renewal' if contract.sponsorship.renewal else 'sponsorship-contract'}-{unidecode(contract.sponsorship.sponsor.name.replace(' ', '-').replace('.', ''))}.docx"
7475
return response
7576

7677

0 commit comments

Comments
 (0)