Skip to content

Commit

Permalink
Fixed ballot tampering check in case of ranked choice
Browse files Browse the repository at this point in the history
Added hidden action to recompute results
  • Loading branch information
mdipierro committed Feb 28, 2014
1 parent 9474ffa commit b86fffa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/default.py
Expand Up @@ -177,6 +177,12 @@ def reminders_callback():
redirect(URL('elections'),client_side=True)
return dict(form=form,failures=failures,election=election)

@auth.requires(auth.user and auth.user.is_manager)
def recompute_results():
election = db.election(request.args(0,cast=int)) or redirect(URL('index'))
compute_results(election)
redirect(URL('elections'))

def compute_results(election):
voted_ballots = db(db.ballot.election_id==election.id
)(db.ballot.voted==True).select()
Expand Down Expand Up @@ -231,6 +237,7 @@ def hash_ballot(text):
import re
text = text.replace('checked="checked" ','')
text = text.replace('disabled="disabled" ','')
text = re.sub('value="\d+"','',text)
text = re.sub('ballot\S+','',text)
return hash(text)

Expand Down

0 comments on commit b86fffa

Please sign in to comment.