From 284a99378e22b711dd90e1662c0daba817c3cdf3 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 17 Feb 2023 20:40:57 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20API:=20descrinscription=20=C3=A0=20un=20?= =?UTF-8?q?groupe=20de=20parcours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/partitions.py | 18 +++++++++++++++++- app/comp/res_common.py | 3 ++- app/scodoc/sco_edit_module.py | 2 +- sco_version.py | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/api/partitions.py b/app/api/partitions.py index 42307656..489d20e8 100644 --- a/app/api/partitions.py +++ b/app/api/partitions.py @@ -16,7 +16,7 @@ from app.api import api_bp as bp, api_web_bp from app.decorators import scodoc, permission_required from app.scodoc.sco_utils import json_error from app.models import FormSemestre, FormSemestreInscription, Identite -from app.models import GroupDescr, Partition +from app.models import GroupDescr, Partition, Scolog from app.models.groups import group_membership from app.scodoc import sco_cache from app.scodoc import sco_groups @@ -204,6 +204,14 @@ def group_remove_etud(group_id: int, etudid: int): if etud in group.etuds: group.etuds.remove(etud) db.session.commit() + Scolog.logdb( + method="group_remove_etud", + etudid=etud.id, + msg=f"Retrait du groupe {group.group_name} de {group.partition.partition_name}", + commit=True, + ) + # Update parcours + group.partition.formsemestre.update_inscriptions_parcours_from_groups() sco_cache.invalidate_formsemestre(group.partition.formsemestre_id) return jsonify({"group_id": group_id, "etudid": etudid}) @@ -235,7 +243,15 @@ def partition_remove_etud(partition_id: int, etudid: int): ) for group in groups: group.etuds.remove(etud) + Scolog.logdb( + method="partition_remove_etud", + etudid=etud.id, + msg=f"Retrait du groupe {group.group_name} de {group.partition.partition_name}", + commit=True, + ) db.session.commit() + # Update parcours + group.partition.formsemestre.update_inscriptions_parcours_from_groups() app.set_sco_dept(partition.formsemestre.departement.acronym) sco_cache.invalidate_formsemestre(partition.formsemestre_id) return jsonify({"partition_id": partition_id, "etudid": etudid}) diff --git a/app/comp/res_common.py b/app/comp/res_common.py index d1cc2d56..1cfa17f4 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -125,7 +125,8 @@ class ResultatsSemestre(ResultatsCache): return [ue.id for ue in self.ues if ue.type != UE_SPORT] def etud_ues(self, etudid: int) -> Generator[UniteEns]: - """Liste des UE auxquelles l'étudiant est inscrit.""" + """Liste des UE auxquelles l'étudiant est inscrit + (sans bonus, en BUT prend en compte le parcours de l'étudiant).""" return (UniteEns.query.get(ue_id) for ue_id in self.etud_ues_ids(etudid)) def etud_ects_tot_sem(self, etudid: int) -> float: diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 8038c8e5..4bbd4911 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -756,7 +756,7 @@ def module_edit( ] # force module semestre_idx to its UE if module: - if module.ue.semestre_idx is None: + if (not module.ue) or (module.ue.semestre_idx is None): # Filet de sécurité si jamais l'UE n'a pas non plus de semestre: module_dict["semestre_id"] = 1 else: diff --git a/sco_version.py b/sco_version.py index 7ab74076..0442f9c2 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.4.44" +SCOVERSION = "9.4.45" SCONAME = "ScoDoc"