X-Git-Url: http://git.cyclocoop.org/?p=cavote.git;a=blobdiff_plain;f=main.py;fp=main.py;h=fde382fbfdf05939073b81202443ab305f6d62f5;hp=ccb7229ce6a47f90ad5db544a190f6cfb4dd3d4f;hb=ce16da78f97de079b797276db9d1248507f996dd;hpb=f2c5f4be15b6225e5e7d9f3c53084424beb32f1b diff --git a/main.py b/main.py index ccb7229..fde382f 100755 --- a/main.py +++ b/main.py @@ -674,7 +674,10 @@ def admin_votes(): votes = query_db('select *, votes.id as voteid, groups.name as groupname from votes \ join groups on groups.id=votes.id_group \ where is_hidden=0 order by id desc') - return render_template('admin_votes.html', votes=votes, today=date.today().strftime("%Y-%m-%d")) + return render_template('admin_votes.html', votes=votes + , today=date.today().strftime("%Y-%m-%d") + , can_delete_votes=CAN_DELETE_VOTES + ) @app.route('/admin/votes/add', methods=['GET', 'POST']) def admin_vote_add(): @@ -828,11 +831,13 @@ def admin_vote_edit(voteid): def admin_vote_del(idvote): if not session.get('user').get('is_admin'): abort(401) - vote = query_db('select * from votes where id = ?', [idvote], one=True) - if vote is None: - abort(404) - g.db.execute('update votes set is_hidden=1 where id = ?', [idvote]) - g.db.commit() + if not CAN_DELETE_VOTES: + flash(u'La configuration interdit la suppression des votes.', 'error') + else: + if vote is None: + abort(404) + g.db.execute('update votes set is_hidden=1 where id = ?', [idvote]) + g.db.commit() return redirect(url_for('admin_votes')) @app.route('/admin/votes/addchoice/', methods=['POST'])