Author: humbedooh
Date: Fri Mar 20 12:06:36 2015
New Revision: 1667991
URL: http://svn.apache.org/r1667991
Log:
Some updates:
- require a voter uid (hash) for viewing elections/issues (to be used later)
- redirect to yna or stv page depending on vote type
Modified:
steve/trunk/pytest/www/cgi-bin/rest_voter.py
steve/trunk/pytest/www/htdocs/js/steve_rest.js
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=1667991&r1=1667990&r2=1667991&view=diff
==============================================================================
--- steve/trunk/pytest/www/cgi-bin/rest_voter.py (original)
+++ steve/trunk/pytest/www/cgi-bin/rest_voter.py Fri Mar 20 12:06:36 2015
@@ -56,9 +56,11 @@ if pathinfo:
action = l[0]
election = l[1] if len(l) > 1 else None
issue = l[2] if len(l) > 2 else None
- voterid = l[3] if len(l) > 3 else None
+ voterid = form.getvalue('uid')
- if action == "view":
+ if not voterid:
+ response.respond(403, {'message': "Voter UID missing"})
+ elif action == "view":
# View a list of issues for an election
if election and not issue:
js = []
Modified: steve/trunk/pytest/www/htdocs/js/steve_rest.js
URL:
http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/js/steve_rest.js?rev=1667991&r1=1667990&r2=1667991&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/js/steve_rest.js (original)
+++ steve/trunk/pytest/www/htdocs/js/steve_rest.js Fri Mar 20 12:06:36 2015
@@ -181,7 +181,7 @@ function loadElection(election, uid) {
if (!election || !uid) {
var l = document.location.search.substr(1).split("/");
election = l[0];
- uid = l[1];
+ uid = l[1] ? l[1] : "";
}
if (step == 0) {
getJSON("/steve/voter/view/" + election + "?uid=" + uid,
[election,uid], displayElection)
@@ -209,7 +209,7 @@ function displayElection(code, response,
if (code == 200) {
window.setTimeout(renderElectionFrontpage, 2000, response, el);
} else {
- document.getElementById('preloaderWrapper').innerHTML =
"<h1>Sorry, no such election!</h1>"
+ document.getElementById('preloaderWrapper').innerHTML =
"<h1>Sorry, an error occured while fetching election data:</h1><h2>" +
response.message + "</h2>"
}
}
@@ -241,7 +241,7 @@ function renderElectionFrontpage(respons
inner.innerHTML = issue.id + ": " + issue.title;
outer.appendChild(no)
outer.appendChild(inner)
- outer.setAttribute("onclick", "location.href='ballot.html?" +
el[0] + "/" + issue.id + "/" + el[1] + "';")
+ outer.setAttribute("onclick", "location.href='ballot_" +
(issue.type == "yna" ? "yna" : "stv") + ".html?" + el[0] + "/" + issue.id + "/"
+ (el[1] ? el[1] : "") + "';")
outer.style.animation = "fadein " + (0.5 + (s/6)) + "s"
issueList.appendChild(outer)
}