1
0
forked from ScoDoc/ScoDoc

Fix: UE delete

This commit is contained in:
Emmanuel Viennet 2022-05-10 17:56:21 +02:00
parent 272a57d1c8
commit 0d638de209

View File

@ -156,6 +156,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
from app.scodoc import sco_parcours_dut from app.scodoc import sco_parcours_dut
ue = UniteEns.query.get_or_404(ue_id) ue = UniteEns.query.get_or_404(ue_id)
formation_id = ue.formation_id
semestre_idx = ue.semestre_idx
if not can_delete_ue(ue): if not can_delete_ue(ue):
raise ScoNonEmptyFormationObject( raise ScoNonEmptyFormationObject(
"UE", "UE",
@ -163,8 +165,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
dest_url=url_for( dest_url=url_for(
"notes.ue_table", "notes.ue_table",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formation_id=ue.formation_id, formation_id=formation_id,
semestre_idx=ue.semestre_idx, semestre_idx=semestre_idx,
), ),
) )
@ -187,13 +189,13 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
cancel_url=url_for( cancel_url=url_for(
"notes.ue_table", "notes.ue_table",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formation_id=ue.formation_id, formation_id=formation_id,
semestre_idx=ue.semestre_idx, semestre_idx=semestre_idx,
), ),
parameters={"ue_id": ue.id, "dialog_confirmed": 1}, parameters={"ue_id": ue.id, "dialog_confirmed": 1},
) )
if delete_validations: if delete_validations:
log("deleting all validations of UE %s" % ue.id) log(f"deleting all validations of UE {ue.id}")
ndb.SimpleQuery( ndb.SimpleQuery(
"DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s", "DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s",
{"ue_id": ue.id}, {"ue_id": ue.id},
@ -215,10 +217,10 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
# utilisé: acceptable de tout invalider): # utilisé: acceptable de tout invalider):
sco_cache.invalidate_formsemestre() sco_cache.invalidate_formsemestre()
# news # news
F = sco_formations.formation_list(args={"formation_id": ue.formation_id})[0] F = sco_formations.formation_list(args={"formation_id": formation_id})[0]
ScolarNews.add( ScolarNews.add(
typ=ScolarNews.NEWS_FORM, typ=ScolarNews.NEWS_FORM,
obj=ue.formation_id, obj=formation_id,
text=f"Modification de la formation {F['acronyme']}", text=f"Modification de la formation {F['acronyme']}",
max_frequency=10 * 60, max_frequency=10 * 60,
) )
@ -228,8 +230,8 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
url_for( url_for(
"notes.ue_table", "notes.ue_table",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formation_id=ue.formation_id, formation_id=formation_id,
semestre_idx=ue.semestre_idx, semestre_idx=semestre_idx,
) )
) )
return None return None