X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/967eed676fc83d15b26149047f353ac61faa8217..f1143b5bcf508dcfe7f72e90faee72cf72a2392a:/src/reporting/utils.py?ds=sidebyside diff --git a/src/reporting/utils.py b/src/reporting/utils.py index 955f7d92d..797542abf 100755 --- a/src/reporting/utils.py +++ b/src/reporting/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -33,7 +32,7 @@ def render_to_pdf(output_path, template, context=None, add_files=None): texml = BytesIO(rendered.encode('utf-8')) tempdir = mkdtemp(prefix="render_to_pdf-") tex_path = os.path.join(tempdir, "doc.tex") - with open(tex_path, 'w') as tex_file: + with open(tex_path, 'wb') as tex_file: Texml.processor.process(texml, tex_file, encoding="utf-8") if add_files: @@ -72,7 +71,7 @@ def render_to_csv(output_path, template, context=None, add_files=None): makedirs(os.path.dirname(output_path)) rendered = render_to_string(template, context) - with open(output_path, 'w') as csv_file: + with open(output_path, 'wb') as csv_file: csv_file.write(rendered.encode('utf-8')) @@ -111,7 +110,7 @@ def generated_file_view(file_name, mime_type, send_name=None, signals=None): response = HttpResponse(content_type=mime_type) response['Content-Disposition'] = 'attachment; filename=%s' % name - with open(file_path) as f: + with open(file_path, 'rb') as f: for chunk in read_chunks(f): response.write(chunk) return response