Commit 5d011e3e authored by Tangui's avatar Tangui

Ajout d'une route pour obtenir un parlementaire à solliciter au hasard

parent 14006432
......@@ -8,6 +8,7 @@ from flask import (flash, redirect, render_template, request, session, url_for)
from flask_mail import Mail, Message
from sqlalchemy.orm import joinedload
from sqlalchemy.sql.expression import case, func
from ..models import Action, Parlementaire, User, db
from ..models.constants import (ETAPE_A_CONFIRMER, ETAPE_A_ENVOYER,
......@@ -43,6 +44,19 @@ def setup_routes(app):
mail = Mail(app)
files_root = os.path.join(app.config['DATA_DIR'], 'files')
@app.route('/hasard', endpoint='hasard')
def hasard():
parl = Parlementaire.query \
.filter(Parlementaire.etape == ETAPE_A_ENVOYER) \
.order_by(func.random()) \
if not parl:
parl = Parlementaire.query \
.order_by(func.random()) \
return redirect(url_for('parlementaire',
@app.route('/parlementaires', endpoint='parlementaires')
def parlementaires():
qs = Parlementaire.query.options(joinedload(Parlementaire.groupe)) \
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment