Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-07-15 14:36:15 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-07-15 14:39:04 (GMT)
commit437855d1d872f25ca8dd5d37c97089cd78439e7b (patch)
tree0ef123824b8a1853490f13c2797f227093845405
parent1464d619d5b1aba55791c992e435a0f669e6ae00 (diff)
4122 - Text headers for csv result format
-rw-r--r--webapp/polls/models.py7
-rw-r--r--webapp/polls/tests/result_tests.py2
2 files changed, 6 insertions, 3 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py
index a2c52ab..05346f8 100644
--- a/webapp/polls/models.py
+++ b/webapp/polls/models.py
@@ -413,7 +413,8 @@ class Poll(Document, AbstracErrorObject):
header.append(field.name)
elif field.widget_type in MANY_ANSWERS:
for option in field.options:
- header.append(option.id)
+ col_name = option.text if option.text else option.id
+ header.append(col_name)
return ";".join(header)
@@ -1295,7 +1296,9 @@ class PollResult(AbstractObject):
answer.values()[0].get("weight", "-"))
elif len(answer) and widget_type in MANY_ANSWERS:
for opt_id, opt_value in answer.iteritems():
- aux[opt_id] = str(opt_value.get("weight", "-"))
+ text = opt_value.get('text', None)
+ coln_name = text if text else opt_id
+ aux[coln_name] = str(opt_value.get("weight", "-"))
record = []
for key in header_order:
diff --git a/webapp/polls/tests/result_tests.py b/webapp/polls/tests/result_tests.py
index d34858e..acd43e9 100644
--- a/webapp/polls/tests/result_tests.py
+++ b/webapp/polls/tests/result_tests.py
@@ -350,7 +350,7 @@ class PollResultTests(MongoTestCase):
"RUEE;DEPARTAMENTO;NUM_ESC;GRADO;GRUPO;" +
"TIPO_GRUPO;Q: TextInput con ácento;Q: RadioButton con ácento;" +
"Q: DropDownList;" +
- "Q: ImageRadioButton;1370786178809;1370786178810;" +
+ "Q: ImageRadioButton;option 1;option 2;" +
"1370786178812;1370786178813;", 'utf-8')
self.assertEqual(expected_header, poll_result.get_csv_header())