From 810a3ba496c05acd2069e78e8d1b9b9181b52c07 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 17 May 2021 22:15:50 +0200 Subject: [PATCH] Added redirecting after login --- advlabdb/modelViews.py | 2 +- advlabdb/routes.py | 8 ++++++-- advlabdb/templates/index.html | 4 ---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/advlabdb/modelViews.py b/advlabdb/modelViews.py index fa4e30e..b99fc1f 100644 --- a/advlabdb/modelViews.py +++ b/advlabdb/modelViews.py @@ -167,7 +167,7 @@ admin.add_view(UserModelView(User, db.session)) admin.add_view(RoleModelView(Role, db.session)) with app.app_context(): - semesters = Semester.query.all() + semesters = Semester.query.all()[::-1] for semester in semesters: admin.add_link(MenuLink(name=semester.label, url=url_for("set_semester") + "?semester_id=" + str(semester.id), diff --git a/advlabdb/routes.py b/advlabdb/routes.py index 4a5e935..8863c6c 100644 --- a/advlabdb/routes.py +++ b/advlabdb/routes.py @@ -56,8 +56,12 @@ def util_processor(): @app.route("/") def index(): - return render_template("index.html", - ) + if current_user.has_role("admin"): + return redirect(url_for("index") + "admin") + elif current_user.has_role("assistant"): + return redirect(url_for("index") + "assistant") + else: + return render_template("index.html") """ @app.route("/assistants") diff --git a/advlabdb/templates/index.html b/advlabdb/templates/index.html index da9e131..a05b433 100644 --- a/advlabdb/templates/index.html +++ b/advlabdb/templates/index.html @@ -2,8 +2,4 @@ {% extends "layout.html" %} {% block content %} Welcome to AdvLabDB! - -
- -Go to /admin {% endblock content %}