2023-12-29 13:58:18 +01:00
|
|
|
"""
|
|
|
|
Tableau de bord utilisateur
|
|
|
|
|
|
|
|
Emmanuel Viennet, 2023
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
from flask import flash, redirect, render_template, url_for
|
|
|
|
from flask import g, request
|
|
|
|
from app.auth.models import User
|
|
|
|
from app.decorators import (
|
|
|
|
scodoc,
|
|
|
|
permission_required,
|
|
|
|
)
|
2023-12-31 22:18:52 +01:00
|
|
|
from app.models import Departement, FormSemestre
|
2023-12-29 13:58:18 +01:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2023-12-31 22:18:52 +01:00
|
|
|
from app.scodoc import sco_preferences
|
2023-12-29 13:58:18 +01:00
|
|
|
from app.scodoc import sco_utils as scu
|
|
|
|
from app.views import scolar_bp as bp
|
|
|
|
from app.views import ScoData
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/user_board/<string:user_name>")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def user_board(user_name: str):
|
|
|
|
"""Tableau de bord utilisateur: liens vers ses objets"""
|
|
|
|
user = User.query.filter_by(user_name=user_name).first_or_404()
|
2023-12-31 22:18:52 +01:00
|
|
|
(
|
|
|
|
formsemestres_by_dept,
|
|
|
|
modimpls_by_formsemestre,
|
|
|
|
) = FormSemestre.get_user_formsemestres_annee_by_dept(user)
|
|
|
|
dept_names = {
|
|
|
|
dept_id: sco_preferences.get_preference("DeptName", dept_id=dept_id)
|
|
|
|
for dept_id in formsemestres_by_dept
|
|
|
|
}
|
|
|
|
dept_names_sorted = {
|
|
|
|
dept_id: dept_name
|
|
|
|
for (dept_id, dept_name) in sorted(dept_names.items(), key=lambda x: x[1])
|
|
|
|
}
|
2023-12-29 13:58:18 +01:00
|
|
|
# TODO: le calendrier avec ses enseignements
|
|
|
|
return render_template(
|
|
|
|
"user_board/user_board.j2",
|
2023-12-31 22:18:52 +01:00
|
|
|
dept_names=dept_names_sorted,
|
|
|
|
formsemestres_by_dept=formsemestres_by_dept,
|
2023-12-29 13:58:18 +01:00
|
|
|
modimpls_by_formsemestre=modimpls_by_formsemestre,
|
|
|
|
sco=ScoData(),
|
|
|
|
title=f"{user.get_prenomnom()}: tableau de bord",
|
|
|
|
user=user,
|
|
|
|
)
|