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
|
2023-12-31 22:59:09 +01:00
|
|
|
from flask_login import login_required
|
2024-08-06 23:18:17 +02:00
|
|
|
from app import db
|
2023-12-29 13:58:18 +01:00
|
|
|
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-31 22:59:09 +01:00
|
|
|
from app.views import scodoc_bp as bp
|
2023-12-29 13:58:18 +01:00
|
|
|
from app.views import ScoData
|
|
|
|
|
|
|
|
|
2023-12-31 22:59:09 +01:00
|
|
|
@bp.route("/ScoDoc/user_board/<string:user_name>")
|
2023-12-29 13:58:18 +01:00
|
|
|
@scodoc
|
2023-12-31 22:59:09 +01:00
|
|
|
@login_required
|
2023-12-29 13:58:18 +01:00
|
|
|
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)
|
2023-12-31 22:59:09 +01:00
|
|
|
depts = {
|
2024-08-06 23:18:17 +02:00
|
|
|
dept_id: db.session.get(Departement, dept_id)
|
|
|
|
for dept_id in formsemestres_by_dept
|
2023-12-31 22:59:09 +01:00
|
|
|
}
|
2023-12-31 22:18:52 +01:00
|
|
|
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:59:09 +01:00
|
|
|
depts=depts,
|
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,
|
|
|
|
)
|