]> WPIA git - motion.git/commitdiff
add: an user with 'audit' privilleges can view all votes
authorFelix Dörre <felix@dogcraft.de>
Thu, 23 Nov 2017 09:06:18 +0000 (10:06 +0100)
committerFelix Dörre <felix@dogcraft.de>
Thu, 23 Nov 2017 09:06:18 +0000 (10:06 +0100)
motion.py
templates/single_motion.html

index 783cf476fe7eca1b95766acedf4117b9534b217e..cef02eeac3b07e14438ac920ea9bc376c9b996b8 100644 (file)
--- a/motion.py
+++ b/motion.py
@@ -141,7 +141,10 @@ def show_motion(motion):
                          + "LEFT JOIN voter canceler ON canceler.id = motion.canceled_by "
                          + "WHERE motion.id=$1")
     rv = p(motion, g.voter)
-    return render_template('single_motion.html', motion=rv[0], may_vote=may("vote", rv[0].get("type")), may_cancel=may("cancel", rv[0].get("type")))
+    votes = None
+    if may("audit", rv[0].get("type")):
+        votes = get_db().prepare("SELECT vote.result, voter.email FROM vote INNER JOIN voter ON voter.id = vote.voter_id WHERE vote.motion_id=$1")(motion);
+    return render_template('single_motion.html', motion=rv[0], may_vote=may("vote", rv[0].get("type")), may_cancel=may("cancel", rv[0].get("type")), votes=votes)
 
 @app.route("/motion/<int:motion>/vote", methods=['POST'])
 def vote(motion):
index ac4ff79148bc4ef86292b5040f1611cbda0c8a75..a15e397d182744086b762f90fac08ab8d6d64efc 100644 (file)
@@ -4,6 +4,18 @@ Motion: {{motion.name}}
 {%- endblock %}
 {% block body %}
 {%- include 'motion.html' %}
+{%- if votes %}
+<div class="panel panel-info" id="votes">
+  <div class="panel-heading">
+    Motion Votes
+  </div>
+  <div class="panel-body">
+    {%- for row in votes %}
+    <div>{{row.email}}: {{row.result}}</div>
+    {%- endfor %}
+  </div>
+</div>
+{%- endif %}
 {%- if motion.running %}
 {%- if may_vote %}
 <form action="/motion/{{motion.id}}/vote" method="POST">