forked from ScoDoc/ScoDoc
retire arguments REQUEST de sendResult et sendPDFFile
This commit is contained in:
parent
2c97349acf
commit
f516ccdfe7
@ -903,7 +903,7 @@ def do_formsemestre_bulletinetud(
|
|||||||
)
|
)
|
||||||
if format == "pdf":
|
if format == "pdf":
|
||||||
return (
|
return (
|
||||||
scu.sendPDFFile(REQUEST, bul, filename),
|
scu.sendPDFFile(bul, filename),
|
||||||
I["filigranne"],
|
I["filigranne"],
|
||||||
) # unused ret. value
|
) # unused ret. value
|
||||||
else:
|
else:
|
||||||
|
@ -132,9 +132,7 @@ def formation_export(
|
|||||||
if mod["ects"] is None:
|
if mod["ects"] is None:
|
||||||
del mod["ects"]
|
del mod["ects"]
|
||||||
|
|
||||||
return scu.sendResult(
|
return scu.sendResult(F, name="formation", format=format, force_outer_xml_tag=False)
|
||||||
REQUEST, F, name="formation", format=format, force_outer_xml_tag=False
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def formation_import_xml(doc: str, import_tags=True):
|
def formation_import_xml(doc: str, import_tags=True):
|
||||||
|
@ -476,7 +476,7 @@ def formsemestre_partition_list(formsemestre_id, format="xml", REQUEST=None):
|
|||||||
# Ajoute les groupes
|
# Ajoute les groupes
|
||||||
for p in partitions:
|
for p in partitions:
|
||||||
p["group"] = get_partition_groups(p)
|
p["group"] = get_partition_groups(p)
|
||||||
return scu.sendResult(REQUEST, partitions, name="partition", format=format)
|
return scu.sendResult(partitions, name="partition", format=format)
|
||||||
|
|
||||||
|
|
||||||
# Encore utilisé par groupmgr.js
|
# Encore utilisé par groupmgr.js
|
||||||
|
@ -706,7 +706,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST=
|
|||||||
else:
|
else:
|
||||||
groups_filename = ""
|
groups_filename = ""
|
||||||
filename = "PV-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
|
filename = "PV-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
|
||||||
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
|
return scu.sendPDFFile(pdfdoc, filename)
|
||||||
|
|
||||||
|
|
||||||
def descrform_pvjury(sem):
|
def descrform_pvjury(sem):
|
||||||
@ -867,7 +867,7 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[], REQUEST=No
|
|||||||
dt = time.strftime("%Y-%m-%d")
|
dt = time.strftime("%Y-%m-%d")
|
||||||
groups_filename = "-" + groups_infos.groups_filename
|
groups_filename = "-" + groups_infos.groups_filename
|
||||||
filename = "lettres-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
|
filename = "lettres-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)
|
||||||
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
|
return scu.sendPDFFile(pdfdoc, filename)
|
||||||
|
|
||||||
|
|
||||||
def descrform_lettres_individuelles():
|
def descrform_lettres_individuelles():
|
||||||
|
@ -1491,7 +1491,7 @@ def formsemestre_graph_parcours(
|
|||||||
statut=statut,
|
statut=statut,
|
||||||
)
|
)
|
||||||
filename = scu.make_filename("flux " + sem["titreannee"])
|
filename = scu.make_filename("flux " + sem["titreannee"])
|
||||||
return scu.sendPDFFile(REQUEST, doc, filename + ".pdf")
|
return scu.sendPDFFile(doc, filename + ".pdf")
|
||||||
elif format == "png":
|
elif format == "png":
|
||||||
#
|
#
|
||||||
(
|
(
|
||||||
|
@ -466,7 +466,7 @@ def _listeappel_photos_pdf(groups_infos, REQUEST):
|
|||||||
document.build(objects)
|
document.build(objects)
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(REQUEST, data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
|
||||||
|
|
||||||
# --------------------- Upload des photos de tout un groupe
|
# --------------------- Upload des photos de tout un groupe
|
||||||
|
@ -272,7 +272,7 @@ def pdf_trombino_tours(
|
|||||||
document.build(objects)
|
document.build(objects)
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(REQUEST, data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
|
||||||
|
|
||||||
# Feuille d'absences en pdf avec photos:
|
# Feuille d'absences en pdf avec photos:
|
||||||
@ -466,4 +466,4 @@ def pdf_feuille_releve_absences(
|
|||||||
document.build(objects)
|
document.build(objects)
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(REQUEST, data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
@ -538,17 +538,9 @@ def sendCSVFile(REQUEST, data, filename): # DEPRECATED ne plus utiliser
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def sendPDFFile(REQUEST, data, filename):
|
def sendPDFFile(data, filename):
|
||||||
filename = (
|
filename = make_filename(filename)
|
||||||
unescape_html(suppress_accents(filename)).replace("&", "").replace(" ", "_")
|
return send_file(data, filename=filename, mime=JSON_MIMETYPE, attached=True)
|
||||||
)
|
|
||||||
if REQUEST:
|
|
||||||
REQUEST.RESPONSE.setHeader("content-type", PDF_MIMETYPE)
|
|
||||||
REQUEST.RESPONSE.setHeader(
|
|
||||||
"content-disposition", 'attachment; filename="%s"' % filename
|
|
||||||
)
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
class ScoDocJSONEncoder(json.JSONEncoder):
|
class ScoDocJSONEncoder(json.JSONEncoder):
|
||||||
def default(self, o): # pylint: disable=E0202
|
def default(self, o): # pylint: disable=E0202
|
||||||
@ -565,25 +557,21 @@ def sendJSON(data):
|
|||||||
return send_file(js, filename="sco_data.json", mime=JSON_MIMETYPE, attached=False)
|
return send_file(js, filename="sco_data.json", mime=JSON_MIMETYPE, attached=False)
|
||||||
|
|
||||||
|
|
||||||
def sendXML(REQUEST, data, tagname=None, force_outer_xml_tag=True):
|
def sendXML(data, tagname=None, force_outer_xml_tag=True):
|
||||||
if type(data) != list:
|
if type(data) != list:
|
||||||
data = [data] # always list-of-dicts
|
data = [data] # always list-of-dicts
|
||||||
if force_outer_xml_tag:
|
if force_outer_xml_tag:
|
||||||
data = [{tagname: data}]
|
data = [{tagname: data}]
|
||||||
tagname += "_list"
|
tagname += "_list"
|
||||||
doc = sco_xml.simple_dictlist2xml(data, tagname=tagname)
|
doc = sco_xml.simple_dictlist2xml(data, tagname=tagname)
|
||||||
if REQUEST:
|
return send_file(doc, filename="sco_data.xml", mime=XML_MIMETYPE, attached=False)
|
||||||
REQUEST.RESPONSE.setHeader("content-type", XML_MIMETYPE)
|
|
||||||
return doc
|
|
||||||
|
|
||||||
|
|
||||||
def sendResult(REQUEST, data, name=None, format=None, force_outer_xml_tag=True):
|
def sendResult(data, name=None, format=None, force_outer_xml_tag=True):
|
||||||
if (format is None) or (format == "html"):
|
if (format is None) or (format == "html"):
|
||||||
return data
|
return data
|
||||||
elif format == "xml": # name is outer tagname
|
elif format == "xml": # name is outer tagname
|
||||||
return sendXML(
|
return sendXML(data, tagname=name, force_outer_xml_tag=force_outer_xml_tag)
|
||||||
REQUEST, data, tagname=name, force_outer_xml_tag=force_outer_xml_tag
|
|
||||||
)
|
|
||||||
elif format == "json":
|
elif format == "json":
|
||||||
return sendJSON(data)
|
return sendJSON(data)
|
||||||
else:
|
else:
|
||||||
|
@ -1223,7 +1223,7 @@ def _tableBillets(billets, etud=None, title=""):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@scodoc7func
|
@scodoc7func
|
||||||
def listeBilletsEtud(etudid=False, REQUEST=None, format="html"):
|
def listeBilletsEtud(etudid=False, format="html"):
|
||||||
"""Liste billets pour un etudiant"""
|
"""Liste billets pour un etudiant"""
|
||||||
etuds = sco_etud.get_etud_info(filled=True, etudid=etudid)
|
etuds = sco_etud.get_etud_info(filled=True, etudid=etudid)
|
||||||
if not etuds:
|
if not etuds:
|
||||||
@ -1243,12 +1243,12 @@ def listeBilletsEtud(etudid=False, REQUEST=None, format="html"):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required_compat_scodoc7(Permission.ScoView)
|
@permission_required_compat_scodoc7(Permission.ScoView)
|
||||||
@scodoc7func
|
@scodoc7func
|
||||||
def XMLgetBilletsEtud(etudid=False, REQUEST=None):
|
def XMLgetBilletsEtud(etudid=False):
|
||||||
"""Liste billets pour un etudiant"""
|
"""Liste billets pour un etudiant"""
|
||||||
if not sco_preferences.get_preference("handle_billets_abs"):
|
if not sco_preferences.get_preference("handle_billets_abs"):
|
||||||
return ""
|
return ""
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
r = listeBilletsEtud(etudid, REQUEST=REQUEST, format="xml")
|
r = listeBilletsEtud(etudid, format="xml")
|
||||||
log("XMLgetBilletsEtud (%gs)" % (time.time() - t0))
|
log("XMLgetBilletsEtud (%gs)" % (time.time() - t0))
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ def formation_list(format=None, REQUEST=None, formation_id=None, args={}):
|
|||||||
(when args is given, formation_id is ignored).
|
(when args is given, formation_id is ignored).
|
||||||
"""
|
"""
|
||||||
r = sco_formations.formation_list(formation_id=formation_id, args=args)
|
r = sco_formations.formation_list(formation_id=formation_id, args=args)
|
||||||
return scu.sendResult(REQUEST, r, name="formation", format=format)
|
return scu.sendResult(r, name="formation", format=format)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formation_export")
|
@bp.route("/formation_export")
|
||||||
@ -614,8 +614,7 @@ sco_publish("/ue_move", sco_edit_formation.ue_move, Permission.ScoChangeFormatio
|
|||||||
@permission_required_compat_scodoc7(Permission.ScoView)
|
@permission_required_compat_scodoc7(Permission.ScoView)
|
||||||
@scodoc7func
|
@scodoc7func
|
||||||
def formsemestre_list(
|
def formsemestre_list(
|
||||||
format=None,
|
format="json",
|
||||||
REQUEST=None,
|
|
||||||
formsemestre_id=None,
|
formsemestre_id=None,
|
||||||
formation_id=None,
|
formation_id=None,
|
||||||
etape_apo=None,
|
etape_apo=None,
|
||||||
@ -632,7 +631,7 @@ def formsemestre_list(
|
|||||||
args[argname] = L[argname]
|
args[argname] = L[argname]
|
||||||
sems = sco_formsemestre.do_formsemestre_list(args=args)
|
sems = sco_formsemestre.do_formsemestre_list(args=args)
|
||||||
# log('formsemestre_list: format="%s", %s semestres found' % (format,len(sems)))
|
# log('formsemestre_list: format="%s", %s semestres found' % (format,len(sems)))
|
||||||
return scu.sendResult(REQUEST, sems, name="formsemestre", format=format)
|
return scu.sendResult(sems, name="formsemestre", format=format)
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
@bp.route(
|
||||||
@ -1328,7 +1327,7 @@ def do_formsemestre_inscription_listinscrits(
|
|||||||
r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
|
r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
|
||||||
formsemestre_id
|
formsemestre_id
|
||||||
)
|
)
|
||||||
return scu.sendResult(REQUEST, r, format=format, name="inscrits")
|
return scu.sendResult(r, format=format, name="inscrits")
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formsemestre_desinscription", methods=["GET", "POST"])
|
@bp.route("/formsemestre_desinscription", methods=["GET", "POST"])
|
||||||
@ -1699,7 +1698,7 @@ def formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedevals"
|
|||||||
pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
||||||
formsemestre_id, REQUEST, version=version
|
formsemestre_id, REQUEST, version=version
|
||||||
)
|
)
|
||||||
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
|
return scu.sendPDFFile(pdfdoc, filename)
|
||||||
|
|
||||||
|
|
||||||
_EXPL_BULL = """Versions des bulletins:<ul><li><bf>courte</bf>: moyennes des modules</li><li><bf>intermédiaire</bf>: moyennes des modules et notes des évaluations sélectionnées</li><li><bf>complète</bf>: toutes les notes</li><ul>"""
|
_EXPL_BULL = """Versions des bulletins:<ul><li><bf>courte</bf>: moyennes des modules</li><li><bf>intermédiaire</bf>: moyennes des modules et notes des évaluations sélectionnées</li><li><bf>complète</bf>: toutes les notes</li><ul>"""
|
||||||
@ -1715,7 +1714,7 @@ def formsemestre_bulletins_pdf_choice(REQUEST, formsemestre_id, version=None):
|
|||||||
pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
||||||
formsemestre_id, REQUEST, version=version
|
formsemestre_id, REQUEST, version=version
|
||||||
)
|
)
|
||||||
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
|
return scu.sendPDFFile(pdfdoc, filename)
|
||||||
return formsemestre_bulletins_choice(
|
return formsemestre_bulletins_choice(
|
||||||
REQUEST,
|
REQUEST,
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
@ -1733,7 +1732,7 @@ def etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"):
|
|||||||
pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf(
|
pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf(
|
||||||
etudid, REQUEST, version=version
|
etudid, REQUEST, version=version
|
||||||
)
|
)
|
||||||
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
|
return scu.sendPDFFile(pdfdoc, filename)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/formsemestre_bulletins_mailetuds_choice")
|
@bp.route("/formsemestre_bulletins_mailetuds_choice")
|
||||||
|
@ -336,7 +336,7 @@ def getEtudInfo(etudid=False, code_nip=False, filled=False, REQUEST=None, format
|
|||||||
if format is None:
|
if format is None:
|
||||||
return etud
|
return etud
|
||||||
else:
|
else:
|
||||||
return scu.sendResult(REQUEST, etud, name="etud", format=format)
|
return scu.sendResult(etud, name="etud", format=format)
|
||||||
|
|
||||||
|
|
||||||
sco_publish(
|
sco_publish(
|
||||||
@ -391,7 +391,7 @@ def etud_info(etudid=None, format="xml", REQUEST=None):
|
|||||||
"error": "code etudiant inconnu",
|
"error": "code etudiant inconnu",
|
||||||
}
|
}
|
||||||
return scu.sendResult(
|
return scu.sendResult(
|
||||||
REQUEST, d, name="etudiant", format=format, force_outer_xml_tag=False
|
d, name="etudiant", format=format, force_outer_xml_tag=False
|
||||||
)
|
)
|
||||||
d = {}
|
d = {}
|
||||||
etud = etuds[0]
|
etud = etuds[0]
|
||||||
@ -459,9 +459,7 @@ def etud_info(etudid=None, format="xml", REQUEST=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
log("etud_info (%gs)" % (time.time() - t0))
|
log("etud_info (%gs)" % (time.time() - t0))
|
||||||
return scu.sendResult(
|
return scu.sendResult(d, name="etudiant", format=format, force_outer_xml_tag=False)
|
||||||
REQUEST, d, name="etudiant", format=format, force_outer_xml_tag=False
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------- FICHE ETUDIANT --------------------------
|
# -------------------------- FICHE ETUDIANT --------------------------
|
||||||
|
@ -88,7 +88,7 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"):
|
|||||||
@scodoc7func
|
@scodoc7func
|
||||||
def user_info(user_name, format="json", REQUEST=None):
|
def user_info(user_name, format="json", REQUEST=None):
|
||||||
info = sco_users.user_info(user_name)
|
info = sco_users.user_info(user_name)
|
||||||
return scu.sendResult(REQUEST, info, name="user", format=format)
|
return scu.sendResult(info, name="user", format=format)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/create_user_form", methods=["GET", "POST"])
|
@bp.route("/create_user_form", methods=["GET", "POST"])
|
||||||
|
Loading…
Reference in New Issue
Block a user