forked from ScoDoc/ScoDoc
fonction get_formsemestre_bulletin_etud_json
This commit is contained in:
parent
5379e4b93a
commit
d000e7b5a7
@ -7,7 +7,6 @@ from app.comp import df_cache
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models.modules import Module
|
||||
from app.models.ues import UniteEns
|
||||
from app.scodoc import notesdb as ndb
|
||||
from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_codes_parcours
|
||||
from app.scodoc import sco_utils as scu
|
||||
|
@ -32,7 +32,7 @@ import email
|
||||
import time
|
||||
|
||||
from flask import g, request
|
||||
from flask import flash, render_template, url_for
|
||||
from flask import flash, jsonify, render_template, url_for
|
||||
from flask_login import current_user
|
||||
|
||||
from app import email
|
||||
@ -76,6 +76,34 @@ from app.scodoc import sco_bulletins_legacy
|
||||
from app.scodoc import sco_bulletins_ucac # format expérimental UCAC Cameroun
|
||||
|
||||
|
||||
def get_formsemestre_bulletin_etud_json(
|
||||
formsemestre: FormSemestre,
|
||||
etud: Identite,
|
||||
force_publishing=False,
|
||||
version="long",
|
||||
) -> str:
|
||||
"""Le JSON du bulletin d'un étudiant, quel que soit le type de formation."""
|
||||
if formsemestre.formation.is_apc():
|
||||
r = bulletin_but.BulletinBUT(formsemestre)
|
||||
return jsonify(
|
||||
r.bulletin_etud(
|
||||
etud,
|
||||
formsemestre,
|
||||
force_publishing=force_publishing,
|
||||
version=version,
|
||||
)
|
||||
)
|
||||
return formsemestre_bulletinetud(
|
||||
etud,
|
||||
formsemestre_id=formsemestre.id,
|
||||
format="json",
|
||||
version=version,
|
||||
xml_with_decisions=True,
|
||||
force_publishing=force_publishing,
|
||||
)
|
||||
|
||||
|
||||
# -------------
|
||||
def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict:
|
||||
"""Construit dictionnaire avec valeurs pour substitution des textes
|
||||
(preferences bul_pdf_*)
|
||||
@ -799,7 +827,10 @@ def formsemestre_bulletinetud(
|
||||
force_publishing=False, # force publication meme si semestre non publie sur "portail"
|
||||
prefer_mail_perso=False,
|
||||
):
|
||||
"page bulletin de notes"
|
||||
"""Page bulletin de notes
|
||||
pour les formations classiques hors BUT (page HTML)
|
||||
ou le format "oldjson".
|
||||
"""
|
||||
format = format or "html"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||
if not formsemestre:
|
||||
|
@ -312,53 +312,42 @@ def formsemestre_bulletinetud(
|
||||
raise ScoValueError(
|
||||
"Paramètre manquant: spécifier etudid, code_nip ou code_ine"
|
||||
)
|
||||
if formsemestre.formation.is_apc() and format != "oldjson":
|
||||
if format == "json":
|
||||
r = bulletin_but.BulletinBUT(formsemestre)
|
||||
return jsonify(
|
||||
r.bulletin_etud(
|
||||
etud,
|
||||
formsemestre,
|
||||
force_publishing=force_publishing,
|
||||
version=version,
|
||||
)
|
||||
)
|
||||
elif format == "html":
|
||||
return render_template(
|
||||
"but/bulletin.html",
|
||||
appreciations=models.BulAppreciations.query.filter_by(
|
||||
etudid=etudid, formsemestre_id=formsemestre.id
|
||||
).order_by(models.BulAppreciations.date),
|
||||
bul_url=url_for(
|
||||
"notes.formsemestre_bulletinetud",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre_id,
|
||||
etudid=etudid,
|
||||
format="json",
|
||||
force_publishing=1, # pour ScoDoc lui même
|
||||
version=version,
|
||||
),
|
||||
can_edit_appreciations=formsemestre.est_responsable(current_user)
|
||||
or (current_user.has_permission(Permission.ScoEtudInscrit)),
|
||||
etud=etud,
|
||||
formsemestre=formsemestre,
|
||||
inscription_courante=etud.inscription_courante(),
|
||||
inscription_str=etud.inscription_descr()["inscription_str"],
|
||||
is_apc=formsemestre.formation.is_apc(),
|
||||
menu_autres_operations=sco_bulletins.make_menu_autres_operations(
|
||||
formsemestre, etud, "notes.formsemestre_bulletinetud", version
|
||||
),
|
||||
sco=ScoData(etud=etud),
|
||||
scu=scu,
|
||||
time=time,
|
||||
title=f"Bul. {etud.nom} - BUT",
|
||||
version=version,
|
||||
)
|
||||
|
||||
if not (etudid or code_nip or code_ine):
|
||||
raise ScoValueError(
|
||||
"Paramètre manquant: spécifier code_nip ou etudid ou code_ine"
|
||||
if format == "json":
|
||||
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
||||
formsemestre, etud, version=version
|
||||
)
|
||||
if formsemestre.formation.is_apc() and format == "html":
|
||||
return render_template(
|
||||
"but/bulletin.html",
|
||||
appreciations=models.BulAppreciations.query.filter_by(
|
||||
etudid=etudid, formsemestre_id=formsemestre.id
|
||||
).order_by(models.BulAppreciations.date),
|
||||
bul_url=url_for(
|
||||
"notes.formsemestre_bulletinetud",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
formsemestre_id=formsemestre_id,
|
||||
etudid=etudid,
|
||||
format="json",
|
||||
force_publishing=1, # pour ScoDoc lui même
|
||||
version=version,
|
||||
),
|
||||
can_edit_appreciations=formsemestre.est_responsable(current_user)
|
||||
or (current_user.has_permission(Permission.ScoEtudInscrit)),
|
||||
etud=etud,
|
||||
formsemestre=formsemestre,
|
||||
inscription_courante=etud.inscription_courante(),
|
||||
inscription_str=etud.inscription_descr()["inscription_str"],
|
||||
is_apc=formsemestre.formation.is_apc(),
|
||||
menu_autres_operations=sco_bulletins.make_menu_autres_operations(
|
||||
formsemestre, etud, "notes.formsemestre_bulletinetud", version
|
||||
),
|
||||
sco=ScoData(etud=etud),
|
||||
scu=scu,
|
||||
time=time,
|
||||
title=f"Bul. {etud.nom} - BUT",
|
||||
version=version,
|
||||
)
|
||||
|
||||
if format == "oldjson":
|
||||
format = "json"
|
||||
r = sco_bulletins.formsemestre_bulletinetud(
|
||||
|
Loading…
Reference in New Issue
Block a user