Fix Excel download of ordering batch, per python3
This commit is contained in:
parent
5a96672d79
commit
318e8645b2
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -110,7 +110,9 @@ class View(object):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return self.notfound()
|
return self.notfound()
|
||||||
response = FileResponse(path, request=self.request)
|
response = FileResponse(path, request=self.request)
|
||||||
response.headers[b'Content-Length'] = six.binary_type(os.path.getsize(path))
|
response.content_length = os.path.getsize(path)
|
||||||
filename = os.path.basename(path).encode('ascii', 'replace')
|
filename = os.path.basename(path)
|
||||||
response.headers[b'Content-Disposition'] = b'attachment; filename="{}"'.format(filename)
|
if six.PY2:
|
||||||
|
filename = filename.encode('ascii', 'replace')
|
||||||
|
response.content_disposition = str('attachment; filename="{}"'.format(filename))
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -36,8 +36,6 @@ from rattail.db import model, api
|
||||||
from rattail.core import Object
|
from rattail.core import Object
|
||||||
from rattail.time import localtime
|
from rattail.time import localtime
|
||||||
|
|
||||||
from pyramid.response import FileResponse
|
|
||||||
|
|
||||||
from tailbone.views.purchasing import PurchasingBatchView
|
from tailbone.views.purchasing import PurchasingBatchView
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,10 +352,7 @@ class OrderingBatchView(PurchasingBatchView):
|
||||||
path = batch.filepath(self.rattail_config, filename)
|
path = batch.filepath(self.rattail_config, filename)
|
||||||
workbook.save(path)
|
workbook.save(path)
|
||||||
|
|
||||||
response = FileResponse(path, request=self.request)
|
return self.file_response(path)
|
||||||
response.content_length = os.path.getsize(path)
|
|
||||||
response.content_disposition = b'attachment; filename="{}"'.format(filename)
|
|
||||||
return response
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _ordering_defaults(cls, config):
|
def _ordering_defaults(cls, config):
|
||||||
|
|
Loading…
Reference in a new issue