mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
34 lines
918 B
Python
34 lines
918 B
Python
from flask import redirect, render_template, request, url_for, flash
|
|
from flask_security import auth_required, current_user
|
|
|
|
from advlabdb import app
|
|
from advlabdb.utils import setUserActiveSemester, userActiveSemester
|
|
|
|
|
|
@app.context_processor
|
|
def util_processor():
|
|
return dict(userActiveSemester=userActiveSemester)
|
|
|
|
|
|
@app.route("/")
|
|
def index():
|
|
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("/set_semester")
|
|
@auth_required()
|
|
def set_semester():
|
|
try:
|
|
semesterId = int(request.args.get("semester_id"))
|
|
except Exception as ex:
|
|
flash(str(ex), "error")
|
|
else:
|
|
setUserActiveSemester(semesterId)
|
|
|
|
red = request.referrer or url_for("index")
|
|
return redirect(red)
|