Votes list
[cavote.git] / main.py
diff --git a/main.py b/main.py
index 8c050b8..8a99adb 100755 (executable)
--- a/main.py
+++ b/main.py
@@ -29,7 +29,7 @@ def teardown_request(exception):
 
 @app.route('/')
 def home():
-    return render_template('index.html')
+    return render_template('index.html', active_button="home")
 
 def query_db(query, args=(), one=False):
     cur = g.db.execute(query, args)
@@ -206,15 +206,17 @@ def del_role(idrole):
 @app.route('/votes/<votes>')
 def show_votes(votes):
     today = date.today()
+    active_button = votes
+    basequery = 'select *, roles.name as rolename from votes join roles on roles.id=votes.id_role'
     if votes == 'all':
-        votes = query_db('select * from votes order by id desc')
+        votes = query_db(basequery + ' order by id desc')
     elif votes == 'archive':
-        votes = query_db('select * from votes where date_end < (?) order by id desc', [today])
+        votes = query_db(basequery + ' where date_end < (?) order by id desc', [today])
     elif votes == 'current':
-        votes = query_db('select * from votes where date_end >= (?) order by id desc', [today])
+        votes = query_db(basequery + ' where date_end >= (?) order by id desc', [today])
     else:
         abort(404)
-    return render_template('show_votes.html', votes=votes)
+    return render_template('show_votes.html', votes=votes, active_button=active_button)
 
 #------
 # Vote