Réglage publication bulletin JSON

This commit is contained in:
Emmanuel Viennet 2022-01-25 13:24:08 +01:00
parent a78bb4bc1c
commit 4133b9df6a
4 changed files with 16 additions and 6 deletions

View File

@ -219,13 +219,18 @@ class ResultatsSemestreBUT:
} }
return d return d
def bulletin_etud(self, etud, formsemestre) -> dict: def bulletin_etud(self, etud, formsemestre, force_publishing=False) -> dict:
"""Le bulletin de l'étudiant dans ce semestre""" """Le bulletin de l'étudiant dans ce semestre.
Si force_publishing, rempli le bulletin même si bul_hide_xml est vrai
(bulletins non publiés).
"""
etat_inscription = etud.etat_inscription(formsemestre.id) etat_inscription = etud.etat_inscription(formsemestre.id)
published = (not formsemestre.bul_hide_xml) or force_publishing
d = { d = {
"version": "0", "version": "0",
"type": "BUT", "type": "BUT",
"date": datetime.datetime.utcnow().isoformat() + "Z", "date": datetime.datetime.utcnow().isoformat() + "Z",
"publie": not formsemestre.bul_hide_xml,
"etudiant": etud.to_dict_bul(), "etudiant": etud.to_dict_bul(),
"formation": { "formation": {
"id": formsemestre.formation.id, "id": formsemestre.formation.id,
@ -237,6 +242,8 @@ class ResultatsSemestreBUT:
"etat_inscription": etat_inscription, "etat_inscription": etat_inscription,
"options": bulletin_option_affichage(formsemestre), "options": bulletin_option_affichage(formsemestre),
} }
if not published:
return d
semestre_infos = { semestre_infos = {
"etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo], "etapes": [str(x.etape_apo) for x in formsemestre.etapes if x.etape_apo],
"date_debut": formsemestre.date_debut.isoformat(), "date_debut": formsemestre.date_debut.isoformat(),

View File

@ -98,9 +98,9 @@ def formsemestre_bulletinetud_published_dict(
d = {} d = {}
if (not sem["bul_hide_xml"]) or force_publishing: if (not sem["bul_hide_xml"]) or force_publishing:
published = 1 published = True
else: else:
published = 0 published = False
if xml_nodate: if xml_nodate:
docdate = "" docdate = ""
else: else:

View File

@ -307,7 +307,9 @@ def formsemestre_bulletinetud(
) )
if format == "json": if format == "json":
r = bulletin_but.ResultatsSemestreBUT(formsemestre) r = bulletin_but.ResultatsSemestreBUT(formsemestre)
return jsonify(r.bulletin_etud(etud, formsemestre)) return jsonify(
r.bulletin_etud(etud, formsemestre, force_publishing=force_publishing)
)
elif format == "html": elif format == "html":
return render_template( return render_template(
"but/bulletin.html", "but/bulletin.html",
@ -318,6 +320,7 @@ def formsemestre_bulletinetud(
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
etudid=etudid, etudid=etudid,
format="json", format="json",
force_publishing=1, # pour ScoDoc lui même
), ),
sco=ScoData(), sco=ScoData(),
) )

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.1.32" SCOVERSION = "9.1.33"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"