Author: humbedooh
Date: Sun Feb 7 09:05:40 2016
New Revision: 1728931
URL: http://svn.apache.org/viewvc?rev=1728931&view=rev
Log:
backlog feature for monitors
Modified:
steve/trunk/pysteve/lib/election.py
steve/trunk/pysteve/www/cgi-bin/rest_admin.py
Modified: steve/trunk/pysteve/lib/election.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/election.py?rev=1728931&r1=1728930&r2=1728931&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/election.py (original)
+++ steve/trunk/pysteve/lib/election.py Sun Feb 7 09:05:40 2016
@@ -72,6 +72,9 @@ def getVotes(electionID, issueID):
def getVotesRaw(electionID, issueID):
return backend.votes_get_raw(electionID, issueID)
+def getVoteHistory(electionID, issueID):
+ return backend.vote_history(electionID, issueID)
+
def createElection(eid, title, owner, monitors, starts, ends, isopen):
basedata = {
Modified: steve/trunk/pysteve/www/cgi-bin/rest_admin.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/www/cgi-bin/rest_admin.py?rev=1728931&r1=1728930&r2=1728931&view=diff
==============================================================================
--- steve/trunk/pysteve/www/cgi-bin/rest_admin.py (original)
+++ steve/trunk/pysteve/www/cgi-bin/rest_admin.py Sun Feb 7 09:05:40 2016
@@ -485,7 +485,41 @@ else:
response.respond(403, {'message': "You do not have karma
to tally the votes here"})
else:
response.respond(404, {'message': 'No such election or
issue'})
-
+ # Vote backlog, including all recasts
+ elif action == "backlog" and electionID:
+ issue = l[2] if len(l) > 2 else None
+ if electionID and issue:
+ basedata = election.getBasedata(electionID, hideHash=True)
+ if karma >= 2 or ('owner' in basedata and basedata['owner'] ==
whoami):
+ issuedata = election.getIssue(electionID, issue)
+ votes = election.getVoteHistory(electionID, issue)
+ jvotes = []
+ for vote in votes:
+ jvotes.append({
+ 'vote': vote['data']['vote'],
+ 'timestamp': vote['data']['timestamp'],
+ 'uid': hashlib.sha224(vote['key']).hexdigest()
+ })
+ if issuedata and votes:
+ if election.validType(issuedata['type']):
+ ehash, blergh = election.getHash(electionID)
+ response.respond(200, {
+ 'issue': issuedata,
+ 'base': basedata,
+ 'history': jvotes,
+ 'hash': ehash
+ })
+ else:
+ response.respond(500, {'message': "Unknown vote
type"})
+ elif issuedata and not votes:
+ response.respond(404, {'message': "No votes found"})
+ else:
+ response.respond(404, {'message': "Issue not found"})
+ else:
+ response.respond(403, {'message': "You do not have karma
to tally the votes here"})
+ else:
+ response.respond(404, {'message': 'No such election or
issue'})
+
else:
response.respond(400, {'message': "No (or invalid) action
supplied"})
else: