Fixed hardcoded vote publisher value to maethor
[cavote.git] / main.py
diff --git a/main.py b/main.py
index 6b391c3..dc2259d 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -92,6 +92,8 @@ def login():
         else:
             connect_user(user)
             flash(u'Vous êtes connecté. Bienvenue, %s !' % user['name'], 'success')
+            if request.args.get('continue'):
+                return redirect(request.args['continue'])
             return redirect(url_for('home'))
     return render_template('login.html')
 
@@ -99,6 +101,8 @@ def login():
 def logout():
     disconnect_user()
     flash(u'Vous avez été déconnecté.', 'info')
+    if request.args.get('continue') and not "admin" in request.args.get('continue'):
+        return redirect(request.args['continue'])
     return redirect(url_for('home'))
 
 #-----------------
@@ -120,7 +124,7 @@ def password_lost():
                 "From: %s" % EMAIL,
                 "To: %s" % user['email'],
                 "Subject: [Cavote] Password lost",
-                "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
+                "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()).decode('utf-8'),
                 "X-Mailer: %s" % VERSION,
                 "",
                 "You have lost your password.",
@@ -250,7 +254,7 @@ def admin_user_add():
                             "From: %s" % EMAIL,
                             "To: %s" % user['email'],
                             "Subject: [Cavote] Welcome",
-                            "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
+                            "Date: %s" % time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()).decode('utf-8'),
                             "X-Mailer: %s" % VERSION,
                             "",
                             "Hi %s!" % user['name'],
@@ -377,7 +381,7 @@ def votes(votes):
     basequery = 'select votes.*, max_votes from votes left join (' + max_votes + ') as max_votes on votes.id_group = max_votes.id_group'
     nb_votes = 'select id_vote, count(*) as nb_votes from (select id_user, id_vote from user_choice join choices on id_choice = choices.id group by id_user, id_vote) group by id_vote'
     basequery = 'select * from (' + basequery + ') left join (' + nb_votes + ') on id = id_vote'
-    basequery = 'select *, votes.id as voteid, groups.name as groupname from (' + basequery + ') as votes join groups on groups.id = id_group where is_open=1'
+    basequery = 'select *, votes.id as voteid, groups.name as groupname, users.name as author from (' + basequery + ') as votes join groups on groups.id = id_group join users on users.id = id_author where is_open=1'
     if votes == 'all':
         votes = query_db(basequery + ' order by date_end')
     elif votes == 'archive':