def vote_all(): if 'osm_token' not in session or config.STAGE != 'voting': return redirect(url_for('login')) uid = session['osm_uid'] # Delete current votes to replace by with the new ones q = Vote.delete().where((Vote.user == uid) & (~Vote.preliminary)) q.execute() for nom in config.NOMINATIONS: votes = request.form.getlist('vote_{}'.format(nom)) for vote in votes: v = Vote() v.nominee = Nominee.get(Nominee.id == int(vote)) v.user = uid v.preliminary = False v.save() flash(g.lang['thanksvoted']) return redirect(url_for('voting'))