@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)
@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
@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'))