forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -230,7 +230,9 @@ def group_remove_etud(group_id: int, etudid: int):
|
||||
commit=True,
|
||||
)
|
||||
# Update parcours
|
||||
group.partition.formsemestre.update_inscriptions_parcours_from_groups()
|
||||
group.partition.formsemestre.update_inscriptions_parcours_from_groups(
|
||||
etudid=etudid
|
||||
)
|
||||
sco_cache.invalidate_formsemestre(group.partition.formsemestre_id)
|
||||
return {"group_id": group_id, "etudid": etudid}
|
||||
|
||||
@ -277,7 +279,7 @@ def partition_remove_etud(partition_id: int, etudid: int):
|
||||
)
|
||||
db.session.commit()
|
||||
# Update parcours
|
||||
partition.formsemestre.update_inscriptions_parcours_from_groups()
|
||||
partition.formsemestre.update_inscriptions_parcours_from_groups(etudid=etudid)
|
||||
app.set_sco_dept(partition.formsemestre.departement.acronym)
|
||||
sco_cache.invalidate_formsemestre(partition.formsemestre_id)
|
||||
return {"partition_id": partition_id, "etudid": etudid}
|
||||
|
@ -818,11 +818,15 @@ class FormSemestre(db.Model):
|
||||
|
||||
db.session.commit()
|
||||
|
||||
def update_inscriptions_parcours_from_groups(self) -> None:
|
||||
def update_inscriptions_parcours_from_groups(self, etudid: int = None) -> None:
|
||||
"""Met à jour les inscriptions dans les parcours du semestres en
|
||||
fonction des groupes de parcours.
|
||||
|
||||
Les groupes de parcours sont ceux de la partition scu.PARTITION_PARCOURS
|
||||
et leur nom est le code du parcours (eg "Cyber").
|
||||
|
||||
Si etudid est sépcifié, n'affecte que cet étudiant,
|
||||
sinon traite tous les inscrits du semestre.
|
||||
"""
|
||||
if self.formation.referentiel_competence_id is None:
|
||||
return # safety net
|
||||
@ -833,17 +837,32 @@ class FormSemestre(db.Model):
|
||||
return
|
||||
|
||||
# Efface les inscriptions aux parcours:
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription
|
||||
SET parcour_id=NULL
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
"""
|
||||
),
|
||||
{
|
||||
"formsemestre_id": self.id,
|
||||
},
|
||||
)
|
||||
if etudid:
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription
|
||||
SET parcour_id=NULL
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
AND etudid=:etudid
|
||||
"""
|
||||
),
|
||||
{
|
||||
"formsemestre_id": self.id,
|
||||
"etudid": etudid,
|
||||
},
|
||||
)
|
||||
else:
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription
|
||||
SET parcour_id=NULL
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
"""
|
||||
),
|
||||
{
|
||||
"formsemestre_id": self.id,
|
||||
},
|
||||
)
|
||||
# Inscrit les étudiants des groupes de parcours:
|
||||
for group in partition.groups:
|
||||
query = (
|
||||
@ -861,22 +880,42 @@ class FormSemestre(db.Model):
|
||||
)
|
||||
continue
|
||||
parcour = query.first()
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription ins
|
||||
SET parcour_id=:parcour_id
|
||||
FROM group_membership gm
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
AND gm.etudid = ins.etudid
|
||||
AND gm.group_id = :group_id
|
||||
"""
|
||||
),
|
||||
{
|
||||
"formsemestre_id": self.id,
|
||||
"parcour_id": parcour.id,
|
||||
"group_id": group.id,
|
||||
},
|
||||
)
|
||||
if etudid:
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription ins
|
||||
SET parcour_id=:parcour_id
|
||||
FROM group_membership gm
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
AND ins.etudid = :etudid
|
||||
AND gm.etudid = :etudid
|
||||
AND gm.group_id = :group_id
|
||||
"""
|
||||
),
|
||||
{
|
||||
"etudid": etudid,
|
||||
"formsemestre_id": self.id,
|
||||
"parcour_id": parcour.id,
|
||||
"group_id": group.id,
|
||||
},
|
||||
)
|
||||
else:
|
||||
db.session.execute(
|
||||
text(
|
||||
"""UPDATE notes_formsemestre_inscription ins
|
||||
SET parcour_id=:parcour_id
|
||||
FROM group_membership gm
|
||||
WHERE formsemestre_id=:formsemestre_id
|
||||
AND gm.etudid = ins.etudid
|
||||
AND gm.group_id = :group_id
|
||||
"""
|
||||
),
|
||||
{
|
||||
"formsemestre_id": self.id,
|
||||
"parcour_id": parcour.id,
|
||||
"group_id": group.id,
|
||||
},
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
def etud_validations_description_html(self, etudid: int) -> str:
|
||||
|
@ -314,7 +314,7 @@ def do_formsemestre_inscription_with_modules(
|
||||
formsemestre_id=formsemestre_id,
|
||||
)
|
||||
# Mise à jour des inscriptions aux parcours:
|
||||
formsemestre.update_inscriptions_parcours_from_groups()
|
||||
formsemestre.update_inscriptions_parcours_from_groups(etudid=etudid)
|
||||
|
||||
|
||||
def formsemestre_inscription_with_modules_etud(
|
||||
|
@ -684,7 +684,7 @@ def change_etud_group_in_partition(etudid: int, group: GroupDescr) -> bool:
|
||||
|
||||
# - Update parcours
|
||||
if group.partition.partition_name == scu.PARTITION_PARCOURS:
|
||||
formsemestre.update_inscriptions_parcours_from_groups()
|
||||
formsemestre.update_inscriptions_parcours_from_groups(etudid=etudid)
|
||||
|
||||
# - invalidate cache
|
||||
sco_cache.invalidate_formsemestre(
|
||||
|
Loading…
Reference in New Issue
Block a user