forked from ScoDoc/DocScoDoc
Corrections diverses du code bulletins
This commit is contained in:
parent
45d3106272
commit
b34484784a
@ -347,23 +347,23 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
|
||||
u[
|
||||
"modules_capitalized"
|
||||
] = [] # modules de l'UE capitalisée (liste vide si pas capitalisée)
|
||||
if ue_status["is_capitalized"]:
|
||||
sem_origin = sco_formsemestre.get_formsemestre(ue_status["formsemestre_id"])
|
||||
u["ue_descr_txt"] = "capitalisée le %s" % ndb.DateISOtoDMY(
|
||||
ue_status["event_date"]
|
||||
)
|
||||
if ue_status["is_capitalized"] and ue_status["formsemestre_id"] is not None:
|
||||
sem_origin = FormSemestre.query.get(ue_status["formsemestre_id"])
|
||||
u[
|
||||
"ue_descr_html"
|
||||
] = f"""<a href="{ url_for( 'notes.formsemestre_bulletinetud',
|
||||
scodoc_dept=g.scodoc_dept, formsemestre_id=sem_origin['formsemestre_id'], etudid=etudid)}"
|
||||
title="{sem_origin['titreannee']}" class="bull_link"
|
||||
>{u["ue_descr_txt"]} pouet</a>
|
||||
"ue_descr_txt"
|
||||
] = f'capitalisée le {ndb.DateISOtoDMY(ue_status["event_date"])}'
|
||||
u["ue_descr_html"] = (
|
||||
f"""<a href="{ url_for( 'notes.formsemestre_bulletinetud',
|
||||
scodoc_dept=g.scodoc_dept, formsemestre_id=sem_origin.id, etudid=etudid)}"
|
||||
title="{sem_origin.titre_annee()}" class="bull_link"
|
||||
>{u["ue_descr_txt"]}</a>
|
||||
"""
|
||||
if ue_status["moy"] != "NA" and ue_status["formsemestre_id"]:
|
||||
if sem_origin
|
||||
else ""
|
||||
)
|
||||
if ue_status["moy"] != "NA":
|
||||
# détail des modules de l'UE capitalisée
|
||||
formsemestre_cap = FormSemestre.query.get_or_404(
|
||||
ue_status["formsemestre_id"]
|
||||
)
|
||||
formsemestre_cap = FormSemestre.query.get(ue_status["formsemestre_id"])
|
||||
nt_cap: NotesTableCompat = res_sem.load_formsemestre_results(
|
||||
formsemestre_cap
|
||||
)
|
||||
@ -712,7 +712,6 @@ def etud_descr_situation_semestre(
|
||||
infos = scu.DictDefault(defaultvalue="")
|
||||
|
||||
# --- Situation et décisions jury
|
||||
|
||||
# démission/inscription ?
|
||||
events = sco_etud.scolar_events_list(
|
||||
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
|
||||
@ -763,11 +762,17 @@ def etud_descr_situation_semestre(
|
||||
infos["descr_inscription"] = ""
|
||||
|
||||
infos["situation"] = infos["descr_inscription"]
|
||||
# Décision: valeurs par defaut vides:
|
||||
infos["decision_jury"] = infos["descr_decision_jury"] = ""
|
||||
infos["decision_sem"] = ""
|
||||
infos["decisions_ue"] = infos["descr_decisions_ue"] = ""
|
||||
infos["descr_decisions_niveaux"] = infos["descr_decisions_rcue"] = ""
|
||||
infos["descr_decision_annee"] = ""
|
||||
|
||||
if date_dem:
|
||||
infos["descr_demission"] = f"Démission le {date_dem}."
|
||||
infos["date_demission"] = date_dem
|
||||
infos["descr_decision_jury"] = "Démission"
|
||||
infos["decision_jury"] = infos["descr_decision_jury"] = "Démission"
|
||||
infos["situation"] += " " + infos["descr_demission"]
|
||||
return infos, None # ne donne pas les dec. de jury pour les demissionnaires
|
||||
if date_def:
|
||||
@ -779,8 +784,6 @@ def etud_descr_situation_semestre(
|
||||
dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=[etudid])
|
||||
if dpv:
|
||||
infos["decision_sem"] = dpv["decisions"][0]["decision_sem"]
|
||||
else:
|
||||
infos["decision_sem"] = ""
|
||||
|
||||
if not show_decisions:
|
||||
return infos, dpv
|
||||
@ -803,7 +806,7 @@ def etud_descr_situation_semestre(
|
||||
infos["descr_decisions_ue"] = " UE acquises: " + pv["decisions_ue_descr"] + ". "
|
||||
dec += infos["descr_decisions_ue"]
|
||||
else:
|
||||
# infos['decisions_ue'] = None
|
||||
infos["decisions_ue"] = ""
|
||||
infos["descr_decisions_ue"] = ""
|
||||
|
||||
infos["mention"] = pv["mention"]
|
||||
@ -842,9 +845,20 @@ def formsemestre_bulletinetud(
|
||||
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
||||
prefer_mail_perso=False,
|
||||
):
|
||||
"""Page bulletin de notes
|
||||
pour les formations classiques hors BUT (page HTML)
|
||||
ou le format "oldjson".
|
||||
"""Page bulletin de notes pour
|
||||
- HTML des formations classiques (non BUT)
|
||||
- le format "oldjson" (les "json" sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
||||
- les formats PDF, XML et mail pdf (toutes formations)
|
||||
|
||||
Note: le format XML n'est plus maintenu et pour les BUT ne contient pas
|
||||
toutes les informations. Privilégier le format JSON.
|
||||
|
||||
Paramètres:
|
||||
- version: pour les formations classqiues, versions short/selectedevals/long
|
||||
- xml_with_decisions: inclue ou non les
|
||||
- force_publishing: renvoie le bulletin même si semestre non publie sur "portail"
|
||||
- prefer_mail_perso: pour pdfmail, utilise adresse mail perso en priorité.
|
||||
|
||||
"""
|
||||
format = format or "html"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||
@ -903,7 +917,12 @@ def do_formsemestre_bulletinetud(
|
||||
prefer_mail_perso=False, # mails envoyés sur adresse perso si non vide
|
||||
):
|
||||
"""Génère le bulletin au format demandé.
|
||||
Retourne: (bul, filigranne)
|
||||
Utilisé pour:
|
||||
- HTML des formations classiques (non BUT)
|
||||
- le format "oldjson" (les json sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
||||
- les formats PDF, XML et mail pdf (toutes formations)
|
||||
|
||||
Résultat: (bul, filigranne)
|
||||
où bul est str ou bytes au format demandé (html, pdf, pdfmail, pdfpart, xml, json)
|
||||
et filigranne est un message à placer en "filigranne" (eg "Provisoire").
|
||||
"""
|
||||
@ -919,7 +938,7 @@ def do_formsemestre_bulletinetud(
|
||||
|
||||
return bul, ""
|
||||
|
||||
elif format == "json":
|
||||
elif format == "json": # utilisé pour classic et "oldjson"
|
||||
bul = sco_bulletins_json.make_json_formsemestre_bulletinetud(
|
||||
formsemestre.id,
|
||||
etudid,
|
||||
@ -932,20 +951,20 @@ def do_formsemestre_bulletinetud(
|
||||
if formsemestre.formation.is_apc():
|
||||
etudiant = Identite.query.get(etudid)
|
||||
r = bulletin_but.BulletinBUT(formsemestre)
|
||||
I = r.bulletin_etud_complet(etudiant, version=version)
|
||||
infos = r.bulletin_etud_complet(etudiant, version=version)
|
||||
else:
|
||||
I = formsemestre_bulletinetud_dict(formsemestre.id, etudid)
|
||||
etud = I["etud"]
|
||||
infos = formsemestre_bulletinetud_dict(formsemestre.id, etudid)
|
||||
etud = infos["etud"]
|
||||
|
||||
if format == "html":
|
||||
htm, _ = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
||||
I, version=version, format="html"
|
||||
infos, version=version, format="html"
|
||||
)
|
||||
return htm, I["filigranne"]
|
||||
return htm, infos["filigranne"]
|
||||
|
||||
elif format == "pdf" or format == "pdfpart":
|
||||
bul, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
||||
I,
|
||||
infos,
|
||||
version=version,
|
||||
format="pdf",
|
||||
stand_alone=(format != "pdfpart"),
|
||||
@ -953,10 +972,10 @@ def do_formsemestre_bulletinetud(
|
||||
if format == "pdf":
|
||||
return (
|
||||
scu.sendPDFFile(bul, filename),
|
||||
I["filigranne"],
|
||||
infos["filigranne"],
|
||||
) # unused ret. value
|
||||
else:
|
||||
return bul, I["filigranne"]
|
||||
return bul, infos["filigranne"]
|
||||
|
||||
elif format == "pdfmail":
|
||||
# format pdfmail: envoie le pdf par mail a l'etud, et affiche le html
|
||||
@ -965,7 +984,7 @@ def do_formsemestre_bulletinetud(
|
||||
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||
|
||||
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
||||
I, version=version, format="pdf"
|
||||
infos, version=version, format="pdf"
|
||||
)
|
||||
|
||||
if prefer_mail_perso:
|
||||
@ -975,21 +994,21 @@ def do_formsemestre_bulletinetud(
|
||||
|
||||
if not recipient_addr:
|
||||
flash(f"{etud['nomprenom']} n'a pas d'adresse e-mail !")
|
||||
return False, I["filigranne"]
|
||||
return False, infos["filigranne"]
|
||||
else:
|
||||
mail_bulletin(formsemestre.id, I, pdfdata, filename, recipient_addr)
|
||||
mail_bulletin(formsemestre.id, infos, pdfdata, filename, recipient_addr)
|
||||
flash(f"mail envoyé à {recipient_addr}")
|
||||
|
||||
return True, I["filigranne"]
|
||||
return True, infos["filigranne"]
|
||||
|
||||
raise ValueError("do_formsemestre_bulletinetud: invalid format (%s)" % format)
|
||||
|
||||
|
||||
def mail_bulletin(formsemestre_id, I, pdfdata, filename, recipient_addr):
|
||||
def mail_bulletin(formsemestre_id, infos, pdfdata, filename, recipient_addr):
|
||||
"""Send bulletin by email to etud
|
||||
If bul_mail_list_abs pref is true, put list of absences in mail body (text).
|
||||
"""
|
||||
etud = I["etud"]
|
||||
etud = infos["etud"]
|
||||
webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id)
|
||||
dept = scu.unescape_html(
|
||||
sco_preferences.get_preference("DeptName", formsemestre_id)
|
||||
@ -1016,7 +1035,7 @@ def mail_bulletin(formsemestre_id, I, pdfdata, filename, recipient_addr):
|
||||
etud["etudid"], with_evals=False, format="text"
|
||||
)
|
||||
|
||||
subject = "Relevé de notes de %s" % etud["nomprenom"]
|
||||
subject = f"""Relevé de notes de {etud["nomprenom"]}"""
|
||||
recipients = [recipient_addr]
|
||||
sender = sco_preferences.get_preference("email_from_addr", formsemestre_id)
|
||||
if copy_addr:
|
||||
@ -1025,7 +1044,7 @@ def mail_bulletin(formsemestre_id, I, pdfdata, filename, recipient_addr):
|
||||
bcc = ""
|
||||
|
||||
# Attach pdf
|
||||
log("mail bulletin a %s" % recipient_addr)
|
||||
log(f"""mail bulletin a {recipient_addr}""")
|
||||
email.send_email(
|
||||
subject,
|
||||
sender,
|
||||
|
Loading…
Reference in New Issue
Block a user