Added metas to vote view, added attachments table
[cavote.git] / main.py
diff --git a/main.py b/main.py
index bff42a0..8c050b8 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -233,12 +233,13 @@ def can_vote(idvote, iduser=-1):
 
 @app.route('/vote/<idvote>')
 def show_vote(idvote):
-    vote = query_db('select * from votes where id=?', [idvote], one=True)
+    vote = query_db('select *, roles.name as rolename from votes join roles on roles.id=votes.id_role where votes.id=?', [idvote], one=True)
     if vote is None:
         abort(404)
     if can_see_vote(idvote, session.get('user').get('id')):
         choices = query_db('select * from choices where id_vote=?', [idvote])
-        return render_template('vote.html', vote=vote, choices=choices, can_vote=can_vote(idvote, session.get('user').get('id')))
+        attachments = query_db('select * from attachments where id_vote=?', [idvote])
+        return render_template('vote.html', vote=vote, attachments=attachments, choices=choices, can_vote=can_vote(idvote, session.get('user').get('id')))
     flash('Vous n\'avez pas le droit de voir ce vote, désolé.')
     return(url_for('home'))