CSV export: format duration and effort fields correctly
This commit is contained in:
parent
7d979a5749
commit
f4a5b78700
3 changed files with 14 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -66,7 +66,8 @@ class ResultsConceptCSVExport(ResultsConceptView):
|
|||
for row in results:
|
||||
data = {}
|
||||
for f in fields:
|
||||
value = f.getValue(row)
|
||||
lang = self.languageInfo.language
|
||||
value = f.getExportValue(row, 'csv', lang)
|
||||
if ILoopsObject.providedBy(value):
|
||||
value = value.title
|
||||
value = encode(value, self.encoding)
|
||||
|
|
|
@ -247,7 +247,7 @@ Export of work data
|
|||
>>> output = reportView()
|
||||
>>> print output
|
||||
Day;Start;End;Task;Party;Title;Duration;Effort;State
|
||||
08/12/28;19:00;20:15;loops Development;john;;1.25;0.25;finished
|
||||
08/12/28;19:00;20:15;loops Development;john;;1.2500;0.2500;finished
|
||||
|
||||
|
||||
Meeting Minutes
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,6 +23,7 @@ Work report definitions.
|
|||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.component import adapter, getAdapter
|
||||
from zope.i18n.locales import locales
|
||||
|
||||
from cybertools.composer.report.base import Report
|
||||
from cybertools.composer.report.base import LeafQueryCriteria, CompoundQueryCriteria
|
||||
|
@ -78,6 +79,14 @@ class DurationField(Field):
|
|||
return u''
|
||||
return u'%02i:%02i' % divmod(value * 60, 60)
|
||||
|
||||
def getExportValue(self, row, format, lang):
|
||||
value = self.getValue(row)
|
||||
if format == 'csv':
|
||||
locale = locales.getLocale(lang)
|
||||
fmt = locale.numbers.getFormatter('decimal')
|
||||
return fmt.format(value, pattern=u'0.0000;-0.0000')
|
||||
return value
|
||||
|
||||
|
||||
class PartyStateField(StateField):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue