@@ -499,13 +499,11 @@ def ficheEtud(etudid=None, REQUEST=None):
return header + tmpl % info + html_sco_header.sco_footer()
-def menus_etud(REQUEST=None):
+def menus_etud(etudid):
"""Menu etudiant (operations sur l'etudiant)"""
- if "etudid" not in REQUEST.form:
- return ""
authuser = current_user
- etud = sco_etud.get_etud_info(filled=True)[0]
+ etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
menuEtud = [
{
@@ -544,7 +542,7 @@ def menus_etud(REQUEST=None):
return htmlutils.make_menu("Etudiant", menuEtud, alone=True)
-def etud_info_html(etudid, with_photo="1", REQUEST=None, debug=False):
+def etud_info_html(etudid, with_photo="1", debug=False):
"""An HTML div with basic information and links about this etud.
Used for popups information windows.
"""
diff --git a/app/scodoc/sco_parcours_dut.py b/app/scodoc/sco_parcours_dut.py
index 83f03033..be4f983f 100644
--- a/app/scodoc/sco_parcours_dut.py
+++ b/app/scodoc/sco_parcours_dut.py
@@ -535,7 +535,7 @@ class SituationEtudParcoursGeneric(object):
validated = True
return s
- def valide_decision(self, decision, REQUEST):
+ def valide_decision(self, decision):
"""Enregistre la decision (instance de DecisionSem)
Enregistre codes semestre et UE, et autorisations inscription.
"""
diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py
index d888c2a0..ab53d2c6 100644
--- a/app/scodoc/sco_photos.py
+++ b/app/scodoc/sco_photos.py
@@ -43,6 +43,7 @@ Les images sont servies par ScoDoc, via la méthode getphotofile?etudid=xxx
"""
+from flask.helpers import make_response
from app.scodoc.sco_exceptions import ScoGenError
import datetime
import glob
@@ -120,7 +121,7 @@ def etud_photo_url(etud, size="small", fast=False):
return photo_url
-def get_photo_image(etudid=None, size="small", REQUEST=None):
+def get_photo_image(etudid=None, size="small"):
"""Returns photo image (HTTP response)
If not etudid, use "unknown" image
"""
@@ -131,24 +132,14 @@ def get_photo_image(etudid=None, size="small", REQUEST=None):
filename = photo_pathname(etud, size=size)
if not filename:
filename = UNKNOWN_IMAGE_PATH
- return _http_jpeg_file(filename, REQUEST=REQUEST)
+ return _http_jpeg_file(filename)
-def _http_jpeg_file(filename, REQUEST=None):
- """returns an image.
- This function will be modified when we kill #zope
- """
+def _http_jpeg_file(filename):
+ """returns an image as a Flask response"""
st = os.stat(filename)
last_modified = st.st_mtime # float timestamp
- last_modified_str = time.strftime(
- "%a, %d %b %Y %H:%M:%S GMT", time.gmtime(last_modified)
- )
file_size = st.st_size
- RESPONSE = REQUEST.RESPONSE
- RESPONSE.setHeader("Content-Type", "image/jpeg")
- RESPONSE.setHeader("Last-Modified", last_modified_str)
- RESPONSE.setHeader("Cache-Control", "max-age=3600")
- RESPONSE.setHeader("Content-Length", str(file_size))
header = request.headers.get("If-Modified-Since")
if header is not None:
header = header.split(";")[0]
@@ -161,13 +152,20 @@ def _http_jpeg_file(filename, REQUEST=None):
try:
dt = datetime.datetime.strptime(header, "%a, %d %b %Y %H:%M:%S GMT")
mod_since = dt.timestamp()
- except:
+ except ValueError:
mod_since = None
if (mod_since is not None) and last_modified <= mod_since:
- RESPONSE.setStatus(304) # not modified
- return ""
-
- return open(filename, mode="rb").read()
+ return "", 304 # not modified
+ #
+ last_modified_str = time.strftime(
+ "%a, %d %b %Y %H:%M:%S GMT", time.gmtime(last_modified)
+ )
+ response = make_response(open(filename, mode="rb").read())
+ response.headers["Content-Type"] = "image/jpeg"
+ response.headers["Last-Modified"] = last_modified_str
+ response.headers["Cache-Control"] = "max-age=3600"
+ response.headers["Content-Length"] = str(file_size)
+ return response
def etud_photo_is_local(etud, size="small"):
@@ -206,7 +204,7 @@ def etud_photo_html(etud=None, etudid=None, title=None, size="small"):
)
-def etud_photo_orig_html(etud=None, etudid=None, title=None, REQUEST=None):
+def etud_photo_orig_html(etud=None, etudid=None, title=None):
"""HTML img tag for the photo, in full size.
Full-size images are always stored locally in the filesystem.
They are the original uploaded images, converted in jpeg.
@@ -263,7 +261,7 @@ def store_photo(etud, data):
return 1, "ok"
-def suppress_photo(etud, REQUEST=None):
+def suppress_photo(etud):
"""Suppress a photo"""
log("suppress_photo etudid=%s" % etud["etudid"])
rel_path = photo_pathname(etud)
@@ -281,8 +279,7 @@ def suppress_photo(etud, REQUEST=None):
log("removing file %s" % filename)
os.remove(filename)
# 3- log
- if REQUEST:
- logdb(cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"])
+ logdb(cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"])
# ---------------------------------------------------------------------------
diff --git a/app/scodoc/sco_poursuite_dut.py b/app/scodoc/sco_poursuite_dut.py
index a3bdf411..4dbd7013 100644
--- a/app/scodoc/sco_poursuite_dut.py
+++ b/app/scodoc/sco_poursuite_dut.py
@@ -164,7 +164,7 @@ def _getEtudInfoGroupes(group_ids, etat=None):
return etuds
-def formsemestre_poursuite_report(formsemestre_id, format="html", REQUEST=None):
+def formsemestre_poursuite_report(formsemestre_id, format="html"):
"""Table avec informations "poursuite" """
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds = _getEtudInfoGroupes([sco_groups.get_default_group(formsemestre_id)])
diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py
index 9b8aa725..e0a7aed6 100644
--- a/app/scodoc/sco_preferences.py
+++ b/app/scodoc/sco_preferences.py
@@ -77,7 +77,7 @@ sinon, elle ne concerne que le semestre indiqué.
- avoir un mapping (read only) de toutes les valeurs:
sco_preferences.SemPreferences(formsemestre_id)
- editer les preferences globales:
- sco_preferences.get_base_preferences(self).edit(REQUEST=REQUEST)
+ sco_preferences.get_base_preferences(self).edit()
- editer les preferences d'un semestre:
SemPreferences(formsemestre_id).edit()
@@ -2014,7 +2014,7 @@ class BasePreferences(object):
self._editor.delete(cnx, pdb[0]["pref_id"])
sco_cache.invalidate_formsemestre() # > modif preferences
- def edit(self, REQUEST):
+ def edit(self):
"""HTML dialog: edit global preferences"""
from app.scodoc import html_sco_header
@@ -2033,7 +2033,7 @@ class BasePreferences(object):
form = self.build_tf_form()
tf = TrivialFormulator(
request.base_url,
- REQUEST.form,
+ request.form if request.method == "POST" else request.args,
form,
initvalues=self.prefs[None],
submitlabel="Enregistrer les modifications",
@@ -2143,7 +2143,7 @@ class SemPreferences(object):
return self.base_prefs.is_global(self.formsemestre_id, name)
# The dialog
- def edit(self, categories=[], REQUEST=None):
+ def edit(self, categories=[]):
"""Dialog to edit semestre preferences in given categories"""
from app.scodoc import html_sco_header
from app.scodoc import sco_formsemestre
@@ -2198,7 +2198,7 @@ function set_global_pref(el, pref_name) {
form.append(("formsemestre_id", {"input_type": "hidden"}))
tf = TrivialFormulator(
request.base_url,
- REQUEST.form,
+ request.form if request.method == "POST" else request.args,
form,
initvalues=self,
cssclass="sco_pref",
diff --git a/app/scodoc/sco_prepajury.py b/app/scodoc/sco_prepajury.py
index 084e311c..be2b8d12 100644
--- a/app/scodoc/sco_prepajury.py
+++ b/app/scodoc/sco_prepajury.py
@@ -48,7 +48,7 @@ from app.scodoc import sco_preferences
from app.scodoc.sco_excel import ScoExcelSheet
-def feuille_preparation_jury(formsemestre_id, REQUEST):
+def feuille_preparation_jury(formsemestre_id):
"Feuille excel pour preparation des jurys"
nt = sco_cache.NotesTableCache.get(
formsemestre_id
diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py
index 0c737a2f..028bf103 100644
--- a/app/scodoc/sco_pvjury.py
+++ b/app/scodoc/sco_pvjury.py
@@ -495,7 +495,7 @@ def pvjury_table(
return lines, titles, columns_ids
-def formsemestre_pvjury(formsemestre_id, format="html", publish=True, REQUEST=None):
+def formsemestre_pvjury(formsemestre_id, format="html", publish=True):
"""Page récapitulant les décisions de jury
dpv: result of dict_pvjury
"""
@@ -597,7 +597,7 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True, REQUEST=No
# ---------------------------------------------------------------------------
-def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST=None):
+def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None):
"""Generation PV jury en PDF: saisie des paramètres
Si etudid, PV pour un seul etudiant. Sinon, tout les inscrits au groupe indiqué.
"""
@@ -656,7 +656,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST=
menu_choix_groupe = "" # un seul etudiant à editer
tf = TrivialFormulator(
request.base_url,
- REQUEST.form,
+ request.form if request.method == "POST" else request.args,
descr,
cancelbutton="Annuler",
method="get",
@@ -790,7 +790,7 @@ def descrform_pvjury(sem):
]
-def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[], REQUEST=None):
+def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
"Lettres avis jury en PDF"
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not group_ids:
@@ -824,7 +824,7 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[], REQUEST=No
tf = TrivialFormulator(
request.base_url,
- REQUEST.form,
+ request.form if request.method == "POST" else request.args,
descr,
cancelbutton="Annuler",
method="POST",
diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py
index 9521b53c..06f7b95e 100644
--- a/app/scodoc/sco_recapcomplet.py
+++ b/app/scodoc/sco_recapcomplet.py
@@ -33,6 +33,7 @@ import time
from xml.etree import ElementTree
from flask import request
+from flask import make_response
import app.scodoc.sco_utils as scu
from app import log
@@ -68,7 +69,6 @@ def formsemestre_recapcomplet(
rank_partition_id=None, # si None, calcul rang global
pref_override=True, # si vrai, les prefs ont la priorite sur le param hidebac
force_publishing=True, # publie les XML/JSON meme si bulletins non publiés
- REQUEST=None,
):
"""Page récapitulant les notes d'un semestre.
Grand tableau récapitulatif avec toutes les notes de modules
@@ -101,7 +101,7 @@ def formsemestre_recapcomplet(
javascripts=["libjs/sorttable.js", "js/etud_info.js"],
),
sco_formsemestre_status.formsemestre_status_head(
- formsemestre_id=formsemestre_id, REQUEST=REQUEST
+ formsemestre_id=formsemestre_id
),
'")
@@ -200,7 +200,6 @@ def formsemestre_recapcomplet(
def do_formsemestre_recapcomplet(
- REQUEST=None,
formsemestre_id=None,
format="html", # html, xml, xls, xlsall, json
hidemodules=False, # ne pas montrer les modules (ignoré en XML)
@@ -959,7 +958,7 @@ def _formsemestre_recapcomplet_json(
return J, "", "json"
-def formsemestres_bulletins(annee_scolaire, REQUEST=None):
+def formsemestres_bulletins(annee_scolaire):
"""Tous les bulletins des semestres publiés des semestres de l'année indiquée.
:param annee_scolaire(int): année de début de l'année scoalaire
:returns: JSON
diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py
index 47963cda..c7bbf30e 100644
--- a/app/scodoc/sco_report.py
+++ b/app/scodoc/sco_report.py
@@ -210,7 +210,6 @@ def _results_by_category(
def formsemestre_report(
formsemestre_id,
etuds,
- REQUEST=None,
category="bac",
result="codedecision",
category_name="",
@@ -253,26 +252,25 @@ def formsemestre_report(
return tab
-# def formsemestre_report_bacs(formsemestre_id, format='html', REQUEST=None):
+# def formsemestre_report_bacs(formsemestre_id, format='html'):
# """
# Tableau sur résultats par type de bac
# """
# sem = sco_formsemestre.get_formsemestre( formsemestre_id)
# title = 'Statistiques bacs ' + sem['titreannee']
# etuds = formsemestre_etuds_stats(sem)
-# tab = formsemestre_report(formsemestre_id, etuds, REQUEST=REQUEST,
+# tab = formsemestre_report(formsemestre_id, etuds,
# category='bac', result='codedecision',
# category_name='Bac',
# title=title)
# return tab.make_page(
# title = """""" % sem,
-# format=format, page_title = title, REQUEST=REQUEST )
+# format=format, page_title = title)
def formsemestre_report_counts(
formsemestre_id,
format="html",
- REQUEST=None,
category="bac",
result="codedecision",
allkeys=False,
@@ -288,7 +286,6 @@ def formsemestre_report_counts(
tab = formsemestre_report(
formsemestre_id,
etuds,
- REQUEST=REQUEST,
category=category,
result=result,
category_name=category_name,
@@ -692,7 +689,6 @@ def formsemestre_suivi_cohorte(
civilite=None,
statut="",
only_primo=False,
- REQUEST=None,
):
"""Affiche suivi cohortes par numero de semestre"""
annee_bac = str(annee_bac)
@@ -755,7 +751,6 @@ def formsemestre_suivi_cohorte(
"""""",
_gen_form_selectetuds(
formsemestre_id,
- REQUEST=REQUEST,
only_primo=only_primo,
bac=bac,
bacspecialite=bacspecialite,
@@ -779,7 +774,6 @@ def formsemestre_suivi_cohorte(
def _gen_form_selectetuds(
formsemestre_id,
- REQUEST=None,
percent=None,
only_primo=None,
bac=None,
@@ -1164,7 +1158,7 @@ def table_suivi_parcours(formsemestre_id, only_primo=False, grouped_parcours=Tru
return tab
-def tsp_form_primo_group(REQUEST, only_primo, no_grouping, formsemestre_id, format):
+def tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, format):
"""Element de formulaire pour choisir si restriction aux primos entrants et groupement par lycees"""
F = [""" |