+#------
+# Vote
+
+def can_see_vote(idvote, iduser=-1):
+ user = query_db('select * from users where id=?', [iduser], one=True)
+ vote = query_db('select * from votes where id=?', [idvote], one=True)
+ if user is None and not vote.is_public:
+ return False
+ return True # :TODO:maethor:20120529: Check others things
+
+def can_vote(idvote, iduser=-1):
+ if not can_see_vote(idvote, iduser):
+ return False
+ return True # :TODO:maethor:20120529: Check others things
+
+@app.route('/vote/<idvote>')
+def show_vote(idvote):
+ vote = query_db('select * from votes where 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')))
+ flash('Vous n\'avez pas le droit de voir ce vote, désolé.')
+ return(url_for('home'))
+