From 3b8f28bbb344a3519dad7447d66702c8756fad2d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 14 Feb 2022 10:05:55 +0100 Subject: [PATCH] =?UTF-8?q?essaie=20de=20tol=C3=A9rer=20codes=20modules=20?= =?UTF-8?q?nulls=20(en=20principe=20non=20autoris=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/moduleimpls.py | 2 +- app/scodoc/sco_abs.py | 2 +- app/scodoc/sco_abs_views.py | 14 ++++++++------ app/scodoc/sco_bulletins.py | 4 ++-- app/scodoc/sco_bulletins_legacy.py | 4 ++-- app/scodoc/sco_bulletins_xml.py | 2 +- app/scodoc/sco_cost_formation.py | 2 +- app/scodoc/sco_evaluation_check_abs.py | 6 +++++- app/scodoc/sco_evaluation_edit.py | 2 +- app/scodoc/sco_evaluations.py | 9 ++++++++- app/scodoc/sco_formsemestre_edit.py | 20 +++++++++++++++----- app/scodoc/sco_formsemestre_inscriptions.py | 6 +++--- app/scodoc/sco_formsemestre_status.py | 2 +- app/scodoc/sco_moduleimpl_inscriptions.py | 16 ++++++++++++---- app/scodoc/sco_placement.py | 5 +++-- app/scodoc/sco_poursuite_dut.py | 2 +- app/scodoc/sco_saisie_notes.py | 4 ++-- app/views/absences.py | 4 +++- app/views/notes.py | 2 +- 19 files changed, 71 insertions(+), 37 deletions(-) diff --git a/app/models/moduleimpls.py b/app/models/moduleimpls.py index d51a620b0..700dec26e 100644 --- a/app/models/moduleimpls.py +++ b/app/models/moduleimpls.py @@ -79,7 +79,7 @@ class ModuleImpl(db.Model): ) def to_dict(self): - """as a dict, with the same conversions as in ScoDoc7""" + """as a dict, with the same conversions as in ScoDoc7, including module""" e = dict(self.__dict__) e.pop("_sa_instance_state", None) # ScoDoc7 output_formators: (backward compat) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 0b38559f7..733452967 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -479,7 +479,7 @@ def _get_abs_description(a, cursor=None): ) if Mlist: M = Mlist[0] - module += "%s " % M["module"]["code"] + module += "%s " % (M["module"]["code"] or "(module sans code)") if desc: return "(%s) %s" % (desc, module) diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index d92ee8559..686d589d7 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -127,7 +127,9 @@ def doSignaleAbsence( modimpls = nt.get_modimpls_dict(ue_id=ue["ue_id"]) for modimpl in modimpls: if modimpl["moduleimpl_id"] == moduleimpl_id: - indication_module = "dans le module %s" % modimpl["module"]["code"] + indication_module = "dans le module %s" % ( + modimpl["module"]["code"] or "(pas de code)" + ) H = [ html_sco_header.sco_header( page_title=f"Signalement d'une absence pour {etud.nomprenom}", @@ -218,7 +220,7 @@ def SignaleAbsenceEtud(): # etudid implied """\n""" % { "modimpl_id": modimpl["moduleimpl_id"], - "modname": modimpl["module"]["code"], + "modname": modimpl["module"]["code"] or "", } ) menu_module += """

