Convert all datetime values to localtime, for "download rows as CSV"
this probably will need to be more flexible at some point; this works for now
This commit is contained in:
parent
4413a61513
commit
8945dd75aa
|
@ -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.
|
||||||
#
|
#
|
||||||
|
@ -27,6 +27,7 @@ Model Master View
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import datetime
|
||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -2345,6 +2346,9 @@ class MasterView(View):
|
||||||
csvrow = {}
|
csvrow = {}
|
||||||
for field in fields:
|
for field in fields:
|
||||||
value = getattr(obj, field, None)
|
value = getattr(obj, field, None)
|
||||||
|
if isinstance(value, datetime.datetime):
|
||||||
|
# TODO: this assumes value is *always* naive UTC
|
||||||
|
value = localtime(self.rattail_config, value, from_utc=True)
|
||||||
csvrow[field] = '' if value is None else six.text_type(value)
|
csvrow[field] = '' if value is None else six.text_type(value)
|
||||||
return csvrow
|
return csvrow
|
||||||
|
|
||||||
|
@ -2355,6 +2359,9 @@ class MasterView(View):
|
||||||
csvrow = {}
|
csvrow = {}
|
||||||
for field in fields:
|
for field in fields:
|
||||||
value = getattr(row, field, None)
|
value = getattr(row, field, None)
|
||||||
|
if isinstance(value, datetime.datetime):
|
||||||
|
# TODO: this assumes value is *always* naive UTC
|
||||||
|
value = localtime(self.rattail_config, value, from_utc=True)
|
||||||
csvrow[field] = '' if value is None else six.text_type(value)
|
csvrow[field] = '' if value is None else six.text_type(value)
|
||||||
return csvrow
|
return csvrow
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue