Browse Source

don't test can vote permission on polls unaware of users votes

Rafał Pitoń 8 years ago
parent
commit
fd8116c0d8
1 changed files with 5 additions and 4 deletions
  1. 5 4
      misago/threads/permissions/polls.py

+ 5 - 4
misago/threads/permissions/polls.py

@@ -206,10 +206,11 @@ def allow_vote_poll(user, target):
         raise PermissionDenied(_("You have to sign in to vote in polls."))
         raise PermissionDenied(_("You have to sign in to vote in polls."))
 
 
     user_has_voted = False
     user_has_voted = False
-    for choice in target.choices:
-        if choice['selected']:
-            user_has_voted = True
-            break
+    if target.choices and 'selected' in target.choices[0]:
+        for choice in target.choices:
+            if choice['selected']:
+                user_has_voted = True
+                break
 
 
     if user_has_voted and not target.allow_revotes:
     if user_has_voted and not target.allow_revotes:
         raise PermissionDenied(_("You have already voted in this poll."))
         raise PermissionDenied(_("You have already voted in this poll."))