Fix: API: descrinscription à un groupe de parcours

This commit is contained in:
Emmanuel Viennet 2023-02-17 20:40:57 +01:00
parent 08c536e777
commit 284a99378e
4 changed files with 21 additions and 4 deletions

View File

@ -16,7 +16,7 @@ from app.api import api_bp as bp, api_web_bp
from app.decorators import scodoc, permission_required from app.decorators import scodoc, permission_required
from app.scodoc.sco_utils import json_error from app.scodoc.sco_utils import json_error
from app.models import FormSemestre, FormSemestreInscription, Identite 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.models.groups import group_membership
from app.scodoc import sco_cache from app.scodoc import sco_cache
from app.scodoc import sco_groups from app.scodoc import sco_groups
@ -204,6 +204,14 @@ def group_remove_etud(group_id: int, etudid: int):
if etud in group.etuds: if etud in group.etuds:
group.etuds.remove(etud) group.etuds.remove(etud)
db.session.commit() 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) sco_cache.invalidate_formsemestre(group.partition.formsemestre_id)
return jsonify({"group_id": group_id, "etudid": etudid}) 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: for group in groups:
group.etuds.remove(etud) 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() db.session.commit()
# Update parcours
group.partition.formsemestre.update_inscriptions_parcours_from_groups()
app.set_sco_dept(partition.formsemestre.departement.acronym) app.set_sco_dept(partition.formsemestre.departement.acronym)
sco_cache.invalidate_formsemestre(partition.formsemestre_id) sco_cache.invalidate_formsemestre(partition.formsemestre_id)
return jsonify({"partition_id": partition_id, "etudid": etudid}) return jsonify({"partition_id": partition_id, "etudid": etudid})

View File

@ -125,7 +125,8 @@ class ResultatsSemestre(ResultatsCache):
return [ue.id for ue in self.ues if ue.type != UE_SPORT] return [ue.id for ue in self.ues if ue.type != UE_SPORT]
def etud_ues(self, etudid: int) -> Generator[UniteEns]: 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)) return (UniteEns.query.get(ue_id) for ue_id in self.etud_ues_ids(etudid))
def etud_ects_tot_sem(self, etudid: int) -> float: def etud_ects_tot_sem(self, etudid: int) -> float:

View File

@ -756,7 +756,7 @@ def module_edit(
] ]
# force module semestre_idx to its UE # force module semestre_idx to its UE
if module: 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: # Filet de sécurité si jamais l'UE n'a pas non plus de semestre:
module_dict["semestre_id"] = 1 module_dict["semestre_id"] = 1
else: else:

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.4.44" SCOVERSION = "9.4.45"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"