From: Guillaume Subiron Date: Tue, 5 Jun 2012 14:36:09 +0000 (+0200) Subject: Debug X-Git-Url: https://git.cyclocoop.org/admin/%7B%24www_url%7Dadmin/%27.%20sinon%28find_in_path%28%27css/leaflet.markercluster.css%27%29%2Cfind_in_path%28_DIR_LIB_GIS.%27plugins/%40%20%27info_desinstaller_plugin%27%20=%3E%20%27%20deactivates%20the%20plugin%20and%20deletes%20the%20data%27%2C%20%27info_discussion_cours%27%20=%3E%20%27Current%20discussions%27%2C%20%27info_ecrire_article%27%20=%3E%20%27Before%20writing%20any%20articles%2C%20you%20must%20create%20at%20least%20one%20section.%27%2C-%27info_email_envoi%27%20=%3E%20%27Sender/%27s%20email%20address%20%28optional%29%27%2C-%27info_email_envoi_txt%27%20=%3E%20%27Enter%20the%20sender/%27s%20email%20address%20used%20for%20sending%20emails%20%28by%20default%2C%20the%20recipient/%27s%20address%20is%20used%20as%20the%20sender/%27s%20address%29%C3%82%C2%A0:%27%2C-%27info_email_webmestre%27%20=%3E%20%27Webmaster/%27s%20email%20address%27%2C%20%27info_email_envoi%27%20=%3E%20%27Sender%C3%A2%C2%80%C2%99s%20email%20address%20%28optional%29%27%2C%20%27info_email_envoi_txt%27%20=%3E%20%27Enter%20the%20sender%C3%A2%C2%80%C2%99s%20email%20address%20used%20for%20sending%20emails%20%28by%20default%2C%20the%20recipient%C3%A2%C2%80%C2%99s%20address%20is%20used%20as%20the%20sender%C3%A2%C2%80%C2%99s%20address%29%C3%82%C2%A0:%27%2C%20%27info_email_webmestre%27%20=%3E%20%27Webmaster%C3%A2%C2%80%C2%99s%20email%20address%27%2C%20%27info_entrer_code_alphabet%27%20=%3E%20%27Enter%20the%20code%20of%20the%20character%20set%20to%20be%20used:%27%2C%20%27info_envoi_email_automatique%27%20=%3E%20%27Automated%20mailing%27%2C%20%27info_envoyer_maintenant%27%20=%3E%20%27Send%20now%27%2C%40%40%20-340%2C8%20%20340%2C8%20%40%40%20Do%20not%20submit%20this%20import%20request.%3Cp%3EFor%20more%20information%2C%20please%20see%20%3Ca%20href=?a=commitdiff_plain;h=16be4472e8582f8d8d966b625165ef2e57fc21df;p=cavote.git Debug --- diff --git a/main.py b/main.py index 51af2a9..c276c37 100755 --- a/main.py +++ b/main.py @@ -89,7 +89,7 @@ def login(): if request.method == 'POST': user = valid_login(request.form['username'], request.form['password']) if user is None: - flash('Email ou mot de passe invalide.', 'error') + flash(u'Email ou mot de passe invalide.', 'error') else: connect_user(user) flash(u'Vous êtes connecté. Bienvenue, %s !' % user['name'], 'success') @@ -99,7 +99,7 @@ def login(): @app.route('/logout') def logout(): disconnect_user() - flash('Vous avez été déconnecté.', 'info') + flash(u'Vous avez été déconnecté.', 'info') return redirect(url_for('home')) #----------------- @@ -362,7 +362,7 @@ def can_vote(idvote, iduser=-1): vote = query_db('select * from votes where id=?', [idvote], one=True) if vote is None: return False - if vote['is_finished'] == 0: + if vote['is_terminated'] == 0: if iduser > 0: if can_see_vote(idvote, iduser): if not has_voted(idvote, iduser): @@ -382,14 +382,18 @@ def vote(idvote): if can_see_vote(idvote, get_userid()): if request.method == 'POST': if can_vote(idvote, get_userid()): - choices = query_db('select name, id from choices where id_vote=?', [idvote]) - for choice in choices: - if str(choice['id']) in request.form.keys(): + if vote['is_multiplechoice'] == 0: + if query_db('select * from choices where id = ?', [request.form['choice']], one=True) is not None: g.db.execute('insert into user_choice (id_user, id_choice) values (?, ?)', - [session.get('user').get('id'), choice['id']]) + [session.get('user').get('id'), request.form['choice']]) g.db.commit() - if vote['is_multiplechoice'] == 0: - break + else: + choices = query_db('select name, id from choices where id_vote=?', [idvote]) + for choice in choices: + if str(choice['id']) in request.form.keys(): + g.db.execute('insert into user_choice (id_user, id_choice) values (?, ?)', + [session.get('user').get('id'), choice['id']]) + g.db.commit() else: abort(401) tuples = query_db('select choiceid, choicename, users.id as userid, users.name as username from (select choices.id as choiceid, choices.name as choicename, id_user as userid from choices join user_choice on choices.id = user_choice.id_choice where id_vote = ?) join users on userid = users.id', [idvote]) diff --git a/templates/vote.html b/templates/vote.html index 8c0f3e1..44469ad 100644 --- a/templates/vote.html +++ b/templates/vote.html @@ -44,11 +44,11 @@ {% if vote.is_multiplechoice %} {% for choice in choices %} - + {% endfor %} {% else %} {% for choice in choices %} - + {% endfor %} {% endif %}