From 54b714fdbc48d6739ccaa3fb96028b97b5048971 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 6 Jan 2022 22:42:26 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liore=20affichage=20coefs=20sur=20table?= =?UTF-8?q?au=20bord=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/modules.py | 24 +++++++++++++++--- app/scodoc/sco_edit_module.py | 8 +++--- app/scodoc/sco_formsemestre_status.py | 2 +- app/scodoc/sco_moduleimpl_status.py | 36 ++++++++++++++------------- app/static/css/scodoc.css | 6 +++++ 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/app/models/modules.py b/app/models/modules.py index 8f3055074..24e552461 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -129,9 +129,27 @@ class Module(db.Model): # à redéfinir les relationships... return sorted(self.ue_coefs, key=lambda x: x.ue.numero) - def ue_coefs_descr(self): - """List of tuples [ (ue_acronyme, coef) ]""" - return [(c.ue.acronyme, c.coef) for c in self.get_ue_coefs_sorted()] + def ue_coefs_list(self, include_zeros=True): + """Liste des coefs vers les UE (pour les modules APC). + Si include_zeros, liste aussi les UE sans coef (donc nul) de ce semestre. + Result: List of tuples [ (ue, coef) ] + """ + if not self.is_apc(): + return [] + if include_zeros: + # Toutes les UE du même semestre: + ues_semestre = ( + self.formation.ues.filter_by(semestre_idx=self.ue.semestre_idx) + .order_by(UniteEns.numero) + .all() + ) + coefs_dict = self.get_ue_coef_dict() + coefs_list = [] + for ue in ues_semestre: + coefs_list.append((ue, coefs_dict.get(ue.id, 0.0))) + return coefs_list + # Liste seulement les coefs définis: + return [(c.ue, c.coef) for c in self.get_ue_coefs_sorted()] class ModuleUECoef(db.Model): diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 813320d53..fbc28db67 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -554,9 +554,11 @@ def module_edit(module_id=None): ), ] if is_apc: - coefs_descr = a_module.ue_coefs_descr() - if coefs_descr: - coefs_descr_txt = ", ".join(["%s: %s" % x for x in coefs_descr]) + coefs_lst = a_module.ue_coefs_list() + if coefs_lst: + coefs_descr_txt = ", ".join( + [f"{ue.acronyme}: {c}" for (ue, c) in coefs_lst] + ) else: coefs_descr_txt = """non définis""" descr += [ diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 5c3189898..7ca529269 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -1119,7 +1119,7 @@ def formsemestre_tableau_modules( mod_descr = "Module " + (mod.titre or "") if mod.is_apc(): coef_descr = ", ".join( - [f"{ue_acro}: {co}" for ue_acro, co in mod.ue_coefs_descr()] + [f"{ue.acronyme}: {co}" for ue, co in mod.ue_coefs_list()] ) if coef_descr: mod_descr += " Coefs: " + coef_descr diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 33f51da14..735ece8a0 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -156,28 +156,29 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0): return htmlutils.make_menu("actions", menuEval, alone=True) -def _ue_coefs_html(coefs_descr) -> str: +def _ue_coefs_html(coefs_lst) -> str: """ """ - max_coef = max([x[1] for x in coefs_descr]) if coefs_descr else 1.0 + max_coef = max([x[1] for x in coefs_lst]) if coefs_lst else 1.0 H = """
Coefficients vers les UE
""" - if coefs_descr: - H += f""" + if coefs_lst: + H += ( + f"""
- """ + "\n".join( - [ - f"""
{coef}
{ue_acronyme}
""" - for ue_acronyme, coef in coefs_descr - ] + """ + + "\n".join( + [ + f"""
{coef}
{ue.acronyme}
""" + for ue, coef in coefs_lst + ] + ) + + "
" ) else: - H += """
non définis""" - H += """ -
-
- """ + H += """
non définis
""" + H += "" return H @@ -256,7 +257,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): H.append(scu.icontag("lock32_img", title="verrouillé")) H.append("""""") if modimpl.module.is_apc(): - H.append(_ue_coefs_html(modimpl.module.ue_coefs_descr())) + H.append(_ue_coefs_html(modimpl.module.ue_coefs_list())) else: H.append(f"Coef. dans le semestre: {modimpl.module.coefficient}") H.append("""""") @@ -323,9 +324,10 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): # if not modimpl.check_apc_conformity(): H.append( - """""" + """ ) # if has_expression and nt.expr_diagnostics: diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 72a918a69..918795f07 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -1355,7 +1355,13 @@ div.moduleimpl_type_ressource { div#modimpl_coefs { position: absolute; + border: 1px solid; + padding-top: 3px; + padding-left: 3px; + padding-right: 5px; + background-color: #d3d3d378; } + .coefs_histo{ height: 32px; display: flex;