From acebc8ab08f30faea91ecec795e505568b9a80ec Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 10 Dec 2021 00:54:57 +0100 Subject: [PATCH] page infos UE + qq corrections --- app/models/formsemestre.py | 21 ++++- app/models/notes.py | 5 +- app/scodoc/sco_edit_apc.py | 42 +++++++++- app/static/css/scodoc.css | 2 +- app/templates/formsemestre_header.html | 47 ++++++----- app/templates/pn/form_ues.html | 9 ++- app/templates/pn/ue_infos.html | 64 +++++++++++++++ app/views/notes.py | 10 +++ .../730ac71eea23_index_on_validations.py | 78 +++++++++++++++++++ 9 files changed, 246 insertions(+), 32 deletions(-) create mode 100644 app/templates/pn/ue_infos.html create mode 100644 migrations/versions/730ac71eea23_index_on_validations.py diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 343e7689..a35f511c 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -3,7 +3,6 @@ """ScoDoc models: formsemestre """ import datetime -from typing import Any import flask_sqlalchemy @@ -13,9 +12,7 @@ from app.models import SHORT_STR_LEN from app.models import CODE_STR_LEN from app.models import UniteEns -import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc import sco_evaluation_db from app.models.ues import UniteEns from app.models.modules import Module from app.models.moduleimpls import ModuleImpl @@ -216,6 +213,22 @@ class FormSemestre(db.Model): "-".join((imputation_dept, parcours_name, modalite, semestre_id, annee_sco)) ) + def titre_mois(self) -> str: + """Le titre et les dates du semestre, pour affichage dans des listes + Ex: "BUT QLIO (PN 2022) semestre 1 FI (Sept 2022 - Jan 2023)" + """ + return f"""{self.titre_num()} {self.modalite or ''} ({ + scu.MONTH_NAMES_ABBREV[self.date_debut.month-1]} { + self.date_debut.year} - { + scu.MONTH_NAMES_ABBREV[self.date_fin.month -1]} { + self.date_fin.year})""" + + def titre_num(self) -> str: + """Le titre est le semestre, ex ""DUT Informatique semestre 2"" """ + if self.semestre_id == sco_codes_parcours.NO_SEMESTRE_ID: + return self.titre + return f"{self.titre} {self.formation.get_parcours().SESSION_NAME} {self.semestre_id}" + # Association id des utilisateurs responsables (aka directeurs des etudes) du semestre notes_formsemestre_responsables = db.Table( @@ -238,7 +251,7 @@ class FormsemestreEtape(db.Model): db.Integer, db.ForeignKey("notes_formsemestre.id"), ) - etape_apo = db.Column(db.String(APO_CODE_STR_LEN)) + etape_apo = db.Column(db.String(APO_CODE_STR_LEN), index=True) def __repr__(self): return f"" diff --git a/app/models/notes.py b/app/models/notes.py index 98fe5f5a..c196596f 100644 --- a/app/models/notes.py +++ b/app/models/notes.py @@ -52,16 +52,19 @@ class ScolarFormsemestreValidation(db.Model): etudid = db.Column( db.Integer, db.ForeignKey("identite.id"), + index=True, ) formsemestre_id = db.Column( db.Integer, db.ForeignKey("notes_formsemestre.id"), + index=True, ) ue_id = db.Column( db.Integer, db.ForeignKey("notes_ue.id"), + index=True, ) - code = db.Column(db.String(CODE_STR_LEN), nullable=False) + code = db.Column(db.String(CODE_STR_LEN), nullable=False, index=True) # NULL pour les UE, True|False pour les semestres: assidu = db.Column(db.Boolean) event_date = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) diff --git a/app/scodoc/sco_edit_apc.py b/app/scodoc/sco_edit_apc.py index 00603ce3..3e23414c 100644 --- a/app/scodoc/sco_edit_apc.py +++ b/app/scodoc/sco_edit_apc.py @@ -25,12 +25,14 @@ """Édition formation APC (BUT) """ import flask -from flask import url_for, render_template +from flask import url_for +from flask.templating import render_template from flask import g, request from flask_login import current_user -from app.models import Formation, UniteEns, Matiere, Module -import app.scodoc.notesdb as ndb +from app import db +from app.models import Formation, UniteEns, Matiere, Module, FormSemestre, ModuleImpl +from app.models.notes import ScolarFormsemestreValidation import app.scodoc.sco_utils as scu from app.scodoc import sco_groups from app.scodoc.sco_utils import ModuleType @@ -135,3 +137,37 @@ def html_edit_formation_apc( ] return "\n".join(H) + + +def html_ue_infos(ue): + """page d'information sur une UE""" + from app.views import ScoData + + formsemestres = ( + db.session.query(FormSemestre) + .filter( + ue.id == Module.ue_id, + Module.id == ModuleImpl.module_id, + FormSemestre.id == ModuleImpl.formsemestre_id, + ) + .all() + ) + nb_etuds_valid_ue = ScolarFormsemestreValidation.query.filter_by( + ue_id=ue.id + ).count() + can_safely_be_suppressed = ( + (nb_etuds_valid_ue == 0) + and (len(formsemestres) == 0) + and ue.modules.count() == 0 + and ue.matieres.count() == 0 + ) + return render_template( + "pn/ue_infos.html", + # "pn/tmp.html", + titre=f"UE {ue.acronyme} {ue.titre}", + ue=ue, + formsemestres=formsemestres, + nb_etuds_valid_ue=nb_etuds_valid_ue, + can_safely_be_suppressed=can_safely_be_suppressed, + sco=ScoData(), + ) diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index c5a43d62..cc2ea27a 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -1672,7 +1672,7 @@ ul.notes_module_list { font-style: normal; } -.notes_ue_list a.discretelink, .notes_ue_list a.stdlink { +.notes_ue_list a.stdlink { color: #001084; text-decoration: underline; } diff --git a/app/templates/formsemestre_header.html b/app/templates/formsemestre_header.html index 3dbe9e7d..bb68e513 100644 --- a/app/templates/formsemestre_header.html +++ b/app/templates/formsemestre_header.html @@ -2,34 +2,39 @@
- {{sco.sem.titre}} - - {% if sco.sem.semestre_id != -1 %}, {{sco.sem.formation.get_parcours().SESSION_NAME}} {{sco.sem.semestre_id}} - {% endif %} - {% if sco.sem.modalite %} en {{sco.sem.modalite}}{% endif %} + + {% if sco.sem.semestre_id != -1 %}, {{sco.sem.formation.get_parcours().SESSION_NAME}} + {{sco.sem.semestre_id}} + {% endif %} + {% if sco.sem.modalite %} en {{sco.sem.modalite}}{% endif %} - {{sco.scu.MONTH_NAMES_ABBREV[ sco.sem.date_debut.month]}} {{sco.sem.date_debut.year}} - {{sco.scu.MONTH_NAMES_ABBREV[sco.sem.date_fin.month]}} {{sco.sem.date_fin.year}} + {{sco.scu.MONTH_NAMES_ABBREV[ sco.sem.date_debut.month - 1]}} + {{sco.sem.date_debut.year}} - {{sco.scu.MONTH_NAMES_ABBREV[sco.sem.date_fin.month - 1]}} + {{sco.sem.date_fin.year}} {{sco.sem.responsables_str()}} - {{sco.sem.inscriptions|length}} inscrits{% if sco.sem.etat %}{{sco.scu.icontag("lock_img", border="0", title="Semestre verrouillé")|safe}}{% endif %} - {% if sco.prefs["bul_display_publication"] %} - - {% if sco.sem.bul_hide_xml %} - {{ sco.scu.icontag("hide_img", border="0", title="Bulletins NON publiés")|safe}} - {% else %} - {{ sco.scu.icontag("eye_img", border="0", title="Bulletins publiés")|safe }} - {% endif %} - {% endif %} + title="{{sco.sem.responsables_str(abbrev_prenom=False)}}">{{sco.sem.responsables_str()}} + {{sco.sem.inscriptions|length}} inscrits{% if + sco.sem.etat %}{{sco.scu.icontag("lock_img", border="0", title="Semestre + verrouillé")|safe}}{% endif %} + {% if sco.prefs["bul_display_publication"] %} + + {% if sco.sem.bul_hide_xml %} + {{ sco.scu.icontag("hide_img", border="0", title="Bulletins NON publiés")|safe}} + {% else %} + {{ sco.scu.icontag("eye_img", border="0", title="Bulletins publiés")|safe }} + {% endif %} + {% endif %}
- + {{ sco.sem_menu_bar|safe }}
\ No newline at end of file diff --git a/app/templates/pn/form_ues.html b/app/templates/pn/form_ues.html index 1d795be2..be0af6c3 100644 --- a/app/templates/pn/form_ues.html +++ b/app/templates/pn/form_ues.html @@ -4,7 +4,9 @@ {% for semestre_idx in semestre_ids %}
Semestre S{{semestre_idx}}