""" @@ -964,10 +966,10 @@ def _tables_abs_etud( ex.append( f"""{mod["module"]["code"]}""" + ">{mod["module"]["code"] or "(module sans code)"}""" ) else: - ex.append(mod["module"]["code"]) + ex.append(mod["module"]["code"] or "(module sans code)") if ex: return ", ".join(ex) return "" @@ -982,10 +984,10 @@ def _tables_abs_etud( ex.append( f"""{mod["module"]["code"]}""" + ">{mod["module"]["code"] or '(module sans code)'}""" ) else: - ex.append(mod["module"]["code"]) + ex.append(mod["module"]["code"] or "(module sans code)") if ex: return ", ".join(ex) return "" diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 17195cf77..93a926b64 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -514,7 +514,7 @@ def _ue_mod_bulletin(etudid, formsemestre_id, ue_id, modimpls, nt, version): ) if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id): mod["code"] = modimpl["module"]["code"] - mod["code_html"] = link_mod + mod["code"] + "" + mod["code_html"] = link_mod + (mod["code"] or "") + "" else: mod["code"] = mod["code_html"] = "" mod["name"] = ( @@ -532,7 +532,7 @@ def _ue_mod_bulletin(etudid, formsemestre_id, ue_id, modimpls, nt, version): % (modimpl["moduleimpl_id"], mod_descr) ) if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id): - mod["code_txt"] = modimpl["module"]["code"] + mod["code_txt"] = modimpl["module"]["code"] or "" mod["code_html"] = link_mod + mod["code_txt"] + "" else: mod["code_txt"] = "" diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index fcc714e35..7d570d07d 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -476,8 +476,8 @@ def _bulletin_pdf_table_legacy(I, version="long"): else: rang_minmax = mod["mod_rang_txt"] # vide si pas option rang t = [ - mod["code"], - mod["name"], + mod["code"] or "", + mod["name"] or "", rang_minmax, mod["mod_moy_txt"], mod["mod_coef_txt"], diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 015867e32..f41361c24 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -252,7 +252,7 @@ def make_xml_formsemestre_bulletinetud( x_mod = Element( "module", id=str(modimpl["moduleimpl_id"]), - code=str(mod["code"]), + code=str(mod["code"] or ""), coefficient=str(mod["coefficient"]), numero=str(mod["numero"]), titre=scu.quote_xml_attr(mod["titre"]), diff --git a/app/scodoc/sco_cost_formation.py b/app/scodoc/sco_cost_formation.py index b17643d27..0cc0d78b8 100644 --- a/app/scodoc/sco_cost_formation.py +++ b/app/scodoc/sco_cost_formation.py @@ -65,7 +65,7 @@ def formsemestre_table_estim_cost( Mod = M["module"] T.append( { - "code": Mod["code"], + "code": Mod["code"] or "", "titre": Mod["titre"], "heures_cours": Mod["heures_cours"], "heures_td": Mod["heures_td"] * n_group_td, diff --git a/app/scodoc/sco_evaluation_check_abs.py b/app/scodoc/sco_evaluation_check_abs.py index 36073c2e4..b8287c25d 100644 --- a/app/scodoc/sco_evaluation_check_abs.py +++ b/app/scodoc/sco_evaluation_check_abs.py @@ -237,7 +237,11 @@ def formsemestre_check_absences_html(formsemestre_id): if evals: H.append( '

%s: %s

