diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-06-08 20:39:45 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-06-10 17:47:31 (GMT) |
commit | 22dab872c03af7b53b2d5da8f5e531715e89c35a (patch) | |
tree | 206d7b7ee979fb842c27108063920be134371be3 /webapp/polls/views.py | |
parent | 0fb480fae92f51528d0d95754751451c34c57374 (diff) |
Web system can export poll results to csv file.
Diffstat (limited to 'webapp/polls/views.py')
-rw-r--r-- | webapp/polls/views.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/webapp/polls/views.py b/webapp/polls/views.py index 3487845..10ed773 100644 --- a/webapp/polls/views.py +++ b/webapp/polls/views.py @@ -323,6 +323,18 @@ def opt_thumb(request, poll_id, img_name): ) +def csv_download(request, poll_id): + + poll_result = Poll.get(poll_id).get_result() + + # Download csv file + response = HttpResponse( + poll_result.to_csv(), content_type='text/csv;') + response['Content-Disposition'] = ( + 'attachment; filename="%s_result.csv"' % poll_id) + return response + + class UnploadPollResultFormView(TemplateView): template_name = "poll-result-form.html" |