From 81457c2b7cc13b6df57220f848f19f77ff2458f2 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 19 Feb 2021 10:55:21 -0500 Subject: [PATCH] We can now limit the list of studies to a particular user. Created a new route /user_studies in __init__.py that takes a uva_id. Pulled out some dupllcate code into a new method; render_study_template In index.html, added a pulldown to select the user. I pull the list of users from the studies so we only show users that have studies. Added a script to process the selection. --- pb/__init__.py | 28 ++++++++++++++++++++++------ templates/index.html | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/pb/__init__.py b/pb/__init__.py index 46c7575..fd821d4 100644 --- a/pb/__init__.py +++ b/pb/__init__.py @@ -161,16 +161,32 @@ from pb.models import Study, RequiredDocument, Investigator, StudySchema, Requir from pb.ldap.ldap_service import LdapService +def render_study_template(studies): + table = StudyTable(studies) + users = [] + [users.append(study.NETBADGEID) for study in studies if study.NETBADGEID not in users] + return render_template( + 'index.html', + table=table, + base_href=BASE_HREF, + users=users + ) + + @app.route('/', methods=['GET', 'POST']) def index(): # display results studies = db.session.query(Study).order_by(Study.DATE_MODIFIED.desc()).all() - table = StudyTable(studies) - return render_template( - 'index.html', - table=table, - base_href=BASE_HREF - ) + return render_study_template(studies) + + +@app.route('/user_studies/', defaults={'uva_id': 'all'}) +@app.route('/user_studies/', methods=['GET']) +def user_studies(uva_id): + if uva_id == 'all': + return redirect(f"/") + studies = db.session.query(Study).filter(Study.NETBADGEID == uva_id).order_by(Study.DATE_MODIFIED.desc()).all() + return render_study_template(studies) @app.route('/new_study', methods=['GET', 'POST']) diff --git a/templates/index.html b/templates/index.html index a248e8e..8ec3a82 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,6 +16,18 @@

New Study

+

+ + +

{% with messages = get_flashed_messages(with_categories=True) %} {% if messages %} @@ -43,5 +55,15 @@ setTimeout(() => hideElement(alert), 3000); } +