]> WPIA git - motion.git/commitdiff
Merge branch 'vote-button' into 'master'
authorFelix Dörre <felix@dogcraft.de>
Mon, 17 Aug 2020 16:16:37 +0000 (18:16 +0200)
committerFelix Dörre <felix@dogcraft.de>
Mon, 17 Aug 2020 16:16:37 +0000 (18:16 +0200)
add: button to reach vote / result page

See merge request felixdoerre/motion!15

motion.py
templates/motion.html
tests/test_motion.py

index df5db15b57e335e16a3cd4da5c0e6fc3edef779a..0314550cecba464f6103280dd4b84c335ed3f554 100644 (file)
--- a/motion.py
+++ b/motion.py
@@ -172,7 +172,7 @@ def main():
         else:
             prev = -1
     return render_template('index.html', motions=rv[:10], more=rv[10]["id"] if len(rv) == 11 else None, times=times.per_host, prev=prev,
-                           categories=get_allowed_cats("create"))
+                           categories=get_allowed_cats("create"), singlemotion=False)
 
 def rel_redirect(loc):
     r = redirect(loc)
@@ -230,7 +230,7 @@ def show_motion(motion):
     votes = None
     if may("audit", rv[0].get("type")) and not rv[0].get("running") and not rv[0].get("canceled"):
         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")(rv[0].get("id"));
-    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)
+    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, singlemotion=True)
 
 @app.route("/motion/<string:motion>/vote", methods=['POST'])
 def vote(motion):
index 9e7f2a8904779bbcae93e3979ab73ae18ef2bb89..a363c0e75ef433ede3469058369d949995595b50 100644 (file)
@@ -7,7 +7,11 @@
 ">
     <span class="title-text">{{motion.name}}</span> ({{ 'Running' if motion.running else ('Canceled' if motion.canceled != None else 'Finished') }})
     <span class="motion-type">{{motion.type}}</span>
-    <div># <a href="/motion/{{motion.identifier}}" class="anchor">{{motion.identifier}}</a></div>
+    <div># {{motion.identifier}}
+{%- if singlemotion == False %}
+    <a class="btn btn-primary" href="/motion/{{motion.identifier}}" role="button">{{ 'Vote' if motion.running else 'Result' }}</a>
+{%- endif %}
+    </div>
     <div class="date">
       <div>Proposed: {{motion.posed|timestamp}} (UTC) by {{motion.poser}}</div>
 {%- if motion.canceled != None %}
index bb4acf01ffab6970583e37101fecd655cd77c682..c1f996c3312966439f5bb4a5572cd5637372d350 100644 (file)
@@ -85,7 +85,9 @@ class GeneralTests(BasicTest):
         result = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True)
         testtext= '<div class="motion card" id="motion-3">\n  <div class="motion-title card-heading alert-warning">'\
             + '\n    <span class=\"title-text\">Motion C</span> (Canceled)\n    <span class=\"motion-type\">group1</span>'\
-            + '\n    <div># <a href=\"/motion/g1.20200402.003\" class=\"anchor\">g1.20200402.003</a></div>'\
+            + '\n    <div># g1.20200402.003'\
+            + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.003" role="button">Result</a>'\
+            + '\n    </div>'\
             + '\n    <div class=\"date\">\n      <div>Proposed: 2020-04-02 21:47:24 (UTC) by User A</div>'\
             + '\n      <div>Canceled: 2020-04-03 21:48:24 (UTC) by User A</div></div>\n  </div>'\
             + '\n  <div class=\"card-body\">\n    <p><p>A third motion</p></p>'\
@@ -96,7 +98,9 @@ class GeneralTests(BasicTest):
         self.assertIn(str.encode(testtext), result.data)
         testtext= '<div class="motion card" id="motion-2">\n  <div class="motion-title card-heading alert-danger">'\
             + '\n    <span class=\"title-text\">Motion B</span> (Finished)\n    <span class=\"motion-type\">group1</span>'\
-            + '\n    <div># <a href=\"/motion/g1.20200402.002\" class=\"anchor\">g1.20200402.002</a></div>'\
+            + '\n    <div># g1.20200402.002'\
+            + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.002" role="button">Result</a>'\
+            + '\n    </div>'\
             + '\n    <div class=\"date\">\n      <div>Proposed: 2020-04-02 21:41:26 (UTC) by User A</div>'\
             + '\n      <div>Votes until: 2020-04-04 21:41:26 (UTC)</div></div>\n  </div>'\
             + '\n  <div class=\"card-body\">\n    <p><p>A second motion</p></p>'\
@@ -106,7 +110,9 @@ class GeneralTests(BasicTest):
         self.assertIn(str.encode(testtext), result.data)
         testtext= '<div class=\"motion card\" id=\"motion-1\">\n  <div class=\"motion-title card-heading alert-success\">'\
             + '\n    <span class=\"title-text\">Motion A</span> (Finished)\n    <span class=\"motion-type\">group1</span>'\
-            + '\n    <div># <a href=\"/motion/g1.20200402.001\" class=\"anchor\">g1.20200402.001</a></div>'\
+            + '\n    <div># g1.20200402.001'\
+            + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.001" role="button">Result</a>'\
+            + '\n    </div>'\
             + '\n    <div class=\"date">\n      <div>Proposed: 2020-04-02 21:40:33 (UTC) by User A</div>'\
             + '\n      <div>Votes until: 2020-04-02 21:40:33 (UTC)</div></div>\n  </div>'\
             + '\n  <div class=\"card-body\">\n    <p><p>My special motion</p></p>'\
@@ -333,6 +339,8 @@ class CreateMotionTests(BasicTest):
         self.assertIn(str.encode(title), result.data)
         self.assertIn(str.encode(content), result.data)
         self.assertIn(str.encode('g1.'+datetime.today().strftime('%Y%m%d')+'.001'), result.data)
+        testtext='<a class=\"btn btn-primary" href=\"/motion/g1.'+datetime.today().strftime('%Y%m%d')+'.001\" role=\"button\">Vote</a>'
+        self.assertIn(str.encode(testtext), result.data)
 
         title='My Motion1'
         content='My body1'