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); } +