From a53a0a3e8ad96f0805c05a45a06e15352dd45f72 Mon Sep 17 00:00:00 2001 From: INOPIAE Date: Sun, 24 May 2020 23:49:20 +0200 Subject: [PATCH] add: button to reach vote / result page --- motion.py | 4 ++-- templates/motion.html | 6 +++++- tests/test_motion.py | 14 +++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/motion.py b/motion.py index df5db15..0314550 100644 --- 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//vote", methods=['POST']) def vote(motion): diff --git a/templates/motion.html b/templates/motion.html index 9e7f2a8..a363c0e 100644 --- a/templates/motion.html +++ b/templates/motion.html @@ -7,7 +7,11 @@ "> {{motion.name}} ({{ 'Running' if motion.running else ('Canceled' if motion.canceled != None else 'Finished') }}) {{motion.type}} -
# {{motion.identifier}}
+
# {{motion.identifier}} +{%- if singlemotion == False %} + {{ 'Vote' if motion.running else 'Result' }} +{%- endif %} +
Proposed: {{motion.posed|timestamp}} (UTC) by {{motion.poser}}
{%- if motion.canceled != None %} diff --git a/tests/test_motion.py b/tests/test_motion.py index bb4acf0..c1f996c 100644 --- a/tests/test_motion.py +++ b/tests/test_motion.py @@ -85,7 +85,9 @@ class GeneralTests(BasicTest): result = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True) testtext= '
\n
'\ + '\n Motion C (Canceled)\n group1'\ - + '\n '\ + + '\n
# g1.20200402.003'\ + + '\n Result'\ + + '\n
'\ + '\n
\n
Proposed: 2020-04-02 21:47:24 (UTC) by User A
'\ + '\n
Canceled: 2020-04-03 21:48:24 (UTC) by User A
\n
'\ + '\n
\n

A third motion

'\ @@ -96,7 +98,9 @@ class GeneralTests(BasicTest): self.assertIn(str.encode(testtext), result.data) testtext= '
\n
'\ + '\n Motion B (Finished)\n group1'\ - + '\n '\ + + '\n
# g1.20200402.002'\ + + '\n Result'\ + + '\n
'\ + '\n
\n
Proposed: 2020-04-02 21:41:26 (UTC) by User A
'\ + '\n
Votes until: 2020-04-04 21:41:26 (UTC)
\n
'\ + '\n
\n

A second motion

'\ @@ -106,7 +110,9 @@ class GeneralTests(BasicTest): self.assertIn(str.encode(testtext), result.data) testtext= '
\n
'\ + '\n Motion A (Finished)\n group1'\ - + '\n '\ + + '\n
# g1.20200402.001'\ + + '\n Result'\ + + '\n
'\ + '\n
\n
Proposed: 2020-04-02 21:40:33 (UTC) by User A
'\ + '\n
Votes until: 2020-04-02 21:40:33 (UTC)
\n
'\ + '\n
\n

My special motion

'\ @@ -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='Vote' + self.assertIn(str.encode(testtext), result.data) title='My Motion1' content='My body1' -- 2.39.2