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/24 23:44:58 UTC
svn commit: r1669014 - in /steve/trunk/pysteve/www: cgi-bin/rest_admin.py
htdocs/admin/add_issue.html htdocs/js/steve_rest.js
Author: humbedooh
Date: Tue Mar 24 22:44:57 2015
New Revision: 1669014
URL: http://svn.apache.org/r1669014
Log:
make admin rest api show both types of votes and their desc.
use that for the add issue page
Modified:
steve/trunk/pysteve/www/cgi-bin/rest_admin.py
steve/trunk/pysteve/www/htdocs/admin/add_issue.html
steve/trunk/pysteve/www/htdocs/js/steve_rest.js
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=1669014&r1=1669013&r2=1669014&view=diff
==============================================================================
--- steve/trunk/pysteve/www/cgi-bin/rest_admin.py (original)
+++ steve/trunk/pysteve/www/cgi-bin/rest_admin.py Tue Mar 24 22:44:57 2015
@@ -521,9 +521,9 @@ else:
response.respond(404, {'message': 'No such election or issue'})
# Get registered vote stpye
elif action == "types":
- types = []
+ types = {}
for vtype in constants.VOTE_TYPES:
- types.append(vtype['key'])
+ types[vtype['key']] = vtype['description']
response.respond(200, {'types': types})
else:
Modified: steve/trunk/pysteve/www/htdocs/admin/add_issue.html
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/admin/add_issue.html?rev=1669014&r1=1669013&r2=1669014&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/admin/add_issue.html (original)
+++ steve/trunk/pysteve/www/htdocs/admin/add_issue.html Tue Mar 24 22:44:57 2015
@@ -8,7 +8,10 @@
<script src="/js/jquery-ui.js" type="text/javascript"></script>
<title>Add issue</title>
</head>
-<body onload="document.getElementById('iid').value = parseInt(Math.random()*987654321).toString(16).toLowerCase();">
+<body onload="
+ document.getElementById('iid').value = parseInt(Math.random()*987654321).toString(16).toLowerCase();
+ getJSON('/steve/admin/types', null, setVoteTypes);
+ ">
<p style="text-align: center;">
<img src="/images/steve_logo.png"/>
</p>
@@ -27,18 +30,9 @@
</div>
<div class="keyvaluepair">
<div class="keyfield">Issue type:</div>
- <select id="type" onchange="changeSTVType(this.value)">
+ <select id="type" name="type" onchange="changeSTVType(this.value)">
<option value="">------</option>
- <option value="yna">YNA (Yes/No/Abstain)</option>
- <option value="stv1">STV with 1 seat</option>
- <option value="stv2">STV with 2 seats</option>
- <option value="stv3">STV with 3 seats</option>
- <option value="stv4">STV with 4 seats</option>
- <option value="stv5">STV with 5 seats</option>
- <option value="stv6">STV with 6 seats</option>
- <option value="stv7">STV with 7 seats</option>
- <option value="stv8">STV with 8 seats</option>
- <option value="stv9">STV with 9 seats</option>
+
</select>
<br>
</div>
Modified: steve/trunk/pysteve/www/htdocs/js/steve_rest.js
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/js/steve_rest.js?rev=1669014&r1=1669013&r2=1669014&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/js/steve_rest.js (original)
+++ steve/trunk/pysteve/www/htdocs/js/steve_rest.js Tue Mar 24 22:44:57 2015
@@ -958,4 +958,25 @@ function primeMonitors() {
undefined,
primeMonitorsCallback,
election)
+}
+
+function setVoteTypes(code, response, state) {
+ if (code == 200) {
+ var tobj = document.getElementById('type');
+ var sortable = []
+ for (i in response.types) {
+ var type = response.types[i]
+ var option = document.createElement("option");
+ option.text = type;
+ option.value = i;
+ sortable.push([option, type])
+ }
+ sortable.sort(function(a,b) { return (a[1] > b[1])})
+ for (i in sortable) {
+ tobj.add(sortable[i][0])
+ }
+ } else {
+ alert(response.message)
+ }
+
}
\ No newline at end of file