1
0
forked from ScoDoc/ScoDoc

user_board: accès depuis accueil général

This commit is contained in:
Emmanuel Viennet 2023-12-31 22:59:09 +01:00
parent 97eb18361f
commit 1a5072a35c
3 changed files with 24 additions and 8 deletions

View File

@ -42,6 +42,15 @@
<li><a href="{{ url_for('entreprises.index') }}">Entreprises</a></li>
{% endif %}
</ul>
{% if not current_user.is_anonymous %}
<ul class="nav navbar-nav">
<li>
<a href="{{
url_for('scodoc.user_board', user_name=current_user.user_name)
}}">Tableau de bord</a>
</li>
</ul>
{% endif %}
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('auth.login') }}">connexion</a></li>
@ -92,7 +101,8 @@
<script src="{{scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<script src="{{scu.STATIC_DIR}}/js/scodoc.js"></script>
<script>
const SCO_URL = "{{ url_for('scolar.index_html', scodoc_dept=g.scodoc_dept)[:-11] }}";
const SCO_URL = "{% if g.scodoc_dept %}{{
url_for('scolar.index_html', scodoc_dept=g.scodoc_dept)[:-11] }}{% endif %}";
const SCO_TIMEZONE = "{{ scu.TIME_ZONE }}";
</script>
{% endblock %}

View File

@ -1,6 +1,6 @@
{# Tableau de bord utilisateur #}
{% extends "sco_page.j2" %}
{% extends "base.j2" %}
{% block app_content %}
<style>
@ -63,10 +63,12 @@
</style>
<div class="tab-content">
<h2>Votre tableau de bord, {{user.get_nomcomplet()}}</h2>
<h2>{{user.get_nomcomplet()}}</h2>
{% for dept_id in formsemestres_by_dept %}
<h3>Modules dans le département {{ dept_names[dept_id] }}</h3>
<h3>Modules dans le <a class="stdlink" href="{{
url_for('scolar.index_html', scodoc_dept=depts[dept_id].acronym)}}"
>département {{ dept_names[dept_id] }}</a></h3>
<div class="ub-formsemestres">
{% for formsemestre in formsemestres_by_dept[dept_id] %}
<div class="ub-formsemestre">

View File

@ -7,6 +7,7 @@ Emmanuel Viennet, 2023
from flask import flash, redirect, render_template, url_for
from flask import g, request
from flask_login import login_required
from app.auth.models import User
from app.decorators import (
scodoc,
@ -15,14 +16,13 @@ from app.decorators import (
from app.models import Departement, FormSemestre
from app.scodoc.sco_permissions import Permission
from app.scodoc import sco_preferences
from app.scodoc import sco_utils as scu
from app.views import scolar_bp as bp
from app.views import scodoc_bp as bp
from app.views import ScoData
@bp.route("/user_board/<string:user_name>")
@bp.route("/ScoDoc/user_board/<string:user_name>")
@scodoc
@permission_required(Permission.ScoView)
@login_required
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()
@ -30,6 +30,9 @@ def user_board(user_name: str):
formsemestres_by_dept,
modimpls_by_formsemestre,
) = FormSemestre.get_user_formsemestres_annee_by_dept(user)
depts = {
dept_id: Departement.query.get(dept_id) for dept_id in formsemestres_by_dept
}
dept_names = {
dept_id: sco_preferences.get_preference("DeptName", dept_id=dept_id)
for dept_id in formsemestres_by_dept
@ -41,6 +44,7 @@ def user_board(user_name: str):
# TODO: le calendrier avec ses enseignements
return render_template(
"user_board/user_board.j2",
depts=depts,
dept_names=dept_names_sorted,
formsemestres_by_dept=formsemestres_by_dept,
modimpls_by_formsemestre=modimpls_by_formsemestre,