removed some useless REQUESTs

This commit is contained in:
Emmanuel Viennet 2021-09-24 12:10:53 +02:00
parent 373feece76
commit 0a50edc9f0
26 changed files with 68 additions and 123 deletions

View File

@ -20,7 +20,9 @@
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.from flask import jsonify
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from flask import jsonify
from werkzeug.http import HTTP_STATUS_CODES

View File

@ -318,13 +318,7 @@ def sco_footer():
def html_sem_header(
REQUEST,
title,
sem=None,
with_page_header=True,
with_h2=True,
page_title=None,
**args
title, sem=None, with_page_header=True, with_h2=True, page_title=None, **args
):
"Titre d'une page semestre avec lien vers tableau de bord"
# sem now unused and thus optional...

View File

@ -655,7 +655,7 @@ def add_absence(
sco_abs_notification.abs_notify(etudid, jour)
def add_justif(etudid, jour, matin, REQUEST, description=None):
def add_justif(etudid, jour, matin, description=None):
"Ajoute un justificatif dans la base"
# unpublished
if _isFarFutur(jour):
@ -664,7 +664,9 @@ def add_justif(etudid, jour, matin, REQUEST, description=None):
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
"""INSERT INTO absences (etudid, jour, estabs, estjust, matin, description)
VALUES (%(etudid)s, %(jour)s, FALSE, TRUE, %(matin)s, %(description)s)
""",
vars(),
)
logdb(
@ -677,7 +679,7 @@ def add_justif(etudid, jour, matin, REQUEST, description=None):
invalidate_abs_etud_date(etudid, jour)
def _add_abslist(abslist, REQUEST, moduleimpl_id=None):
def add_abslist(abslist, moduleimpl_id=None):
for a in abslist:
etudid, jour, ampm = a.split(":")
if ampm == "am":
@ -688,7 +690,7 @@ def _add_abslist(abslist, REQUEST, moduleimpl_id=None):
raise ValueError("invalid ampm !")
# ajoute abs si pas deja absent
if count_abs(etudid, jour, jour, matin, moduleimpl_id) == 0:
add_absence(etudid, jour, matin, 0, REQUEST, "", moduleimpl_id)
add_absence(etudid, jour, matin, 0, "", moduleimpl_id)
def annule_absence(etudid, jour, matin, moduleimpl_id=None):
@ -720,7 +722,7 @@ def annule_absence(etudid, jour, matin, moduleimpl_id=None):
invalidate_abs_etud_date(etudid, jour)
def annule_justif(etudid, jour, matin, REQUEST=None):
def annule_justif(etudid, jour, matin):
"Annule un justificatif"
# unpublished
matin = _toboolean(matin)

View File

@ -58,7 +58,6 @@ def doSignaleAbsence(
estjust=False,
description=None,
etudid=False,
REQUEST=None,
): # etudid implied
"""Signalement d'une absence.
@ -69,7 +68,8 @@ def doSignaleAbsence(
demijournee: 2 si journée complète, 1 matin, 0 après-midi
estjust: absence justifiée
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
etudid: etudiant concerné. Si non spécifié, cherche dans
les paramètres de la requête courante.
"""
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
etudid = etud["etudid"]
@ -153,7 +153,7 @@ def doSignaleAbsence(
return "\n".join(H)
def SignaleAbsenceEtud(REQUEST=None): # etudid implied
def SignaleAbsenceEtud(): # etudid implied
"""Formulaire individuel simple de signalement d'une absence"""
# brute-force portage from very old dtml code ...
etud = sco_etud.get_etud_info(filled=True)[0]
@ -225,7 +225,6 @@ def SignaleAbsenceEtud(REQUEST=None): # etudid implied
sco_photos.etud_photo_html(
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""
@ -278,7 +277,6 @@ def doJustifAbsence(
demijournee,
description=None,
etudid=False,
REQUEST=None,
): # etudid implied
"""Justification d'une absence
@ -288,7 +286,8 @@ def doJustifAbsence(
demijournee: 2 si journée complète, 1 matin, 0 après-midi
estjust: absence justifiée
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
etudid: etudiant concerné. Si non spécifié, cherche dans les
paramètres de la requête.
"""
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
etudid = etud["etudid"]
@ -302,14 +301,12 @@ def doJustifAbsence(
etudid=etudid,
jour=jour,
matin=False,
REQUEST=REQUEST,
description=description_abs,
)
sco_abs.add_justif(
etudid=etudid,
jour=jour,
matin=True,
REQUEST=REQUEST,
description=description_abs,
)
nbadded += 2
@ -318,7 +315,6 @@ def doJustifAbsence(
etudid=etudid,
jour=jour,
matin=demijournee,
REQUEST=REQUEST,
description=description_abs,
)
nbadded += 1
@ -354,7 +350,7 @@ def doJustifAbsence(
return "\n".join(H)
def JustifAbsenceEtud(REQUEST=None): # etudid implied
def JustifAbsenceEtud(): # etudid implied
"""Formulaire individuel simple de justification d'une absence"""
# brute-force portage from very old dtml code ...
etud = sco_etud.get_etud_info(filled=True)[0]
@ -373,7 +369,6 @@ def JustifAbsenceEtud(REQUEST=None): # etudid implied
sco_photos.etud_photo_html(
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""
@ -409,9 +404,7 @@ Raison: <input type="text" name="description" size="42"/> (optionnel)
return "\n".join(H)
def doAnnuleAbsence(
datedebut, datefin, demijournee, etudid=False, REQUEST=None
): # etudid implied
def doAnnuleAbsence(datedebut, datefin, demijournee, etudid=False): # etudid implied
"""Annulation des absences pour une demi journée"""
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
etudid = etud["etudid"]
@ -459,7 +452,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
return "\n".join(H)
def AnnuleAbsenceEtud(REQUEST=None): # etudid implied
def AnnuleAbsenceEtud(): # etudid implied
"""Formulaire individuel simple d'annulation d'une absence"""
# brute-force portage from very old dtml code ...
etud = sco_etud.get_etud_info(filled=True)[0]
@ -479,7 +472,6 @@ def AnnuleAbsenceEtud(REQUEST=None): # etudid implied
sco_photos.etud_photo_html(
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
"""</a></td></tr></table>""",
"""<p>A n'utiliser que suite à une erreur de saisie ou lorsqu'il s'avère que l'étudiant était en fait présent. </p>
@ -545,7 +537,7 @@ def AnnuleAbsenceEtud(REQUEST=None): # etudid implied
return "\n".join(H)
def doAnnuleJustif(datedebut0, datefin0, demijournee, REQUEST=None): # etudid implied
def doAnnuleJustif(datedebut0, datefin0, demijournee): # etudid implied
"""Annulation d'une justification"""
etud = sco_etud.get_etud_info(filled=True)[0]
etudid = etud["etudid"]
@ -555,11 +547,11 @@ def doAnnuleJustif(datedebut0, datefin0, demijournee, REQUEST=None): # etudid i
for jour in dates:
# Attention: supprime matin et après-midi
if demijournee == 2:
sco_abs.annule_justif(etudid, jour, False, REQUEST=REQUEST)
sco_abs.annule_justif(etudid, jour, True, REQUEST=REQUEST)
sco_abs.annule_justif(etudid, jour, False)
sco_abs.annule_justif(etudid, jour, True)
nbadded += 2
else:
sco_abs.annule_justif(etudid, jour, demijournee, REQUEST=REQUEST)
sco_abs.annule_justif(etudid, jour, demijournee)
nbadded += 1
#
H = [
@ -713,7 +705,6 @@ def formChoixSemestreGroupe(all=False):
def CalAbs(etudid, sco_year=None):
"""Calendrier des absences d'un etudiant"""
# crude portage from 1999 DTML
REQUEST = None # XXX
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
etudid = etud["etudid"]
anneescolaire = int(scu.AnneeScolaire(sco_year))
@ -763,7 +754,6 @@ def CalAbs(etudid, sco_year=None):
sco_photos.etud_photo_html(
etudid=etudid,
title="fiche de " + etud["nomprenom"],
REQUEST=REQUEST,
),
),
CalHTML,
@ -788,7 +778,6 @@ def ListeAbsEtud(
format="html",
absjust_only=0,
sco_year=None,
REQUEST=None,
):
"""Liste des absences d'un étudiant sur l'année en cours
En format 'html': page avec deux tableaux (non justifiées et justifiées).
@ -807,10 +796,10 @@ def ListeAbsEtud(
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
# Liste des absences et titres colonnes tables:
titles, columns_ids, absnonjust, absjust = _TablesAbsEtud(
titles, columns_ids, absnonjust, absjust = _tables_abs_etud(
etudid, datedebut, with_evals=with_evals, format=format
)
if REQUEST:
if request.base_url:
base_url_nj = "%s?etudid=%s&absjust_only=0" % (request.base_url, etudid)
base_url_j = "%s?etudid=%s&absjust_only=1" % (request.base_url, etudid)
else:
@ -893,13 +882,12 @@ def ListeAbsEtud(
raise ValueError("Invalid format !")
def _TablesAbsEtud(
def _tables_abs_etud(
etudid,
datedebut,
with_evals=True,
format="html",
absjust_only=0,
REQUEST=None,
):
"""Tables des absences justifiees et non justifiees d'un étudiant
sur l'année en cours

View File

@ -395,7 +395,6 @@ def formsemestre_archive(REQUEST, formsemestre_id, group_ids=[]):
H = [
html_sco_header.html_sem_header(
REQUEST,
"Archiver les PV et résultats du semestre",
sem=sem,
javascripts=sco_groups_view.JAVASCRIPTS,
@ -517,7 +516,7 @@ def formsemestre_list_archives(REQUEST, formsemestre_id):
}
L.append(a)
H = [html_sco_header.html_sem_header(REQUEST, "Archive des PV et résultats ", sem)]
H = [html_sco_header.html_sem_header("Archive des PV et résultats ", sem)]
if not L:
H.append("<p>aucune archive enregistrée</p>")
else:

View File

@ -1217,9 +1217,7 @@ def _formsemestre_bulletinetud_header_html(
"""
% (
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
sco_photos.etud_photo_html(
etud, title="fiche de " + etud["nom"], REQUEST=REQUEST
),
sco_photos.etud_photo_html(etud, title="fiche de " + etud["nom"]),
)
)
H.append(

View File

@ -780,7 +780,6 @@ def formsemestre_evaluations_cal(formsemestre_id, REQUEST=None):
H = [
html_sco_header.html_sem_header(
REQUEST,
"Evaluations du semestre",
sem,
cssstyles=["css/calabs.css"],

View File

@ -84,9 +84,7 @@ def formsemestre_custommenu_edit(formsemestre_id, REQUEST=None):
scu.NotesURL() + "/formsemestre_status?formsemestre_id=%s" % formsemestre_id
)
H = [
html_sco_header.html_sem_header(
REQUEST, "Modification du menu du semestre ", sem
),
html_sco_header.html_sem_header("Modification du menu du semestre ", sem),
"""<p class="help">Ce menu, spécifique à chaque semestre, peut être utilisé pour placer des liens vers vos applications préférées.</p>
<p class="help">Procédez en plusieurs fois si vous voulez ajouter plusieurs items.</p>""",
]

View File

@ -91,7 +91,6 @@ def formsemestre_editwithmodules(REQUEST, formsemestre_id):
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
"Modification du semestre",
sem,
javascripts=["libjs/AutoSuggest.js"],
@ -895,7 +894,6 @@ def formsemestre_clone(formsemestre_id, REQUEST=None):
H = [
html_sco_header.html_sem_header(
REQUEST,
"Copie du semestre",
sem,
javascripts=["libjs/AutoSuggest.js"],
@ -1242,7 +1240,7 @@ def formsemestre_delete(formsemestre_id, REQUEST=None):
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
H = [
html_sco_header.html_sem_header(REQUEST, "Suppression du semestre", sem),
html_sco_header.html_sem_header("Suppression du semestre", sem),
"""<div class="ue_warning"><span>Attention !</span>
<p class="help">A n'utiliser qu'en cas d'erreur lors de la saisie d'une formation. Normalement,
<b>un semestre ne doit jamais être supprimé</b> (on perd la mémoire des notes et de tous les événements liés à ce semestre !).</p>
@ -1545,9 +1543,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None, REQUEST=None):
</p>
"""
H = [
html_sco_header.html_sem_header(
REQUEST, "Coefficients des UE du semestre", sem
),
html_sco_header.html_sem_header("Coefficients des UE du semestre", sem),
help,
]
#
@ -1659,9 +1655,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None, REQUEST=None):
formsemestre_id=formsemestre_id
) # > modif coef UE cap (modifs notes de _certains_ etudiants)
header = html_sco_header.html_sem_header(
REQUEST, "Coefficients des UE du semestre", sem
)
header = html_sco_header.html_sem_header("Coefficients des UE du semestre", sem)
return (
header
+ "\n".join(z)

View File

@ -334,7 +334,6 @@ def formsemestre_inscription_with_modules(
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
H = [
html_sco_header.html_sem_header(
REQUEST,
"Inscription de %s dans ce semestre" % etud["nomprenom"],
sem,
)
@ -763,7 +762,6 @@ def formsemestre_inscrits_ailleurs(formsemestre_id, REQUEST=None):
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
"Inscriptions multiples parmi les étudiants du semestre ",
sem,
)

View File

@ -701,7 +701,7 @@ def formsemestre_description_table(formsemestre_id, REQUEST=None, with_evals=Fal
% (request.base_url, formsemestre_id, with_evals),
page_title=title,
html_title=html_sco_header.html_sem_header(
REQUEST, "Description du semestre", sem, with_page_header=False
"Description du semestre", sem, with_page_header=False
),
pdf_title=title,
preferences=sco_preferences.SemPreferences(formsemestre_id),
@ -912,7 +912,7 @@ def formsemestre_status_head(formsemestre_id=None, REQUEST=None, page_title=None
H = [
html_sco_header.html_sem_header(
REQUEST, page_title, sem, with_page_header=False, with_h2=False
page_title, sem, with_page_header=False, with_h2=False
),
f"""<table>
<tr><td class="fichetitre2">Formation: </td><td>

View File

@ -149,9 +149,7 @@ def formsemestre_validation_etud_form(
'</td><td style="text-align: right;"><a href="%s">%s</a></td></tr></table>'
% (
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
sco_photos.etud_photo_html(
etud, title="fiche de %s" % etud["nom"], REQUEST=REQUEST
),
sco_photos.etud_photo_html(etud, title="fiche de %s" % etud["nom"]),
)
)
@ -824,7 +822,7 @@ def formsemestre_validation_auto(formsemestre_id, REQUEST):
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
REQUEST, "Saisie automatique des décisions du semestre", sem
"Saisie automatique des décisions du semestre", sem
),
"""
<ul>
@ -992,9 +990,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid, REQUEST=None):
'</td><td style="text-align: right;"><a href="%s">%s</a></td></tr></table>'
% (
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid),
sco_photos.etud_photo_html(
etud, title="fiche de %s" % etud["nom"], REQUEST=REQUEST
),
sco_photos.etud_photo_html(etud, title="fiche de %s" % etud["nom"]),
)
),
"""<p class="help">Utiliser cette page pour enregistrer une UE validée antérieurement,

View File

@ -412,7 +412,7 @@ def build_page(
H = [
html_sco_header.html_sem_header(
REQUEST, "Passages dans le semestre", sem, with_page_header=False
"Passages dans le semestre", sem, with_page_header=False
),
"""<form method="post" action="%s">""" % request.base_url,
"""<input type="hidden" name="formsemestre_id" value="%(formsemestre_id)s"/>

View File

@ -778,9 +778,7 @@ def evaluation_check_absences_html(
if with_header:
H = [
html_sco_header.html_sem_header(
REQUEST, "Vérification absences à l'évaluation"
),
html_sco_header.html_sem_header("Vérification absences à l'évaluation"),
sco_evaluations.evaluation_describe(evaluation_id=evaluation_id),
"""<p class="help">Vérification de la cohérence entre les notes saisies et les absences signalées.</p>""",
]
@ -866,7 +864,6 @@ def formsemestre_check_absences_html(formsemestre_id, REQUEST=None):
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
"Vérification absences aux évaluations de ce semestre",
sem,
),

View File

@ -286,9 +286,7 @@ def moduleimpl_inscriptions_stats(formsemestre_id, REQUEST=None):
mod["nb_inscrits"] = nb_inscrits
options.append(mod)
# Page HTML:
H = [
html_sco_header.html_sem_header(REQUEST, "Inscriptions aux modules du semestre")
]
H = [html_sco_header.html_sem_header("Inscriptions aux modules du semestre")]
H.append("<h3>Inscrits au semestre: %d étudiants</h3>" % len(inscrits))

View File

@ -168,7 +168,7 @@ def ficheEtud(etudid=None, REQUEST=None):
info["info_naissance"] += " à " + info["lieu_naissance"]
if info["dept_naissance"]:
info["info_naissance"] += " (%s)" % info["dept_naissance"]
info["etudfoto"] = sco_photos.etud_photo_html(etud, REQUEST=REQUEST)
info["etudfoto"] = sco_photos.etud_photo_html(etud)
if (
(not info["domicile"])
and (not info["codepostaldomicile"])
@ -540,9 +540,7 @@ def etud_info_html(etudid, with_photo="1", REQUEST=None, debug=False):
formsemestre_id = sco_formsemestre_status.retreive_formsemestre_from_request()
with_photo = int(with_photo)
etud = sco_etud.get_etud_info(filled=True)[0]
photo_html = sco_photos.etud_photo_html(
etud, title="fiche de " + etud["nom"], REQUEST=REQUEST
)
photo_html = sco_photos.etud_photo_html(etud, title="fiche de " + etud["nom"])
# experimental: may be too slow to be here
etud["codeparcours"], etud["decisions_jury"] = sco_report.get_codeparcoursetud(
etud, prefix="S", separator=", "

View File

@ -174,7 +174,7 @@ def etud_photo_is_local(etud, size="small"):
return photo_pathname(etud, size=size)
def etud_photo_html(etud=None, etudid=None, title=None, size="small", REQUEST=None):
def etud_photo_html(etud=None, etudid=None, title=None, size="small"):
"""HTML img tag for the photo, either in small size (h90)
or original size (size=="orig")
"""
@ -211,9 +211,7 @@ def etud_photo_orig_html(etud=None, etudid=None, title=None, REQUEST=None):
Full-size images are always stored locally in the filesystem.
They are the original uploaded images, converted in jpeg.
"""
return etud_photo_html(
etud=etud, etudid=etudid, title=title, size="orig", REQUEST=REQUEST
)
return etud_photo_html(etud=etud, etudid=etudid, title=title, size="orig")
def photo_pathname(etud, size="orig"):

View File

@ -2154,7 +2154,7 @@ class SemPreferences(object):
) # a bug !
sem = sco_formsemestre.get_formsemestre(self.formsemestre_id)
H = [
html_sco_header.html_sem_header(REQUEST, "Préférences du semestre", sem),
html_sco_header.html_sem_header("Préférences du semestre", sem),
"""
<p class="help">Les paramètres définis ici ne s'appliqueront qu'à ce semestre.</p>
<p class="msg">Attention: cliquez sur "Enregistrer les modifications" en bas de page pour appliquer vos changements !</p>

View File

@ -540,7 +540,6 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True, REQUEST=No
tab.base_url = "%s?formsemestre_id=%s" % (request.base_url, formsemestre_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
"Décisions du jury pour le semestre",
sem,
init_qtip=True,
@ -627,7 +626,6 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST=
H = [
html_sco_header.html_sem_header(
REQUEST,
"Edition du PV de jury %s" % etuddescr,
sem=sem,
javascripts=sco_groups_view.JAVASCRIPTS,
@ -805,7 +803,6 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[], REQUEST=No
H = [
html_sco_header.html_sem_header(
REQUEST,
"Édition des lettres individuelles",
sem=sem,
javascripts=sco_groups_view.JAVASCRIPTS,

View File

@ -150,7 +150,7 @@ def trombino_html(groups_infos, REQUEST=None):
% t["etudid"]
)
if sco_photos.etud_photo_is_local(t, size="small"):
foto = sco_photos.etud_photo_html(t, title="", REQUEST=REQUEST)
foto = sco_photos.etud_photo_html(t, title="")
else: # la photo n'est pas immédiatement dispo
foto = (
'<span class="unloaded_img" id="%s"><img border="0" height="90" alt="en cours" src="/ScoDoc/static/icons/loading.jpg"/></span>'

View File

@ -222,7 +222,6 @@ def external_ue_create_form(formsemestre_id, etudid, REQUEST=None):
H = [
html_sco_header.html_sem_header(
REQUEST,
"Ajout d'une UE externe pour %(nomprenom)s" % etud,
sem,
javascripts=["js/sco_ue_external.js"],

View File

@ -82,7 +82,7 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"):
all_depts = int(all_depts)
with_inactives = int(with_inactives)
H = [html_sco_header.html_sem_header(REQUEST, "Gestion des utilisateurs")]
H = [html_sco_header.html_sem_header("Gestion des utilisateurs")]
if current_user.has_permission(Permission.ScoUsersAdmin, g.scodoc_dept):
H.append(

View File

@ -579,7 +579,7 @@ def sendResult(data, name=None, format=None, force_outer_xml_tag=True):
raise ValueError("invalid format: %s" % format)
def send_file(data, filename, suffix="", mime=None, attached=None):
def send_file(data, filename="", suffix="", mime=None, attached=None):
"""Build Flask Response for file download of given type
By default (attached is None), json and xml are inlined and otrher types are atteched.
"""
@ -588,12 +588,15 @@ def send_file(data, filename, suffix="", mime=None, attached=None):
attached = True
else:
attached = False
if suffix:
filename += suffix
filename = make_filename(filename)
# if attached and not filename:
# raise ValueError("send_file: missing attachement filename")
if filename:
if suffix:
filename += suffix
filename = make_filename(filename)
response = make_response(data)
response.headers["Content-Type"] = mime
if attached:
if attached and filename:
response.headers["Content-Disposition"] = 'attachment; filename="%s"' % filename
return response

View File

@ -121,7 +121,7 @@ def sco_publish(route, function, permission, methods=["GET"]):
@scodoc
@permission_required(Permission.ScoView)
@scodoc7func
def index_html(REQUEST=None):
def index_html():
"""Gestionnaire absences, page principale"""
# crude portage from 1999 DTML
sems = sco_formsemestre.do_formsemestre_list()
@ -268,7 +268,6 @@ def doSignaleAbsenceGrSemestre(
dates="",
etudids="",
destination=None,
REQUEST=None,
):
"""Enregistre absences aux dates indiquees (abslist et dates).
dates est une liste de dates ISO (séparées par des ',').
@ -293,10 +292,10 @@ def doSignaleAbsenceGrSemestre(
# 2- Ajoute les absences
if abslist:
sco_abs._add_abslist(abslist, REQUEST, moduleimpl_id)
sco_abs.add_abslist(abslist, moduleimpl_id)
return "Absences ajoutées"
return ""
return ("", 204)
# ------------ HTML Interfaces
@ -471,7 +470,6 @@ def SignaleAbsenceGrSemestre(
group_ids=[], # list of groups to display
nbweeks=4, # ne montre que les nbweeks dernieres semaines
moduleimpl_id=None,
REQUEST=None,
):
"""Saisie des absences sur une journée sur un semestre (ou intervalle de dates) entier"""
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
@ -841,7 +839,6 @@ def EtatAbsencesGr(
fin="",
with_boursier=True, # colonne boursier
format="html",
REQUEST=None,
):
"""Liste les absences de groupes"""
datedebut = ndb.DateDMYtoISO(debut)
@ -936,7 +933,7 @@ def EtatAbsencesGr(
javascripts=["js/etud_info.js"],
),
html_title=html_sco_header.html_sem_header(
REQUEST, "%s" % title, sem, with_page_header=False
"%s" % title, sem, with_page_header=False
)
+ "<p>Période du %s au %s (nombre de <b>demi-journées</b>)<br/>" % (debut, fin),
base_url="%s&formsemestre_id=%s&debut=%s&fin=%s"
@ -1060,7 +1057,6 @@ def AddBilletAbsence(
code_nip=None,
code_ine=None,
justified=True,
REQUEST=None,
xml_reply=True,
):
"""Memorise un "billet"
@ -1096,9 +1092,6 @@ def AddBilletAbsence(
)
if xml_reply:
# Renvoie le nouveau billet en XML
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
tab = _tableBillets(billets, etud=etud)
log("AddBilletAbsence: new billet_id=%s (%gs)" % (billet_id, time.time() - t0))
@ -1286,7 +1279,7 @@ def listeBillets(REQUEST=None):
@scodoc
@permission_required(Permission.ScoAbsChange)
@scodoc7func
def deleteBilletAbsence(billet_id, REQUEST=None, dialog_confirmed=False):
def deleteBilletAbsence(billet_id, dialog_confirmed=False):
"""Supprime un billet."""
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
@ -1472,7 +1465,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None):
@scodoc
@permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func
def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None):
def XMLgetAbsEtud(beg_date="", end_date=""):
"""returns list of absences in date interval"""
t0 = time.time()
etuds = sco_etud.get_etud_info(filled=False)
@ -1488,7 +1481,6 @@ def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None):
abs_list = sco_abs.list_abs_date(etud["etudid"], beg_date, end_date)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = ElementTree.Element(
"absences", etudid=str(etud["etudid"]), beg_date=beg_date, end_date=end_date
)
@ -1504,4 +1496,5 @@ def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None):
)
)
log("XMLgetAbsEtud (%gs)" % (time.time() - t0))
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
data = sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
scu.send_file(data, mime=scu.XML_MIMETYPE, attached=False)

View File

@ -715,7 +715,6 @@ def edit_enseignants_form(REQUEST, moduleimpl_id):
M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id)
# --
header = html_sco_header.html_sem_header(
REQUEST,
'Enseignants du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>'
% (moduleimpl_id, M["module"]["titre"]),
page_title="Enseignants du module %s" % M["module"]["titre"],
@ -837,7 +836,6 @@ def edit_moduleimpl_resp(REQUEST, moduleimpl_id):
M, sem = sco_moduleimpl.can_change_module_resp(REQUEST, moduleimpl_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
'Modification du responsable du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>'
% (moduleimpl_id, M["module"]["titre"]),
sem,
@ -959,7 +957,6 @@ def edit_moduleimpl_expr(REQUEST, moduleimpl_id):
M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id)
H = [
html_sco_header.html_sem_header(
REQUEST,
'Modification règle de calcul du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>'
% (moduleimpl_id, M["module"]["titre"]),
sem,
@ -1066,7 +1063,6 @@ def view_module_abs(REQUEST, moduleimpl_id, format="html"):
H = [
html_sco_header.html_sem_header(
REQUEST,
'Absences du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>'
% (moduleimpl_id, M["module"]["titre"]),
page_title="Absences du module %s" % (M["module"]["titre"]),
@ -1117,7 +1113,6 @@ def edit_ue_expr(REQUEST, formsemestre_id, ue_id):
ue = sco_edit_ue.do_ue_list({"ue_id": ue_id})[0]
H = [
html_sco_header.html_sem_header(
REQUEST,
"Modification règle de calcul de l'UE %s (%s)"
% (ue["acronyme"], ue["titre"]),
sem,
@ -1258,7 +1253,7 @@ def formsemestre_enseignants_list(REQUEST, formsemestre_id, format="html"):
html_class="table_leftalign",
filename=scu.make_filename("Enseignants-" + sem["titreannee"]),
html_title=html_sco_header.html_sem_header(
REQUEST, "Enseignants du semestre", sem, with_page_header=False
"Enseignants du semestre", sem, with_page_header=False
),
base_url="%s?formsemestre_id=%s" % (request.base_url, formsemestre_id),
caption="Tous les enseignants (responsables ou associés aux modules de ce semestre) apparaissent. Le nombre de saisies d'absences est le nombre d'opérations d'ajout effectuées sur ce semestre, sans tenir compte des annulations ou double saisies.",
@ -1513,7 +1508,7 @@ def evaluation_delete(REQUEST, evaluation_id):
tit = "Suppression de l'évaluation %(description)s (%(jour)s)" % E
etat = sco_evaluations.do_evaluation_etat(evaluation_id)
H = [
html_sco_header.html_sem_header(REQUEST, tit, with_h2=False),
html_sco_header.html_sem_header(tit, with_h2=False),
"""<h2 class="formsemestre">Module <tt>%(code)s</tt> %(titre)s</h2>""" % Mod,
"""<h3>%s</h3>""" % tit,
"""<p class="help">Opération <span class="redboldtext">irréversible</span>. Si vous supprimez l'évaluation, vous ne pourrez pas retrouver les notes associées.</p>""",
@ -1778,7 +1773,7 @@ def formsemestre_bulletins_choice(
"""Choix d'une version de bulletin"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(REQUEST, title, sem),
html_sco_header.html_sem_header(title, sem),
"""
<form name="f" method="GET" action="%s">
<input type="hidden" name="formsemestre_id" value="%s"></input>

View File

@ -810,7 +810,7 @@ def formChangePhoto(etudid=None, REQUEST=None):
<p>Photo actuelle (%(photoloc)s):
"""
% etud,
sco_photos.etud_photo_html(etud, title="photo actuelle", REQUEST=REQUEST),
sco_photos.etud_photo_html(etud, title="photo actuelle"),
"""</p><p>Le fichier ne doit pas dépasser 500Ko (recadrer l'image, format "portrait" de préférence).</p>
<p>L'image sera automagiquement réduite pour obtenir une hauteur de 90 pixels.</p>
""",
@ -1640,7 +1640,6 @@ def check_group_apogee(group_id, REQUEST=None, etat=None, fix=False, fixmail=Fal
cnx = ndb.GetDBConnexion()
H = [
html_sco_header.html_sem_header(
REQUEST,
"Etudiants du %s" % (group["group_name"] or "semestre"),
sem,
),
@ -2081,7 +2080,7 @@ def formsemestre_import_etud_admission(
formsemestre_id, import_identite=True, import_email=import_email
)
H = [
html_sco_header.html_sem_header(REQUEST, "Reimport données admission"),
html_sco_header.html_sem_header("Reimport données admission"),
"<h3>Opération effectuée</h3>",
]
if no_nip: