You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2015/03/21 12:43:27 UTC
svn commit: r1668244 - in /steve/trunk/pytest/www: cgi-bin/rest_voter.py
htdocs/request_link.html
Author: humbedooh
Date: Sat Mar 21 11:43:27 2015
New Revision: 1668244
URL: http://svn.apache.org/r1668244
Log:
allow fetching of base data for open elections and use that to set the title of the link request page
Modified:
steve/trunk/pytest/www/cgi-bin/rest_voter.py
steve/trunk/pytest/www/htdocs/request_link.html
Modified: steve/trunk/pytest/www/cgi-bin/rest_voter.py
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/cgi-bin/rest_voter.py?rev=1668244&r1=1668243&r2=1668244&view=diff
==============================================================================
--- steve/trunk/pytest/www/cgi-bin/rest_voter.py (original)
+++ steve/trunk/pytest/www/cgi-bin/rest_voter.py Sat Mar 21 11:43:27 2015
@@ -59,7 +59,7 @@ if pathinfo:
issue = l[2] if len(l) > 2 else None
voterid = form.getvalue('uid')
- if not voterid and karma < 3 and action != "request":
+ if not voterid and karma < 3 and (action != "request" and action != "peek"):
response.respond(403, {'message': "Voter UID missing"})
elif action == "view":
@@ -202,6 +202,25 @@ if pathinfo:
except Exception as err:
response.respond(500, {'message': 'Could not create voter ID: %s' % err})
+ elif action == "peek" and election:
+ try:
+ elpath = os.path.join(homedir, "issues", election)
+ if os.path.isdir(elpath):
+ basedata = {}
+ with open(elpath + "/basedata.json", "r") as f:
+ basedata = json.loads(f.read())
+ f.close()
+ if 'open' in basedata and basedata['open'] == "true":
+ if 'hash' in basedata:
+ del basedata['hash']
+ response.respond(200, { 'base_data': basedata } )
+ else:
+ response.respond(403, {'message': 'This election is not open to the public'})
+ else:
+ response.respond(404, {'message': 'Could not request data: No such election'})
+
+ except Exception as err:
+ response.respond(500, {'message': 'Could not load election data: %s' % err})
else:
response.respond(400, {'message': 'Invalid action supplied'})
else:
Modified: steve/trunk/pytest/www/htdocs/request_link.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/request_link.html?rev=1668244&r1=1668243&r2=1668244&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/request_link.html (original)
+++ steve/trunk/pytest/www/htdocs/request_link.html Sat Mar 21 11:43:27 2015
@@ -12,16 +12,24 @@
}, undefined,
function(code, response, state) { alert(response.message); }, null);
}
+ function electionCallback(code, response) {
+ if (code == 200) {
+ document.getElementById('title').innerHTML += " " + response.base_data.title
+ } else {
+ alert(response.message)
+ }
+
+ }
</script>
<title>Apache STeVe: Request link</title>
</head>
-<body>
+<body onload="getJSON('/steve/voter/peek/' + document.location.search.substr(1), null, electionCallback)" >
<p style="text-align: center;">
<img src="/images/steve_logo.png"/>
</p>
<div class="formbox">
- <h2>Request vote link:</h2>
+ <h2 id="title">Request vote link:</h2>
<p>
In open elections, anyone can request a voter ID and participate.
To receive a voter ID, please enter your email address in the field below and click 'Request link'.