From 45a2fa174c6d65b8ae03aba668a4a9a3cbccb0c4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 11 Jul 2022 21:39:08 +0200 Subject: [PATCH 1/5] Fiix UE edit. Close #439 --- app/scodoc/sco_edit_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index b94a6017..2e8c9ca7 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -236,6 +236,7 @@ def do_module_edit(vals: dict) -> None: mod = module_list({"module_id": vals["module_id"]})[0] if module_is_locked(mod["module_id"]): # formation verrouillée: empeche de modifier certains champs: + vals = vals.copy() protected_fields = ("coefficient", "ue_id", "matiere_id", "semestre_id") for f in protected_fields: if f in vals: From 009de7a4ab269f681c3c6b25881d75580f26ab02 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 11 Jul 2022 21:39:30 +0200 Subject: [PATCH 2/5] 2 minor bugs --- app/scodoc/sco_formations.py | 2 ++ app/scodoc/sco_formsemestre_edit.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index ae6ecc0b..4526ae63 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -89,6 +89,8 @@ def formation_list(formation_id=None, args={}): def formation_has_locked_sems(formation_id): # XXX to remove "backward compat: True if there is a locked formsemestre in this formation" formation = Formation.query.get(formation_id) + if formation is None: + return False return formation.has_locked_sems() diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index cf24c4b0..507e409f 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -1785,7 +1785,7 @@ def get_formsemestre_session_id(sem, F, parcours): "ImputationDept", sem["formsemestre_id"] ) if not imputation_dept: - imputation_dept = sco_preferences.get_preference("DeptName") + imputation_dept = sco_preferences.get_preference("DeptName") or "" imputation_dept = imputation_dept.upper() parcours_type = parcours.NAME modalite = sem["modalite"] From 34c58cf8cae31a3b0fc3244cf532b6d2d59055fd Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 11 Jul 2022 22:07:47 +0200 Subject: [PATCH 3/5] ue_table: ffiche code Apo des UE BUT --- app/templates/pn/form_ues.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/templates/pn/form_ues.html b/app/templates/pn/form_ues.html index aa6b3235..6e56d2f7 100644 --- a/app/templates/pn/form_ues.html +++ b/app/templates/pn/form_ues.html @@ -51,8 +51,12 @@ else 'aucun'|safe }} ECTS {%- endif -%} + {%- if ue.code_apogee -%} + {{ virg() }} Apo {{ue.code_apogee}} + {%- endif -%} ) + {% if editable and not ue.is_locked() %} From 4921d451295bb75e47bce34f5c5075ff47c7fa3c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 13 Jul 2022 11:30:01 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Fix:=20PV=20jury=20/=20cas=20rare=20sans=20?= =?UTF-8?q?d=C3=A9cision=20d'ann=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_apogee_csv.py | 28 +++++++++++++++++++++++++--- app/scodoc/sco_formsemestre_edit.py | 4 ++-- app/scodoc/sco_pvjury.py | 8 ++++---- app/scodoc/sco_pvpdf.py | 17 +++++++++++------ sco_version.py | 2 +- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index da1aed8d..eef95a09 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -260,6 +260,8 @@ class ApoEtud(dict): self["naissance"] = naissance self.cols = cols "{ col_id : value } colid = 'apoL_c0001'" + self.is_apc = None + "Vrai si BUT" self.col_elts = {} "{'V1RT': {'R': 'ADM', 'J': '', 'B': 20, 'N': '12.14'}}" self.new_cols = {} # { col_id : value to record in csv } @@ -431,6 +433,8 @@ class ApoEtud(dict): return VOID_APO_RES # Elements UE + # if etudid == 3661 and nt.formsemestre.semestre_id == 2: # XXX XXX XXX + # breakpoint() decisions_ue = nt.get_etud_decision_ues(etudid) for ue in nt.get_ues_stat_dict(): if ue["code_apogee"] and code in { @@ -472,6 +476,9 @@ class ApoEtud(dict): def comp_elt_semestre(self, nt, decision, etudid): """Calcul résultat apo semestre""" + if self.is_apc: + # pas de code semestre en APC ! + return dict(N="", B=20, J="", R="", M="") if decision is None: etud = Identite.query.get(etudid) nomprenom = etud.nomprenom if etud else "(inconnu)" @@ -565,7 +572,8 @@ class ApoEtud(dict): il faut considérer les deux semestres ((S1,S2) ou (S3,S4)) pour calculer le code annuel (VET ou VRT1A (voir elt_annee_apo)). - Pour les jurys intermediaires (janvier, S1 ou S3): (S2 ou S4) de la même étape lors d'une année précédente ? + Pour les jurys intermediaires (janvier, S1 ou S3): (S2 ou S4) de la même + étape lors d'une année précédente ? Renvoie le semestre "courant" et l'autre semestre, ou None s'il n'y en a pas. """ @@ -687,6 +695,8 @@ class ApoData(object): self.export_res_rat = export_res_rat self.orig_filename = orig_filename self.periode = periode # + self.is_apc = None + "Vrai si BUT" try: self.read_csv(data) except ScoFormatError as e: @@ -722,8 +732,19 @@ class ApoData(object): def setup(self): """Recherche semestres ScoDoc concernés""" self.sems_etape = comp_apo_sems(self.etape_apogee, self.annee_scolaire) + self.formsemestres_etape = [ + FormSemestre.query.get_or_404(s["formsemestre_id"]) for s in self.sems_etape + ] + apcs = { + formsemestre.formation.is_apc() for formsemestre in self.formsemestres_etape + } + if len(apcs) != 1: + raise ScoValueError( + "l'ensemble mixe des semestres BUT (APC) et des semestres classiques !" + ) + self.is_apc = apcs.pop() self.etape_formsemestre_ids = {s["formsemestre_id"] for s in self.sems_etape} - if self.periode != None: + if self.periode is not None: self.sems_periode = [ s for s in self.sems_etape @@ -1126,7 +1147,7 @@ def _apo_skip_section(f): # ------------------------------------- -def comp_apo_sems(etape_apogee, annee_scolaire): +def comp_apo_sems(etape_apogee, annee_scolaire: int) -> list[dict]: """ :param etape_apogee: etape (string or ApoEtapeVDI) :param annee_scolaire: annee (int) @@ -1224,6 +1245,7 @@ def export_csv_to_apogee( apo_data.setup() # -> .sems_etape for e in apo_data.etuds: + e.is_apc = apo_data.is_apc e.lookup_scodoc(apo_data.etape_formsemestre_ids) e.associate_sco(apo_data) diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 507e409f..ab96e146 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -419,7 +419,7 @@ def do_formsemestre_createwithmodules(edit=False): { "size": 32, "title": "Element(s) Apogée:", - "explanation": "du semestre (ex: VRTW1). Séparés par des virgules.", + "explanation": "associé(s) au résultat du semestre (ex: VRTW1). Inutile en BUT. Séparés par des virgules.", "allow_null": not sco_preferences.get_preference( "always_require_apo_sem_codes" ), @@ -432,7 +432,7 @@ def do_formsemestre_createwithmodules(edit=False): { "size": 32, "title": "Element(s) Apogée:", - "explanation": "de l'année (ex: VRT1A). Séparés par des virgules.", + "explanation": "associé(s) au résultat de l'année (ex: VRT1A). Séparés par des virgules.", "allow_null": not sco_preferences.get_preference( "always_require_apo_sem_codes" ), diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 395f6107..651032c0 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -236,8 +236,8 @@ def dict_pvjury( has_prev = False # vrai si au moins un etudiant a un code prev semestre_non_terminal = False # True si au moins un etudiant a un devenir - L = [] - D = {} # même chose que L, mais { etudid : dec } + decisions = [] + D = {} # même chose que decisions, mais { etudid : dec } for etudid in etudids: # etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud: Identite = Identite.query.get(etudid) @@ -353,7 +353,7 @@ def dict_pvjury( d["prev_code_descr"] = "" d["Se"] = Se - L.append(d) + decisions.append(d) D[etudid] = d return { @@ -364,7 +364,7 @@ def dict_pvjury( "formation": sco_formations.formation_list( args={"formation_id": sem["formation_id"]} )[0], - "decisions": L, + "decisions": decisions, "decisions_dict": D, } diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index ac067339..e086ee99 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -631,12 +631,17 @@ def add_apc_infos(formsemestre: FormSemestre, params: dict, decision: dict): """Ajoute les champs pour les formations APC (BUT), donc avec codes RCUE et année""" annee_but = (formsemestre.semestre_id + 1) // 2 params["decision_orig"] = f"année BUT{annee_but}" - params["decision_sem_descr"] = decision.get("decision_annee", {}).get("code", "") - params[ - "decision_ue_txt" - ] = f"""{params["decision_ue_txt"]}
- Niveaux de compétences:
{decision.get("descr_decisions_rcue", "")} - """ + if decision is None: + params["decision_sem_descr"] = "" + params["decision_ue_txt"] = "" + else: + decision_annee = decision.get("decision_annee") or {} + params["decision_sem_descr"] = decision_annee.get("code") or "" + params[ + "decision_ue_txt" + ] = f"""{params["decision_ue_txt"]}
+ Niveaux de compétences:
{decision.get("descr_decisions_rcue") or ""} + """ # ---------------------------------------------- diff --git a/sco_version.py b/sco_version.py index 83068bb6..0de26319 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.19" +SCOVERSION = "9.3.20" SCONAME = "ScoDoc" From 9d72954cc1822b3de1d9802a199086e19adb7316 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 13 Jul 2022 12:03:53 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Bulletins:=20v=C3=A9rification=20plus=20str?= =?UTF-8?q?icte=20des=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins.py | 12 ++++++++---- app/views/notes.py | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 989c7bd5..02445204 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -148,12 +148,15 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): I["server_name"] = request.url_root # Formation et parcours + formation_dict = None if I["sem"]["formation_id"]: - I["formation"] = sco_formations.formation_list( + formation_dicts = sco_formations.formation_list( args={"formation_id": I["sem"]["formation_id"]} - )[0] - else: # what's the fuck ? - I["formation"] = { + ) + if formation_dicts: + formation_dict = formation_dicts[0] + if formation_dict is None: # what's the fuck ? + formation_dict = { "acronyme": "?", "code_specialite": "", "dept_id": 1, @@ -166,6 +169,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): "type_parcours": 0, "version": 0, } + I["formation"] = formation_dict I["parcours"] = sco_codes_parcours.get_parcours_from_code( I["formation"]["type_parcours"] ) diff --git a/app/views/notes.py b/app/views/notes.py index fe1774a7..111019d8 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -299,21 +299,21 @@ def formsemestre_bulletinetud( raise ScoInvalidIdType( "formsemestre_bulletinetud: formsemestre_id must be an integer !" ) - formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + formsemestre = FormSemestre.query.filter_by( + formsemestre_id=formsemestre_id, dept_id=g.scodoc_dept_id + ).first_or_404() if etudid: - etud = models.Identite.query.get_or_404(etudid) + etud = models.Identite.query.filter_by( + etudid=etudid, dept_id=formsemestre.dept_id + ).first_or_404() elif code_nip: - etud = ( - models.Identite.query.filter_by(code_nip=str(code_nip)) - .filter_by(dept_id=formsemestre.dept_id) - .first_or_404() - ) + etud = models.Identite.query.filter_by( + code_nip=str(code_nip), dept_id=formsemestre.dept_id + ).first_or_404() elif code_ine: - etud = ( - models.Identite.query.filter_by(code_ine=str(code_ine)) - .filter_by(dept_id=formsemestre.dept_id) - .first_or_404() - ) + etud = models.Identite.query.filter_by( + code_ine=str(code_ine), dept_id=formsemestre.dept_id + ).first_or_404() else: raise ScoValueError( "Paramètre manquant: spécifier etudid, code_nip ou code_ine"