From 4e1811e6090f5220a62ceadf4ce4e4db21fb803e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 9 Jan 2022 21:02:07 +0100 Subject: [PATCH] WIP: misc bonus sport --- app/comp/res_common.py | 17 +++++++++++------ app/models/etudiants.py | 7 +++++++ app/scodoc/sco_bac.py | 2 +- app/static/css/scodoc.css | 7 +++++-- app/templates/pn/form_ues.html | 2 ++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 01549fdaf..7a922cf6a 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -35,7 +35,7 @@ class ResultatsSemestre: ) def __init__(self, formsemestre: FormSemestre): - self.formsemestre = formsemestre + self.formsemestre: FormSemestre = formsemestre # BUT ou standard ? (apc == "approche par compétences") self.is_apc = formsemestre.formation.is_apc() # Attributs "virtuels", définis dans les sous-classes @@ -79,10 +79,17 @@ class ResultatsSemestre: "dict { etudid : indice dans les inscrits }" return {e.id: idx for idx, e in enumerate(self.etuds)} + @cached_property + def etuds_dict(self): + "dict { etudid : Identite } inscrits au semestre, sans les démissionnaires" + return {etud.id: etud for etud in self.etuds} + @cached_property def ues(self) -> list: - "Liste des UE du semestre" - return self.formsemestre.query_ues().all() + """Liste des UEs du semestre + (indices des DataFrames) + """ + return self.formsemestre.query_ues(with_sport=True).all() @cached_property def modimpls(self): @@ -191,9 +198,7 @@ class NotesTableCompat(ResultatsSemestre): Résultat: liste de dicts { champs UE U stats moyenne UE } """ ues = [] - for ue in self.ues: - if filter_sport and ue.type == UE_SPORT: - continue + for ue in self.formsemestre.query_ues(with_sport=not filter_sport): d = ue.to_dict() d.update(StatsMoyenne(self.etud_moy_ue[ue.id]).to_dict()) ues.append(d) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 42e22e00b..f4a9318f1 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -12,6 +12,7 @@ from app import db from app import models from app.scodoc import notesdb as ndb +from app.scodoc.sco_bac import Baccalaureat class Identite(db.Model): @@ -50,6 +51,8 @@ class Identite(db.Model): # adresses = db.relationship("Adresse", lazy="dynamic", backref="etud") billets = db.relationship("BilletAbsence", backref="etudiant", lazy="dynamic") + # one-to-one relation: + admission = db.relationship("Admission", backref="identite", lazy="dynamic") def __repr__(self): return f"" @@ -294,6 +297,10 @@ class Admission(db.Model): # classement (1..Ngr) par le jury dans le groupe APB apb_classement_gr = db.Column(db.Integer) + def get_bac(self) -> Baccalaureat: + "Le bac. utiliser bac.abbrev() pour avoir une chaine de caractères." + return Baccalaureat(self.bac, specialite=self.specialite) + # Suivi scolarité / débouchés class ItemSuivi(db.Model): diff --git a/app/scodoc/sco_bac.py b/app/scodoc/sco_bac.py index 2346ac2e9..ce00d96c7 100644 --- a/app/scodoc/sco_bac.py +++ b/app/scodoc/sco_bac.py @@ -130,7 +130,7 @@ BACS_SSP = {(t[0], t[1]): t[2:] for t in _BACS} BACS_S = {t[0]: t[2:] for t in _BACS} -class Baccalaureat(object): +class Baccalaureat: def __init__(self, bac, specialite=""): self.bac = bac self.specialite = specialite diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 7907b2ad9..ecb4f3b9a 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -295,7 +295,7 @@ div.logo-logo img { margin-top: -10px; width: 128px; padding-right: 5px; - margin-left: -30px; + margin-left: -75px; } div.sidebar-bottom { margin-top: 10px; @@ -1671,7 +1671,10 @@ li.notes_ue_list { margin-top: 9px; list-style-type: none; } - +span.ue_type_1 { + color: green; + font-weight: bold; +} span.ue_code { font-family: Courier, monospace; font-weight: normal; diff --git a/app/templates/pn/form_ues.html b/app/templates/pn/form_ues.html index 500ee42aa..8700116c1 100644 --- a/app/templates/pn/form_ues.html +++ b/app/templates/pn/form_ues.html @@ -29,9 +29,11 @@ scodoc_dept=g.scodoc_dept, ue_id=ue.id) }}">{% if editable and not ue.modules.count() %}{{icons.delete|safe}}{% else %}{{icons.delete_disabled|safe}}{% endif %} + {{ue.acronyme}} {{ue.titre}} + {% if editable and not ue.is_locked() %}