Fix csv export of properties that are not string (like datetime.time). Also replace name_on_documents with name helper property.
Patch by: Pawel Solyga
Reviewed by: to-be-reviewed
--- a/app/soc/views/models/base.py Tue Mar 24 16:21:36 2009 +0000
+++ b/app/soc/views/models/base.py Tue Mar 24 18:00:46 2009 +0000
@@ -25,6 +25,7 @@
import csv
+import datetime
import StringIO
from google.appengine.ext import db
@@ -755,14 +756,18 @@
# encode the data to UTF-8 to ensure compatibiliy
for row_dict in data:
for key in row_dict.keys():
- row_dict[key] = row_dict[key].encode("utf-8")
+ value = row_dict[key]
+ row_dict[key] = value.encode("utf-8") if isinstance(value, basestring) else str(value)
writer.writerow(row_dict)
else:
writer = csv.writer(f, dialect='excel')
# encode the data to UTF-8 to ensure compatibiliy
for row in data:
- writer.writerow(row.encode("utf-8"))
+ if row:
+ writer.writerow(row.encode("utf-8"))
+ else:
+ writer.writerow(row)
data = f.getvalue()
--- a/app/soc/views/models/role.py Tue Mar 24 16:21:36 2009 +0000
+++ b/app/soc/views/models/role.py Tue Mar 24 18:00:46 2009 +0000
@@ -158,7 +158,7 @@
new_params['extra_dynaexclude'] = ['user', 'status', 'agreed_to_tos_on']
new_params['list_key_order'] = [
- 'link_id', 'scope_path', 'given_name', 'surname', 'name_on_documents',
+ 'link_id', 'scope_path', 'given_name', 'surname', 'name',
'email', 'home_page','blog','res_street', 'res_city',
'res_state', 'res_country', 'res_postalcode', 'phone',
'ship_street', 'ship_city', 'ship_state', 'ship_country',