forked from ScoDoc/ScoDoc
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[
|
u[
|
||||||
"modules_capitalized"
|
"modules_capitalized"
|
||||||
] = [] # modules de l'UE capitalisée (liste vide si pas capitalisée)
|
] = [] # modules de l'UE capitalisée (liste vide si pas capitalisée)
|
||||||
if ue_status["is_capitalized"]:
|
if ue_status["is_capitalized"] and ue_status["formsemestre_id"] is not None:
|
||||||
sem_origin = sco_formsemestre.get_formsemestre(ue_status["formsemestre_id"])
|
sem_origin = FormSemestre.query.get(ue_status["formsemestre_id"])
|
||||||
u["ue_descr_txt"] = "capitalisée le %s" % ndb.DateISOtoDMY(
|
|
||||||
ue_status["event_date"]
|
|
||||||
)
|
|
||||||
u[
|
u[
|
||||||
"ue_descr_html"
|
"ue_descr_txt"
|
||||||
] = f"""<a href="{ url_for( 'notes.formsemestre_bulletinetud',
|
] = f'capitalisée le {ndb.DateISOtoDMY(ue_status["event_date"])}'
|
||||||
scodoc_dept=g.scodoc_dept, formsemestre_id=sem_origin['formsemestre_id'], etudid=etudid)}"
|
u["ue_descr_html"] = (
|
||||||
title="{sem_origin['titreannee']}" class="bull_link"
|
f"""<a href="{ url_for( 'notes.formsemestre_bulletinetud',
|
||||||
>{u["ue_descr_txt"]} pouet</a>
|
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
|
||||||
# détail des modules de l'UE capitalisée
|
else ""
|
||||||
formsemestre_cap = FormSemestre.query.get_or_404(
|
|
||||||
ue_status["formsemestre_id"]
|
|
||||||
)
|
)
|
||||||
|
if ue_status["moy"] != "NA":
|
||||||
|
# détail des modules de l'UE capitalisée
|
||||||
|
formsemestre_cap = FormSemestre.query.get(ue_status["formsemestre_id"])
|
||||||
nt_cap: NotesTableCompat = res_sem.load_formsemestre_results(
|
nt_cap: NotesTableCompat = res_sem.load_formsemestre_results(
|
||||||
formsemestre_cap
|
formsemestre_cap
|
||||||
)
|
)
|
||||||
@ -712,7 +712,6 @@ def etud_descr_situation_semestre(
|
|||||||
infos = scu.DictDefault(defaultvalue="")
|
infos = scu.DictDefault(defaultvalue="")
|
||||||
|
|
||||||
# --- Situation et décisions jury
|
# --- Situation et décisions jury
|
||||||
|
|
||||||
# démission/inscription ?
|
# démission/inscription ?
|
||||||
events = sco_etud.scolar_events_list(
|
events = sco_etud.scolar_events_list(
|
||||||
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
|
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
|
||||||
@ -763,11 +762,17 @@ def etud_descr_situation_semestre(
|
|||||||
infos["descr_inscription"] = ""
|
infos["descr_inscription"] = ""
|
||||||
|
|
||||||
infos["situation"] = 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:
|
if date_dem:
|
||||||
infos["descr_demission"] = f"Démission le {date_dem}."
|
infos["descr_demission"] = f"Démission le {date_dem}."
|
||||||
infos["date_demission"] = 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"]
|
infos["situation"] += " " + infos["descr_demission"]
|
||||||
return infos, None # ne donne pas les dec. de jury pour les demissionnaires
|
return infos, None # ne donne pas les dec. de jury pour les demissionnaires
|
||||||
if date_def:
|
if date_def:
|
||||||
@ -779,8 +784,6 @@ def etud_descr_situation_semestre(
|
|||||||
dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=[etudid])
|
dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=[etudid])
|
||||||
if dpv:
|
if dpv:
|
||||||
infos["decision_sem"] = dpv["decisions"][0]["decision_sem"]
|
infos["decision_sem"] = dpv["decisions"][0]["decision_sem"]
|
||||||
else:
|
|
||||||
infos["decision_sem"] = ""
|
|
||||||
|
|
||||||
if not show_decisions:
|
if not show_decisions:
|
||||||
return infos, dpv
|
return infos, dpv
|
||||||
@ -803,7 +806,7 @@ def etud_descr_situation_semestre(
|
|||||||
infos["descr_decisions_ue"] = " UE acquises: " + pv["decisions_ue_descr"] + ". "
|
infos["descr_decisions_ue"] = " UE acquises: " + pv["decisions_ue_descr"] + ". "
|
||||||
dec += infos["descr_decisions_ue"]
|
dec += infos["descr_decisions_ue"]
|
||||||
else:
|
else:
|
||||||
# infos['decisions_ue'] = None
|
infos["decisions_ue"] = ""
|
||||||
infos["descr_decisions_ue"] = ""
|
infos["descr_decisions_ue"] = ""
|
||||||
|
|
||||||
infos["mention"] = pv["mention"]
|
infos["mention"] = pv["mention"]
|
||||||
@ -842,9 +845,20 @@ def formsemestre_bulletinetud(
|
|||||||
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
||||||
prefer_mail_perso=False,
|
prefer_mail_perso=False,
|
||||||
):
|
):
|
||||||
"""Page bulletin de notes
|
"""Page bulletin de notes pour
|
||||||
pour les formations classiques hors BUT (page HTML)
|
- HTML des formations classiques (non BUT)
|
||||||
ou le format "oldjson".
|
- 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"
|
format = format or "html"
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
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
|
prefer_mail_perso=False, # mails envoyés sur adresse perso si non vide
|
||||||
):
|
):
|
||||||
"""Génère le bulletin au format demandé.
|
"""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)
|
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").
|
et filigranne est un message à placer en "filigranne" (eg "Provisoire").
|
||||||
"""
|
"""
|
||||||
@ -919,7 +938,7 @@ def do_formsemestre_bulletinetud(
|
|||||||
|
|
||||||
return bul, ""
|
return bul, ""
|
||||||
|
|
||||||
elif format == "json":
|
elif format == "json": # utilisé pour classic et "oldjson"
|
||||||
bul = sco_bulletins_json.make_json_formsemestre_bulletinetud(
|
bul = sco_bulletins_json.make_json_formsemestre_bulletinetud(
|
||||||
formsemestre.id,
|
formsemestre.id,
|
||||||
etudid,
|
etudid,
|
||||||
@ -932,20 +951,20 @@ def do_formsemestre_bulletinetud(
|
|||||||
if formsemestre.formation.is_apc():
|
if formsemestre.formation.is_apc():
|
||||||
etudiant = Identite.query.get(etudid)
|
etudiant = Identite.query.get(etudid)
|
||||||
r = bulletin_but.BulletinBUT(formsemestre)
|
r = bulletin_but.BulletinBUT(formsemestre)
|
||||||
I = r.bulletin_etud_complet(etudiant, version=version)
|
infos = r.bulletin_etud_complet(etudiant, version=version)
|
||||||
else:
|
else:
|
||||||
I = formsemestre_bulletinetud_dict(formsemestre.id, etudid)
|
infos = formsemestre_bulletinetud_dict(formsemestre.id, etudid)
|
||||||
etud = I["etud"]
|
etud = infos["etud"]
|
||||||
|
|
||||||
if format == "html":
|
if format == "html":
|
||||||
htm, _ = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
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":
|
elif format == "pdf" or format == "pdfpart":
|
||||||
bul, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
bul, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
||||||
I,
|
infos,
|
||||||
version=version,
|
version=version,
|
||||||
format="pdf",
|
format="pdf",
|
||||||
stand_alone=(format != "pdfpart"),
|
stand_alone=(format != "pdfpart"),
|
||||||
@ -953,10 +972,10 @@ def do_formsemestre_bulletinetud(
|
|||||||
if format == "pdf":
|
if format == "pdf":
|
||||||
return (
|
return (
|
||||||
scu.sendPDFFile(bul, filename),
|
scu.sendPDFFile(bul, filename),
|
||||||
I["filigranne"],
|
infos["filigranne"],
|
||||||
) # unused ret. value
|
) # unused ret. value
|
||||||
else:
|
else:
|
||||||
return bul, I["filigranne"]
|
return bul, infos["filigranne"]
|
||||||
|
|
||||||
elif format == "pdfmail":
|
elif format == "pdfmail":
|
||||||
# format pdfmail: envoie le pdf par mail a l'etud, et affiche le html
|
# 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 !")
|
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||||
|
|
||||||
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
|
||||||
I, version=version, format="pdf"
|
infos, version=version, format="pdf"
|
||||||
)
|
)
|
||||||
|
|
||||||
if prefer_mail_perso:
|
if prefer_mail_perso:
|
||||||
@ -975,21 +994,21 @@ def do_formsemestre_bulletinetud(
|
|||||||
|
|
||||||
if not recipient_addr:
|
if not recipient_addr:
|
||||||
flash(f"{etud['nomprenom']} n'a pas d'adresse e-mail !")
|
flash(f"{etud['nomprenom']} n'a pas d'adresse e-mail !")
|
||||||
return False, I["filigranne"]
|
return False, infos["filigranne"]
|
||||||
else:
|
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}")
|
flash(f"mail envoyé à {recipient_addr}")
|
||||||
|
|
||||||
return True, I["filigranne"]
|
return True, infos["filigranne"]
|
||||||
|
|
||||||
raise ValueError("do_formsemestre_bulletinetud: invalid format (%s)" % format)
|
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
|
"""Send bulletin by email to etud
|
||||||
If bul_mail_list_abs pref is true, put list of absences in mail body (text).
|
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)
|
webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id)
|
||||||
dept = scu.unescape_html(
|
dept = scu.unescape_html(
|
||||||
sco_preferences.get_preference("DeptName", formsemestre_id)
|
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"
|
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]
|
recipients = [recipient_addr]
|
||||||
sender = sco_preferences.get_preference("email_from_addr", formsemestre_id)
|
sender = sco_preferences.get_preference("email_from_addr", formsemestre_id)
|
||||||
if copy_addr:
|
if copy_addr:
|
||||||
@ -1025,7 +1044,7 @@ def mail_bulletin(formsemestre_id, I, pdfdata, filename, recipient_addr):
|
|||||||
bcc = ""
|
bcc = ""
|
||||||
|
|
||||||
# Attach pdf
|
# Attach pdf
|
||||||
log("mail bulletin a %s" % recipient_addr)
|
log(f"""mail bulletin a {recipient_addr}""")
|
||||||
email.send_email(
|
email.send_email(
|
||||||
subject,
|
subject,
|
||||||
sender,
|
sender,
|
||||||
|
Loading…
Reference in New Issue
Block a user