diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index da1aed8de2..eef95a0924 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_bulletins.py b/app/scodoc/sco_bulletins.py index 989c7bd5cf..0244520479 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/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index b94a60178f..2e8c9ca711 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: diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index ae6ecc0b6b..4526ae6349 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 cf24c4b0c5..ab96e14682 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" ), @@ -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"] diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 395f6107d4..651032c05d 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 ac067339ae..e086ee9922 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/app/templates/pn/form_ues.html b/app/templates/pn/form_ues.html index aa6b323596..6e56d2f77e 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() %} diff --git a/app/views/notes.py b/app/views/notes.py index fe1774a735..111019d829 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" diff --git a/sco_version.py b/sco_version.py index 83068bb612..0de26319f8 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"