update to CSV changes made in r2071

This commit is contained in:
Frédéric Péters 2011-04-25 16:03:07 +02:00
parent 7e61a8f1d7
commit 89935e7a4f
1 changed files with 11 additions and 10 deletions

View File

@ -80,14 +80,16 @@ class FormResultDirectory(FormPage):
' <li><a href="participation">%s</a>' % _('Participation')
'</ul>'
def csv_tuple(self, fields, data=None):
if data is None:
# display heading
if str(self.formdef.workflow_id).endswith(str('+anonymous')):
return ['#code'] + [x.label for x in fields]
else:
return ['#id', _('time'), _('userlabel')] + [x.label for x in fields]
def csv_tuple_heading(self, fields):
if str(self.formdef.workflow_id).endswith(str('+anonymous')):
heading_fields = ['#code']
else:
heading_fields = ['#id', _('time'), _('userlabel')]
for field in fields:
heading_fields.extend(field.get_csv_heading())
return heading_fields
def csv_tuple(self, fields, data):
if str(self.formdef.workflow_id).endswith(str('+anonymous')):
elements = [data.verification_code]
else:
@ -96,11 +98,10 @@ class FormResultDirectory(FormPage):
except:
userlabel = ''
elements = [str(data.id), misc.localstrftime(data.receipt_time), userlabel]
for field in fields:
element = data.data.get(field.id, '') or ''
if field.convert_value_to_str:
element = field.convert_value_to_str(element)
elements += [str(fixcsv(element))]
elements.extend(field.get_csv_value(element))
return elements
def participation [html] (self):