Correct handling of spaces in paperwork filenames

Also normalises display of Invoice IDs. Partial fix for #391.
This commit is contained in:
2020-10-09 12:09:12 +01:00
parent 934c07be72
commit 12a60e1f50
7 changed files with 28 additions and 32 deletions

View File

@@ -195,6 +195,7 @@ class EventPrint(generic.View):
},
'quote': True,
'current_user': request.user,
'filename': 'Event {} {} {}.pdf'.format(object.display_id, re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name), object.start_date)
}
rml = template.render(context)
@@ -209,10 +210,7 @@ class EventPrint(generic.View):
merger.write(merged)
response = HttpResponse(content_type='application/pdf')
escapedEventName = re.sub(r'[^a-zA-Z0-9 \n\.]', '', object.name)
response['Content-Disposition'] = "filename=N%05d | %s.pdf" % (object.pk, escapedEventName)
response['Content-Disposition'] = 'filename="{}"'.format(context['filename'])
response.write(merged.getvalue())
return response