fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove non-ascii chars from SCSS to keep pipeline from tripping.
[redakcja.git]
/
src
/
catalogue
/
ebook_utils.py
diff --git
a/src/catalogue/ebook_utils.py
b/src/catalogue/ebook_utils.py
index
dae2e76
..
f9bd6d3
100644
(file)
--- a/
src/catalogue/ebook_utils.py
+++ b/
src/catalogue/ebook_utils.py
@@
-1,5
+1,7
@@
-# -*- coding: utf-8 -*-
-from StringIO import StringIO
+# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from io import BytesIO
from catalogue.models import Book
from librarian import DocProvider
from django.http import HttpResponse
from catalogue.models import Book
from librarian import DocProvider
from django.http import HttpResponse
@@
-12,7
+14,7
@@
class RedakcjaDocProvider(DocProvider):
self.publishable = publishable
def by_slug(self, slug):
self.publishable = publishable
def by_slug(self, slug):
- return
String
IO(Book.objects.get(dc_slug=slug
+ return
Bytes
IO(Book.objects.get(dc_slug=slug
).materialize(publishable=self.publishable
).encode('utf-8'))
).materialize(publishable=self.publishable
).encode('utf-8'))
@@
-26,7
+28,7
@@
def serve_file(file_path, name, mime_type):
response = HttpResponse(content_type=mime_type)
response['Content-Disposition'] = 'attachment; filename=%s' % name
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
for chunk in read_chunks(f):
response.write(chunk)
return response