diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-10-02 15:24:55 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-10-02 15:24:55 (GMT) |
commit | ecb24dfddc108f878643552925b3f64e54d7ba84 (patch) | |
tree | 807c57de44e8bbcf12271407f5156826a5779c2c /webapp/polls/views.py | |
parent | 132c6cc82f6b89aa974326e6f3ed489259f3b79c (diff) |
Refactor: Use PollResultFile in Upload poll results view
Diffstat (limited to 'webapp/polls/views.py')
-rw-r--r-- | webapp/polls/views.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/webapp/polls/views.py b/webapp/polls/views.py index c19eac1..e195242 100644 --- a/webapp/polls/views.py +++ b/webapp/polls/views.py @@ -1,7 +1,5 @@ # -*- encoding: utf-8 -*- import os -import json -import StringIO import warnings from importlib import import_module @@ -369,13 +367,10 @@ class UnploadPollResultFormView(TemplateView): to_json = [] # genera una lista de dict python en to_json - for file in files: - json_dst = StringIO.StringIO() - for chunk in file.chunks(): - json_dst.write(chunk) - json_dst.seek(0) - to_json.append(json.load(json_dst, 'utf-8')) - file.seek(0) + for file_ in files: + path = file_.temporary_file_path() + prf = PollResultFile(path) + to_json.append(prf.get_data()) # comprueba si los archivos ya existÃan y los excluye poll_id = to_json[0].get("poll_id", None) |