' - % (M["moduleimpl_id"], M["module"]["code"], M["module"]["abbrev"]) + % ( + M["moduleimpl_id"], + M["module"]["code"] or "", + M["module"]["abbrev"] or "", + ) ) for E in evals: H.append( diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 5b41941cd..4375ad721 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -122,7 +122,7 @@ def evaluation_create_form( # mod_descr = '%s %s %s' % ( moduleimpl_id, - mod["code"], + mod["code"] or "module sans code", mod["titre"], link, ) diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 72f3755cc..09f2179b7 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -637,7 +637,14 @@ def evaluation_describe(evaluation_id="", edit_in_place=True): ) mod_descr = ( '%s %s (resp. %s) %s' - % (moduleimpl_id, Mod["code"], Mod["titre"], nomcomplet, resp, link) + % ( + moduleimpl_id, + Mod["code"] or "", + Mod["titre"] or "?", + nomcomplet, + resp, + link, + ) ) etit = E["description"] or "" diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 619e2d078..81dbd5659 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -601,7 +601,7 @@ def do_formsemestre_createwithmodules(edit=False): "input_type": "text_suggest", "size": 50, "withcheckbox": True, - "title": "%s %s" % (mod["code"], mod["titre"]), + "title": "%s %s" % (mod["code"] or "", mod["titre"] or ""), "allowed_values": allowed_user_names, "template": itemtemplate, "text_suggest_options": { @@ -802,7 +802,9 @@ def do_formsemestre_createwithmodules(edit=False): } moduleimpl_id = sco_moduleimpl.do_moduleimpl_create(modargs) mod = sco_edit_module.module_list({"module_id": module_id})[0] - msg += ["création de %s (%s)" % (mod["code"], mod["titre"])] + msg += [ + "création de %s (%s)" % (mod["code"] or "?", mod["titre"] or "?") + ] # INSCRIPTIONS DES ETUDIANTS log( 'inscription module: %s = "%s"' @@ -824,7 +826,7 @@ def do_formsemestre_createwithmodules(edit=False): ) msg += [ "inscription de %d étudiants au module %s" - % (len(etudids), mod["code"]) + % (len(etudids), mod["code"] or "(module sans code)") ] else: log( @@ -919,11 +921,19 @@ def formsemestre_delete_moduleimpls(formsemestre_id, module_ids_to_del): if evals: msg += [ 'impossible de supprimer %s (%s) car il y a %d évaluations définies (supprimer les d\'abord)' - % (mod["code"], mod["titre"], len(evals), moduleimpl_id) + % ( + mod["code"] or "(module sans code)", + mod["titre"], + len(evals), + moduleimpl_id, + ) ] ok = False else: - msg += ["suppression de %s (%s)" % (mod["code"], mod["titre"])] + msg += [ + "suppression de %s (%s)" + % (mod["code"] or "(module sans code)", mod["titre"] or "") + ] sco_moduleimpl.do_moduleimpl_delete( moduleimpl_id, formsemestre_id=formsemestre_id ) diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 3e398c837..44c75dd0c 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -508,7 +508,7 @@ def formsemestre_inscription_option(etudid, formsemestre_id): modimpls_by_ue_ids[ue_id].append(mod["moduleimpl_id"]) modimpls_by_ue_names[ue_id].append( - "%s %s" % (mod["module"]["code"], mod["module"]["titre"]) + "%s %s" % (mod["module"]["code"] or "", mod["module"]["titre"] or "") ) vals = scu.get_request_args() if not vals.get("tf_submitted", False): @@ -653,7 +653,7 @@ function chkbx_select(field_id, state) { "%s (%s)" % ( modsdict[x]["module"]["titre"], - modsdict[x]["module"]["code"], + modsdict[x]["module"]["code"] or "(module sans code)", ) for x in a_desinscrire ] @@ -672,7 +672,7 @@ function chkbx_select(field_id, state) { "%s (%s)" % ( modsdict[x]["module"]["titre"], - modsdict[x]["module"]["code"], + modsdict[x]["module"]["code"] or "(module sans code)", ) for x in a_inscrire ] diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index e9a69c8c4..d8be56f27 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -638,7 +638,7 @@ def formsemestre_description_table(formsemestre_id, with_evals=False): ) l = { "UE": M["ue"]["acronyme"], - "Code": M["module"]["code"], + "Code": M["module"]["code"] or "", "Module": M["module"]["abbrev"] or M["module"]["titre"], "_Module_class": "scotext", "Inscrits": len(ModInscrits), diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index a0266219f..e3c232305 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -92,7 +92,11 @@ def moduleimpl_inscriptions_edit(moduleimpl_id, etuds=[], submitted=False): "Appliquer les modifications".

""" - % (moduleimpl_id, mod["titre"], mod["code"]), + % ( + moduleimpl_id, + mod["titre"] or "(module sans titre)", + mod["code"] or "(module sans code)", + ), ] # Liste des inscrits à ce semestre inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits( @@ -308,8 +312,8 @@ def moduleimpl_inscriptions_stats(formsemestre_id): H.append( '%s%s%s%s' % ( - mod["ue"]["acronyme"], - mod["module"]["code"], + mod["ue"]["acronyme"] or "", + mod["module"]["code"] or "(module sans code)", mod["nb_inscrits"], c_link, ) @@ -337,7 +341,11 @@ def moduleimpl_inscriptions_stats(formsemestre_id): c_link = mod["module"]["titre"] H.append( '%s%s%s' - % (mod["ue"]["acronyme"], mod["module"]["code"], c_link) + % ( + mod["ue"]["acronyme"], + mod["module"]["code"] or "(module sans code)", + c_link, + ) ) H.append("") diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index 1d5ac6c42..7682d1ea4 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -257,7 +257,7 @@ class PlacementRunner: self.moduleimpl_data["formsemestre_id"] ) self.evalname = "%s-%s" % ( - self.module_data["code"], + self.module_data["code"] or "?", ndb.DateDMYtoISO(self.eval_data["jour"]), ) if self.eval_data["description"]: @@ -266,7 +266,8 @@ class PlacementRunner: self.evaltitre = "évaluation du %s" % self.eval_data["jour"] self.desceval = [ # une liste de chaines: description de l'evaluation "%s" % self.sem["titreannee"], - "Module : %s - %s" % (self.module_data["code"], self.module_data["abbrev"]), + "Module : %s - %s" + % (self.module_data["code"] or "?", self.module_data["abbrev"] or ""), "Surveillants : %s" % self.surveillants, "Batiment : %(batiment)s - Salle : %(salle)s" % self.__dict__, "Controle : %s (coef. %g)" diff --git a/app/scodoc/sco_poursuite_dut.py b/app/scodoc/sco_poursuite_dut.py index c0c453bf9..cfa3dff8c 100644 --- a/app/scodoc/sco_poursuite_dut.py +++ b/app/scodoc/sco_poursuite_dut.py @@ -92,7 +92,7 @@ def etud_get_poursuite_info(sem, etud): for ue in ues: # on parcourt chaque UE for modimpl in modimpls: # dans chaque UE les modules if modimpl["module"]["ue_id"] == ue["ue_id"]: - codeModule = modimpl["module"]["code"] + codeModule = modimpl["module"]["code"] or "" noteModule = scu.fmt_note( nt.get_etud_mod_moy(modimpl["moduleimpl_id"], etudid) ) diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index b026bbaa4..8dee1a7e2 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -813,8 +813,8 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]): evaltitre = "évaluation du %s" % E["jour"] description = "%s en %s (%s) resp. %s" % ( evaltitre, - Mod["abbrev"], - Mod["code"], + Mod["abbrev"] or "", + Mod["code"] or "", mod_responsable["prenomnom"], ) diff --git a/app/views/absences.py b/app/views/absences.py index ea65d52ee..cf8de2c18 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -443,8 +443,9 @@ def SignaleAbsenceGrHebdo( % { "modimpl_id": modimpl["moduleimpl_id"], "modname": modimpl["module"]["code"] + or "" + " " - + (modimpl["module"]["abbrev"] or modimpl["module"]["titre"]), + + (modimpl["module"]["abbrev"] or modimpl["module"]["titre"] or ""), "sel": sel, } ) @@ -611,6 +612,7 @@ def SignaleAbsenceGrSemestre( % { "modimpl_id": modimpl["moduleimpl_id"], "modname": modimpl["module"]["code"] + or "" + " " + (modimpl["module"]["abbrev"] or modimpl["module"]["titre"]), "sel": sel, diff --git a/app/views/notes.py b/app/views/notes.py index a1424b381..efad2808b 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1322,7 +1322,7 @@ def formsemestre_enseignants_list(formsemestre_id, format="html"): # description textuelle des modules for ens in sem_ens: sem_ens[ens]["descr_mods"] = ", ".join( - [x["module"]["code"] for x in sem_ens[ens]["mods"]] + [x["module"]["code"] or "?" for x in sem_ens[ens]["mods"]] ) # ajoute infos sur enseignant: