Browse Source

Fix issue with publisher

Arnaud Delcasse 12 years ago
parent
commit
3884468d1f
1 changed files with 6 additions and 1 deletions
  1. 6 1
      main.py

+ 6 - 1
main.py

@@ -432,7 +432,7 @@ def has_voted(idvote, iduser=-1):
 
 
 @app.route('/vote/<idvote>', methods=['GET', 'POST'])
 @app.route('/vote/<idvote>', methods=['GET', 'POST'])
 def vote(idvote):
 def vote(idvote):
-    vote = query_db('select votes.*, groups.name as groupname, users.name as author from votes join groups on groups.id=votes.id_group join users on users.id = id_author where votes.id=?', [idvote], one=True)
+    vote = query_db('select votes.*, groups.name as groupname from votes join groups on groups.id=votes.id_group where votes.id=?', [idvote], one=True)
     if vote is None:
     if vote is None:
         abort(404)
         abort(404)
     if can_see_vote(idvote, get_userid()):
     if can_see_vote(idvote, get_userid()):
@@ -478,6 +478,11 @@ def vote(idvote):
                 vote['percent'] = int((float(vote['nb_votes']) / float(vote['max_votes'])) * 100)
                 vote['percent'] = int((float(vote['nb_votes']) / float(vote['max_votes'])) * 100)
         if query_db('select * from user_group where id_group = ? and id_user = ?', [vote['id_group'], get_userid()], one=True) and not vote['is_terminated']:
         if query_db('select * from user_group where id_group = ? and id_user = ?', [vote['id_group'], get_userid()], one=True) and not vote['is_terminated']:
             flash(u'Ce vote vous concerne !', 'info')
             flash(u'Ce vote vous concerne !', 'info')
+        publisher = query_db("select name from users where id = ?", [vote['id_author']], one=True)
+        if publisher is None:
+            vote['author'] = "NDN"
+        else:
+            vote['author'] = publisher['name']
         return render_template('vote.html', vote=vote, attachments=attachments, choices=choices, users=users.values(), can_vote=can_vote(idvote, get_userid()))
         return render_template('vote.html', vote=vote, attachments=attachments, choices=choices, users=users.values(), can_vote=can_vote(idvote, get_userid()))
     flash(u'Vous n\'avez pas le droit de voir ce vote, désolé.')
     flash(u'Vous n\'avez pas le droit de voir ce vote, désolé.')
     return redirect(url_for('home'))
     return redirect(url_for('home'))