Nettoyage code + exception save note

This commit is contained in:
Emmanuel Viennet 2023-05-29 16:04:41 +02:00 committed by iziram
parent 2a63533fc0
commit d8f1a617bf

View File

@ -583,12 +583,8 @@ def notes_add(
existing_note = NotesNotes.query.filter_by(
evaluation_id=evaluation_id, etudid=etudid
).first()
sco_cache.EvaluationCache.delete(evaluation_id)
notes_db = sco_evaluation_db.do_evaluation_get_all_notes(
evaluation_id
)
raise ScoBugCatcher(
f"dup: existing={existing_note} etudid={repr(etudid)} value={value} in_db={etudid in notes_db}"
f"dup: existing={existing_note}"
) from exc
changed = True
else:
@ -885,12 +881,20 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
indication_date = evaluation.jour.isoformat()
else:
indication_date = scu.sanitize_filename(evaluation.description or "")[:12]
eval_name = f"{evaluation.moduleimpl.module.code}-{indication_date}"
eval_name = "%s-%s" % (evaluation.moduleimpl.module.code, indication_date)
date_str = (
f"""du {evaluation.jour.strftime("%d/%m/%Y")}"""
if evaluation.jour
else "(sans date)"
if evaluation.description:
evaltitre = "%s du %s" % (
evaluation.description,
evaluation.jour.strftime("%d/%m/%Y"),
)
else:
evaltitre = "évaluation du %s" % evaluation.jour.strftime("%d/%m/%Y")
description = "%s en %s (%s) resp. %s" % (
evaltitre,
evaluation.moduleimpl.module.abbrev or "",
evaluation.moduleimpl.module.code,
mod_responsable["prenomnom"],
)
eval_titre = f"""{evaluation.description if evaluation.description else "évaluation"} {date_str}"""
@ -941,7 +945,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
filename = f"notes_{eval_name}_{gr_title_filename}"
xls = sco_excel.excel_feuille_saisie(
evaluation, formsemestre.titre_annee(), description, lines=rows
evaluation, formsemestre.titre_annee(), description, lines=L
)
return scu.send_file(xls, filename, scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE)