Skip to content

Commit

Permalink
added bboard search
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Nov 14, 2008
1 parent 0667bd4 commit 6db7ade
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
20 changes: 16 additions & 4 deletions controllers/election.py
Expand Up @@ -606,16 +606,28 @@ def vote(self, election):
return self.render('vote')

@web
def bboard(self, election):
def bboard(self, election, voter_email=None, voter_openid=None, after=None, offset=0, limit=20):
"""
Display a list of encrypted votes
"""
offset = int(offset)
limit = int(limit)
if not election.is_frozen():
self.redirect("./view")

# load all voters
voters = election.get_voters()

# if there's a specific voter
if voter_email or voter_openid:
voters = [do.Voter.selectByEmailOrOpenID(election, email=voter_email, openid_url=voter_openid)]
else:
# load a bunch of voters
voters = election.get_voters(after=after, limit=limit+1)

more_p = len(voters) > limit
if more_p:
voters = voters[0:limit]
next_after = voters[limit-1].voter_id
next_offset = offset + limit

return self.render('bboard')

@web
Expand Down
6 changes: 3 additions & 3 deletions index.yaml
Expand Up @@ -10,14 +10,14 @@ indexes:
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

# Unused in query history -- copied from input.
# Used 2 times in query history.
- kind: ElectionExponent
properties:
- name: election
- name: exponent
direction: desc

# Used once in query history.
# Used 9 times in query history.
- kind: KeyShare
properties:
- name: election
Expand All @@ -43,7 +43,7 @@ indexes:
- name: tallied_at
- name: cast_id

# Used once in query history.
# Used 32 times in query history.
- kind: Voter
properties:
- name: election
Expand Down
17 changes: 17 additions & 0 deletions templates/election/bboard.tmpl
@@ -1,6 +1,23 @@
#include "templates/header.tmpl"
<h2 class="title">$election.name &mdash; Bulletin Board <span style="font-size:0.7em;">[<a href="./view">done</a>]</span></h2>

<h3>Search</h3>
<form method="get" action="">
Voter Email: <input type="text" name="voter_email" size="40" value="$voter_email" />
<input type="submit" value="search" />
</form>
<br /><br />
#if $voter_email or $voter_openid
<b>currently viewing voter ${voter_email or voter_openid}</b>. [<a href="./bboard">Show All</a>]
<br /><br />
#end if
Voters ${offset+1} - ${offset+$limit} &nbsp;&nbsp;
#if $after
<a href="./bboard">back to start</a> &nbsp;&nbsp;
#end if
#if $more_p
<a href="./bboard?after=$next_after&offset=$next_offset">next $limit</a>
#end if
<table class="pretty">
<tr><th>Name</th><th>Ballot Fingerprint</th></tr>
#for $voter in $voters
Expand Down

0 comments on commit 6db7ade

Please sign in to comment.