From: Felix Dörre Date: Fri, 18 Dec 2020 21:29:45 +0000 (+0100) Subject: Merge branch 'finish' into 'master' X-Git-Url: https://code.wpia.club/?p=motion.git;a=commitdiff_plain;h=7102b6e5ec7d3ef39627106f273ddc3ae2fa705d;hp=698cc152cd39d911f6f21410e234b92dcd575c1c Merge branch 'finish' into 'master' fix: missing finish button, some unit tests See merge request felixdoerre/motion!24 --- diff --git a/.gitignore b/.gitignore index 1b9d93c..5792f88 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ messages.pot messages.mo messages.po +/python_tests_xml diff --git a/motion.py b/motion.py index 8eaa350..e878616 100644 --- a/motion.py +++ b/motion.py @@ -372,7 +372,7 @@ def show_motion(motion): if may("audit", resultmotion[0].get("type")) and not resultmotion[0].get("running") and not resultmotion[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")(resultmotion[0].get("id")); votes = get_db().prepare("SELECT vote.result, voter.email, CASE voter.email WHEN proxy.email THEN NULL ELSE proxy.email END as proxyemail FROM vote INNER JOIN voter ON voter.id = vote.voter_id INNER JOIN voter as proxy ON proxy.id = vote.proxy_id WHERE vote.motion_id=$1")(resultmotion[0].get("id")); - return render_template('single_motion.html', motion=resultmotion[0], may_vote=may("vote", resultmotion[0].get("type")), may_cancel=may("cancel", resultmotion[0].get("type")), votes=votes, proxyvote=resultproxyvote, proxyname=resultproxyname, languages=get_languages()) + return render_template('single_motion.html', motion=resultmotion[0], may_vote=may("vote", resultmotion[0].get("type")), may_cancel=may("cancel", resultmotion[0].get("type")), may_finish=may("finish", resultmotion[0].get("type")), votes=votes, proxyvote=resultproxyvote, proxyname=resultproxyname, languages=get_languages()) @app.route("/motion//vote/", methods=['POST']) @validate_motion_access_vote('vote') diff --git a/tests/test_motion.py b/tests/test_motion.py index b4ba907..2b95b1e 100644 --- a/tests/test_motion.py +++ b/tests/test_motion.py @@ -400,6 +400,19 @@ class CreateMotionTests(BasicTest): self.assertEqual(response.status_code, 403) self.assertIn(str.encode('Forbidden'), response.data) + def test_SeeCancelMotion(self): + self.db_sampledata() + + motion='g1.20200402.004' + result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True) + testtext= '' + self.assertIn(str.encode(testtext), result.data) + + motion='g1.20200402.004' + result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True) + testtext= '' + self.assertNotIn(str.encode(testtext), result.data) + def test_cancelMotion(self): self.db_sampledata() @@ -432,6 +445,19 @@ class CreateMotionTests(BasicTest): self.assertEqual(response.status_code, 403) self.assertIn(str.encode('Error, motion was canceled'), response.data) + def test_SeeFinishMotion(self): + self.db_sampledata() + + motion='g1.20200402.004' + result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True) + testtext= '' + self.assertIn(str.encode(testtext), result.data) + + motion='g1.20200402.004' + result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True) + testtext= '' + self.assertNotIn(str.encode(testtext), result.data) + def test_finishMotion(self): self.db_sampledata()