Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp/polls/views.py
diff options
context:
space:
mode:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-10-02 17:51:00 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-10-02 17:51:00 (GMT)
commit7768fdaff4a2a7bd5f917c029a278eb6355c8938 (patch)
tree8076cb6b5083e17141e9c0e247ff1359f010fcfe /webapp/polls/views.py
parentae2446a7d56f540529414eea1c0c9cb4d9a725c3 (diff)
Show message when a uploaded file is not a .poll_result
Diffstat (limited to 'webapp/polls/views.py')
-rw-r--r--webapp/polls/views.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/webapp/polls/views.py b/webapp/polls/views.py
index e195242..6ca16ee 100644
--- a/webapp/polls/views.py
+++ b/webapp/polls/views.py
@@ -360,17 +360,23 @@ class UnploadPollResultFormView(TemplateView):
files = dict(request.FILES.lists()).get('result', [])
- # si se subió algún archivo:
- if len(files):
- # Esto hace todo
+ to_json = []
- to_json = []
-
- # genera una lista de dict python en to_json
- for file_ in files:
- path = file_.temporary_file_path()
+ # genera una lista de dict python en to_json
+ for index, file_ in enumerate(files):
+ path = file_.temporary_file_path()
+ try:
prf = PollResultFile(path)
to_json.append(prf.get_data())
+ except ValueError:
+ del files[index]
+ fname = file_.name
+ msg = u'{0}: No es un .poll_result válido.'.format(fname)
+ messages.add_message(self.request, messages.ERROR, msg)
+
+ # si se subió algún archivo:
+ if len(files):
+ # Esto hace todo
# comprueba si los archivos ya existían y los excluye
poll_id = to_json[0].get("poll_id", None)