Grand nettoyage: élimination des REQUEST héritées de Zope.

This commit is contained in:
Emmanuel Viennet 2021-09-27 10:20:10 +02:00
parent 18d6324488
commit 057832c309
60 changed files with 661 additions and 891 deletions

View File

@ -39,68 +39,6 @@ class ZUser(object):
raise NotImplementedError() raise NotImplementedError()
class ZRequest(object):
"Emulating Zope 2 REQUEST"
def __init__(self):
# if current_app.config["DEBUG"]:
# le ReverseProxied se charge maintenant de mettre le bon protocole http ou https
# self.URL = request.base_url
# self.BASE0 = request.url_root
# else:
# self.URL = request.base_url.replace("http://", "https://")
# self.BASE0 = request.url_root.replace("http://", "https://")
# self.URL0 = self.URL
# query_string is bytes:
# self.QUERY_STRING = request.query_string.decode("utf-8")
# self.REQUEST_METHOD = request.method
# self.AUTHENTICATED_USER = current_user
# self.REMOTE_ADDR = request.remote_addr
if request.method == "POST":
# request.form is a werkzeug.datastructures.ImmutableMultiDict
# must copy to get a mutable version (needed by TrivialFormulator)
self.form = request.form.copy()
if request.files:
# Add files in form:
self.form.update(request.files)
for k in request.form:
if k.endswith(":list"):
self.form[k[:-5]] = request.form.getlist(k)
elif request.method == "GET":
self.form = {}
for k in request.args:
# current_app.logger.debug("%s\t%s" % (k, request.args.getlist(k)))
if k.endswith(":list"):
self.form[k[:-5]] = request.args.getlist(k)
else:
values = request.args.getlist(k)
self.form[k] = values[0] if len(values) == 1 else values
# current_app.logger.info("ZRequest.form=%s" % str(self.form))
self.RESPONSE = ZResponse()
def __str__(self):
return """ZREQUEST
form={r.form}
""".format(
r=self
)
class ZResponse(object):
"Emulating Zope 2 RESPONSE"
def __init__(self):
self.headers = {}
def redirect(self, url):
# current_app.logger.debug("ZResponse redirect to:" + str(url))
return flask.redirect(url) # http 302
def setHeader(self, header, value):
self.headers[header.lower()] = value
def scodoc(func): def scodoc(func):
"""Décorateur pour toutes les fonctions ScoDoc """Décorateur pour toutes les fonctions ScoDoc
Affecte le département à g Affecte le département à g
@ -131,7 +69,6 @@ def permission_required(permission):
def decorator(f): def decorator(f):
@wraps(f) @wraps(f)
def decorated_function(*args, **kwargs): def decorated_function(*args, **kwargs):
# current_app.logger.info("PERMISSION; kwargs=%s" % str(kwargs))
scodoc_dept = getattr(g, "scodoc_dept", None) scodoc_dept = getattr(g, "scodoc_dept", None)
if not current_user.has_permission(permission, scodoc_dept): if not current_user.has_permission(permission, scodoc_dept):
abort(403) abort(403)
@ -192,7 +129,6 @@ def admin_required(f):
def scodoc7func(func): def scodoc7func(func):
"""Décorateur pour intégrer les fonctions Zope 2 de ScoDoc 7. """Décorateur pour intégrer les fonctions Zope 2 de ScoDoc 7.
Ajoute l'argument REQUEST s'il est dans la signature de la fonction.
Les paramètres de la query string deviennent des (keywords) paramètres de la fonction. Les paramètres de la query string deviennent des (keywords) paramètres de la fonction.
""" """
@ -209,15 +145,17 @@ def scodoc7func(func):
""" """
# Détermine si on est appelé via une route ("toplevel") # Détermine si on est appelé via une route ("toplevel")
# ou par un appel de fonction python normal. # ou par un appel de fonction python normal.
top_level = not hasattr(g, "zrequest") top_level = not hasattr(g, "scodoc7_decorated")
if not top_level: if not top_level:
# ne "redécore" pas # ne "redécore" pas
return func(*args, **kwargs) return func(*args, **kwargs)
g.scodoc7_decorated = True
# --- Emulate Zope's REQUEST # --- Emulate Zope's REQUEST
REQUEST = ZRequest() # REQUEST = ZRequest()
g.zrequest = REQUEST # g.zrequest = REQUEST
req_args = REQUEST.form # args from query string (get) or form (post) # args from query string (get) or form (post)
# --- Add positional arguments req_args = request.form if request.method == "POST" else request.args
## --- Add positional arguments
pos_arg_values = [] pos_arg_values = []
argspec = inspect.getfullargspec(func) argspec = inspect.getfullargspec(func)
# current_app.logger.info("argspec=%s" % str(argspec)) # current_app.logger.info("argspec=%s" % str(argspec))
@ -228,7 +166,10 @@ def scodoc7func(func):
arg_names = argspec.args arg_names = argspec.args
for arg_name in arg_names: for arg_name in arg_names:
if arg_name == "REQUEST": # special case if arg_name == "REQUEST": # special case
pos_arg_values.append(REQUEST) raise ValueError(
"invalid REQUEST parameter !"
) # debug check, TODO remove after tests
# pos_arg_values.append(REQUEST)
else: else:
# peut produire une KeyError s'il manque un argument attendu: # peut produire une KeyError s'il manque un argument attendu:
v = req_args[arg_name] v = req_args[arg_name]
@ -244,9 +185,9 @@ def scodoc7func(func):
# Add keyword arguments # Add keyword arguments
if nb_default_args: if nb_default_args:
for arg_name in argspec.args[-nb_default_args:]: for arg_name in argspec.args[-nb_default_args:]:
if arg_name == "REQUEST": # special case # if arg_name == "REQUEST": # special case
kwargs[arg_name] = REQUEST # kwargs[arg_name] = REQUEST
elif arg_name in req_args: if arg_name in req_args:
# set argument kw optionnel # set argument kw optionnel
v = req_args[arg_name] v = req_args[arg_name]
# try to convert all arguments to INTEGERS # try to convert all arguments to INTEGERS
@ -270,13 +211,13 @@ def scodoc7func(func):
# Build response, adding collected http headers: # Build response, adding collected http headers:
headers = [] headers = []
kw = {"response": value, "status": 200} kw = {"response": value, "status": 200}
if g.zrequest: # if g.zrequest:
headers = g.zrequest.RESPONSE.headers # headers = g.zrequest.RESPONSE.headers
if not headers: # if not headers:
# no customized header, speedup: # # no customized header, speedup:
return value # return value
if "content-type" in headers: # if "content-type" in headers:
kw["mimetype"] = headers["content-type"] # kw["mimetype"] = headers["content-type"]
r = flask.Response(**kw) r = flask.Response(**kw)
for h in headers: for h in headers:
r.headers[h] = headers[h] r.headers[h] = headers[h]

View File

@ -135,7 +135,7 @@ class TF(object):
is_submitted=False, is_submitted=False,
): ):
self.form_url = form_url self.form_url = form_url
self.values = values self.values = values.copy()
self.formdescription = list(formdescription) self.formdescription = list(formdescription)
self.initvalues = initvalues self.initvalues = initvalues
self.method = method self.method = method

View File

@ -39,17 +39,11 @@ from app.scodoc.sco_permissions import Permission
def sidebar_common(): def sidebar_common():
"partie commune à toutes les sidebar" "partie commune à toutes les sidebar"
params = {
"ScoURL": scu.ScoURL(),
"UsersURL": scu.UsersURL(),
"NotesURL": scu.NotesURL(),
"AbsencesURL": scu.AbsencesURL(),
"authuser": current_user.user_name,
}
H = [ H = [
f"""<a class="scodoc_title" href="about">ScoDoc 9</a> f"""<a class="scodoc_title" href="about">ScoDoc 9</a>
<div id="authuser"><a id="authuserlink" href="{ <div id="authuser"><a id="authuserlink" href="{
url_for("users.user_info_page", scodoc_dept=g.scodoc_dept, user_name=current_user.user_name) url_for("users.user_info_page",
scodoc_dept=g.scodoc_dept, user_name=current_user.user_name)
}">{current_user.user_name}</a> }">{current_user.user_name}</a>
<br/><a id="deconnectlink" href="{url_for("auth.logout")}">déconnexion</a> <br/><a id="deconnectlink" href="{url_for("auth.logout")}">déconnexion</a>
</div> </div>
@ -70,7 +64,8 @@ def sidebar_common():
if current_user.has_permission(Permission.ScoChangePreferences): if current_user.has_permission(Permission.ScoChangePreferences):
H.append( H.append(
f"""<a href="{url_for("scolar.edit_preferences", scodoc_dept=g.scodoc_dept)}" class="sidebar">Paramétrage</a> <br/>""" f"""<a href="{url_for("scolar.edit_preferences", scodoc_dept=g.scodoc_dept)}"
class="sidebar">Paramétrage</a> <br/>"""
) )
return "".join(H) return "".join(H)
@ -96,7 +91,8 @@ def sidebar():
""" """
] ]
# ---- Il y-a-t-il un etudiant selectionné ? # ---- Il y-a-t-il un etudiant selectionné ?
etudid = None etudid = g.get("etudid", None)
if not etudid:
if request.method == "GET": if request.method == "GET":
etudid = request.args.get("etudid", None) etudid = request.args.get("etudid", None)
elif request.method == "POST": elif request.method == "POST":

View File

@ -272,7 +272,6 @@ PVArchive = SemsArchiver()
def do_formsemestre_archive( def do_formsemestre_archive(
REQUEST,
formsemestre_id, formsemestre_id,
group_ids=[], # si indiqué, ne prend que ces groupes group_ids=[], # si indiqué, ne prend que ces groupes
description="", description="",
@ -340,14 +339,12 @@ def do_formsemestre_archive(
data = data.encode(scu.SCO_ENCODING) data = data.encode(scu.SCO_ENCODING)
PVArchive.store(archive_id, "Bulletins.xml", data) PVArchive.store(archive_id, "Bulletins.xml", data)
# Decisions de jury, en XLS # Decisions de jury, en XLS
data = sco_pvjury.formsemestre_pvjury( data = sco_pvjury.formsemestre_pvjury(formsemestre_id, format="xls", publish=False)
formsemestre_id, format="xls", REQUEST=REQUEST, publish=False
)
if data: if data:
PVArchive.store(archive_id, "Decisions_Jury" + scu.XLSX_SUFFIX, data) PVArchive.store(archive_id, "Decisions_Jury" + scu.XLSX_SUFFIX, data)
# Classeur bulletins (PDF) # Classeur bulletins (PDF)
data, _ = sco_bulletins_pdf.get_formsemestre_bulletins_pdf( data, _ = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
formsemestre_id, REQUEST, version=bulVersion formsemestre_id, version=bulVersion
) )
if data: if data:
PVArchive.store(archive_id, "Bulletins.pdf", data) PVArchive.store(archive_id, "Bulletins.pdf", data)
@ -378,7 +375,7 @@ def do_formsemestre_archive(
PVArchive.store(archive_id, "PV_Jury%s.pdf" % groups_filename, data) PVArchive.store(archive_id, "PV_Jury%s.pdf" % groups_filename, data)
def formsemestre_archive(REQUEST, formsemestre_id, group_ids=[]): def formsemestre_archive(formsemestre_id, group_ids=[]):
"""Make and store new archive for this formsemestre. """Make and store new archive for this formsemestre.
(all students or only selected groups) (all students or only selected groups)
""" """
@ -456,7 +453,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="POST", method="POST",
@ -478,7 +475,6 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
else: else:
tf[2]["anonymous"] = False tf[2]["anonymous"] = False
do_formsemestre_archive( do_formsemestre_archive(
REQUEST,
formsemestre_id, formsemestre_id,
group_ids=group_ids, group_ids=group_ids,
description=tf[2]["description"], description=tf[2]["description"],
@ -502,7 +498,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement.
) )
def formsemestre_list_archives(REQUEST, formsemestre_id): def formsemestre_list_archives(formsemestre_id):
"""Page listing archives""" """Page listing archives"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem_archive_id = formsemestre_id sem_archive_id = formsemestre_id
@ -552,9 +548,7 @@ def formsemestre_get_archived_file(formsemestre_id, archive_name, filename):
return PVArchive.get_archived_file(sem_archive_id, archive_name, filename) return PVArchive.get_archived_file(sem_archive_id, archive_name, filename)
def formsemestre_delete_archive( def formsemestre_delete_archive(formsemestre_id, archive_name, dialog_confirmed=False):
REQUEST, formsemestre_id, archive_name, dialog_confirmed=False
):
"""Delete an archive""" """Delete an archive"""
if not sco_permissions_check.can_edit_pv(formsemestre_id): if not sco_permissions_check.can_edit_pv(formsemestre_id):
raise AccessDenied("opération non autorisée pour %s" % str(current_user)) raise AccessDenied("opération non autorisée pour %s" % str(current_user))

View File

@ -59,7 +59,7 @@ def can_edit_etud_archive(authuser):
return authuser.has_permission(Permission.ScoEtudAddAnnotations) return authuser.has_permission(Permission.ScoEtudAddAnnotations)
def etud_list_archives_html(REQUEST, etudid): def etud_list_archives_html(etudid):
"""HTML snippet listing archives""" """HTML snippet listing archives"""
can_edit = can_edit_etud_archive(current_user) can_edit = can_edit_etud_archive(current_user)
etuds = sco_etud.get_etud_info(etudid=etudid) etuds = sco_etud.get_etud_info(etudid=etudid)
@ -131,7 +131,7 @@ def add_archives_info_to_etud_list(etuds):
etud["etudarchive"] = ", ".join(l) etud["etudarchive"] = ", ".join(l)
def etud_upload_file_form(REQUEST, etudid): def etud_upload_file_form(etudid):
"""Page with a form to choose and upload a file, with a description.""" """Page with a form to choose and upload a file, with a description."""
# check permission # check permission
if not can_edit_etud_archive(current_user): if not can_edit_etud_archive(current_user):
@ -153,7 +153,7 @@ def etud_upload_file_form(REQUEST, etudid):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("etudid", {"default": etudid, "input_type": "hidden"}), ("etudid", {"default": etudid, "input_type": "hidden"}),
("datafile", {"input_type": "file", "title": "Fichier", "size": 30}), ("datafile", {"input_type": "file", "title": "Fichier", "size": 30}),
@ -198,7 +198,7 @@ def _store_etud_file_to_new_archive(etud_archive_id, data, filename, description
EtudsArchive.store(archive_id, filename, data) EtudsArchive.store(archive_id, filename, data)
def etud_delete_archive(REQUEST, etudid, archive_name, dialog_confirmed=False): def etud_delete_archive(etudid, archive_name, dialog_confirmed=False):
"""Delete an archive""" """Delete an archive"""
# check permission # check permission
if not can_edit_etud_archive(current_user): if not can_edit_etud_archive(current_user):
@ -250,7 +250,7 @@ def etud_get_archived_file(etudid, archive_name, filename):
# --- Upload d'un ensemble de fichiers (pour un groupe d'étudiants) # --- Upload d'un ensemble de fichiers (pour un groupe d'étudiants)
def etudarchive_generate_excel_sample(group_id=None, REQUEST=None): def etudarchive_generate_excel_sample(group_id=None):
"""Feuille excel pour import fichiers etudiants (utilisé pour admissions)""" """Feuille excel pour import fichiers etudiants (utilisé pour admissions)"""
fmt = sco_import_etuds.sco_import_format() fmt = sco_import_etuds.sco_import_format()
data = sco_import_etuds.sco_import_generate_excel_sample( data = sco_import_etuds.sco_import_generate_excel_sample(
@ -274,7 +274,7 @@ def etudarchive_generate_excel_sample(group_id=None, REQUEST=None):
) )
def etudarchive_import_files_form(group_id, REQUEST=None): def etudarchive_import_files_form(group_id):
"""Formulaire pour importation fichiers d'un groupe""" """Formulaire pour importation fichiers d'un groupe"""
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
@ -309,7 +309,7 @@ def etudarchive_import_files_form(group_id, REQUEST=None):
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}), ("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}),
("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}), ("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}),

View File

@ -766,7 +766,6 @@ def formsemestre_bulletinetud(
xml_with_decisions=False, xml_with_decisions=False,
force_publishing=False, # force publication meme si semestre non publie sur "portail" force_publishing=False, # force publication meme si semestre non publie sur "portail"
prefer_mail_perso=False, prefer_mail_perso=False,
REQUEST=None,
): ):
"page bulletin de notes" "page bulletin de notes"
try: try:
@ -786,7 +785,6 @@ def formsemestre_bulletinetud(
xml_with_decisions=xml_with_decisions, xml_with_decisions=xml_with_decisions,
force_publishing=force_publishing, force_publishing=force_publishing,
prefer_mail_perso=prefer_mail_perso, prefer_mail_perso=prefer_mail_perso,
REQUEST=REQUEST,
)[0] )[0]
if format not in {"html", "pdfmail"}: if format not in {"html", "pdfmail"}:
filename = scu.bul_filename(sem, etud, format) filename = scu.bul_filename(sem, etud, format)
@ -795,7 +793,7 @@ def formsemestre_bulletinetud(
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [ H = [
_formsemestre_bulletinetud_header_html( _formsemestre_bulletinetud_header_html(
etud, etudid, sem, formsemestre_id, format, version, REQUEST etud, etudid, sem, formsemestre_id, format, version
), ),
bulletin, bulletin,
] ]
@ -853,7 +851,6 @@ def do_formsemestre_bulletinetud(
etudid, etudid,
version="long", # short, long, selectedevals version="long", # short, long, selectedevals
format="html", format="html",
REQUEST=None,
nohtml=False, nohtml=False,
xml_with_decisions=False, # force decisions dans XML xml_with_decisions=False, # force decisions dans XML
force_publishing=False, # force publication meme si semestre non publie sur "portail" force_publishing=False, # force publication meme si semestre non publie sur "portail"
@ -1005,7 +1002,6 @@ def _formsemestre_bulletinetud_header_html(
formsemestre_id=None, formsemestre_id=None,
format=None, format=None,
version=None, version=None,
REQUEST=None,
): ):
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(

View File

@ -164,7 +164,7 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"):
return sco_pdf.makeParas(text, style, suppress_empty=suppress_empty_pars) return sco_pdf.makeParas(text, style, suppress_empty=suppress_empty_pars)
def get_formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedevals"): def get_formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"):
"document pdf et filename" "document pdf et filename"
from app.scodoc import sco_bulletins from app.scodoc import sco_bulletins
@ -184,7 +184,6 @@ def get_formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedev
etudid, etudid,
format="pdfpart", format="pdfpart",
version=version, version=version,
REQUEST=REQUEST,
) )
fragments += frag fragments += frag
filigrannes[i] = filigranne filigrannes[i] = filigranne
@ -192,7 +191,7 @@ def get_formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedev
i = i + 1 i = i + 1
# #
infos = {"DeptName": sco_preferences.get_preference("DeptName", formsemestre_id)} infos = {"DeptName": sco_preferences.get_preference("DeptName", formsemestre_id)}
if REQUEST: if request:
server_name = request.url_root server_name = request.url_root
else: else:
server_name = "" server_name = ""
@ -220,7 +219,7 @@ def get_formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedev
return pdfdoc, filename return pdfdoc, filename
def get_etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"): def get_etud_bulletins_pdf(etudid, version="selectedevals"):
"Bulletins pdf de tous les semestres de l'étudiant, et filename" "Bulletins pdf de tous les semestres de l'étudiant, et filename"
from app.scodoc import sco_bulletins from app.scodoc import sco_bulletins
@ -235,14 +234,13 @@ def get_etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"):
etudid, etudid,
format="pdfpart", format="pdfpart",
version=version, version=version,
REQUEST=REQUEST,
) )
fragments += frag fragments += frag
filigrannes[i] = filigranne filigrannes[i] = filigranne
bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015 bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015
i = i + 1 i = i + 1
infos = {"DeptName": sco_preferences.get_preference("DeptName")} infos = {"DeptName": sco_preferences.get_preference("DeptName")}
if REQUEST: if request:
server_name = request.url_root server_name = request.url_root
else: else:
server_name = "" server_name = ""

View File

@ -56,7 +56,7 @@ et sur page "réglages bulletin" (avec formsemestre_id)
# import os # import os
# def form_change_bul_sig(side, formsemestre_id=None, REQUEST=None): # def form_change_bul_sig(side, formsemestre_id=None):
# """Change pdf signature""" # """Change pdf signature"""
# filename = _get_sig_existing_filename( # filename = _get_sig_existing_filename(
# side, formsemestre_id=formsemestre_id # side, formsemestre_id=formsemestre_id
@ -69,7 +69,7 @@ et sur page "réglages bulletin" (avec formsemestre_id)
# raise ValueError("invalid value for 'side' parameter") # raise ValueError("invalid value for 'side' parameter")
# signatureloc = get_bul_sig_img() # signatureloc = get_bul_sig_img()
# H = [ # H = [
# self.sco_header(REQUEST, page_title="Changement de signature"), # self.sco_header(page_title="Changement de signature"),
# """<h2>Changement de la signature bulletin de %(sidetxt)s</h2> # """<h2>Changement de la signature bulletin de %(sidetxt)s</h2>
# """ # """
# % (sidetxt,), # % (sidetxt,),

View File

@ -47,7 +47,6 @@ def formsemestre_table_estim_cost(
n_group_tp=1, n_group_tp=1,
coef_tp=1, coef_tp=1,
coef_cours=1.5, coef_cours=1.5,
REQUEST=None,
): ):
""" """
Rapports estimation coût de formation basé sur le programme pédagogique Rapports estimation coût de formation basé sur le programme pédagogique
@ -158,7 +157,6 @@ def formsemestre_estim_cost(
coef_tp=1, coef_tp=1,
coef_cours=1.5, coef_cours=1.5,
format="html", format="html",
REQUEST=None,
): ):
"""Page (formulaire) estimation coûts""" """Page (formulaire) estimation coûts"""
@ -173,7 +171,6 @@ def formsemestre_estim_cost(
n_group_tp=n_group_tp, n_group_tp=n_group_tp,
coef_tp=coef_tp, coef_tp=coef_tp,
coef_cours=coef_cours, coef_cours=coef_cours,
REQUEST=REQUEST,
) )
h = """ h = """
<form name="f" method="get" action="%s"> <form name="f" method="get" action="%s">

View File

@ -46,7 +46,7 @@ from app.scodoc import sco_up_to_date
from app.scodoc import sco_users from app.scodoc import sco_users
def index_html(REQUEST=None, showcodes=0, showsemtable=0): def index_html(showcodes=0, showsemtable=0):
"Page accueil département (liste des semestres)" "Page accueil département (liste des semestres)"
showsemtable = int(showsemtable) showsemtable = int(showsemtable)
H = [] H = []

View File

@ -119,12 +119,12 @@ def do_formation_delete(oid):
) )
def formation_create(REQUEST=None): def formation_create():
"""Creation d'une formation""" """Creation d'une formation"""
return formation_edit(create=True, REQUEST=REQUEST) return formation_edit(create=True)
def formation_edit(formation_id=None, create=False, REQUEST=None): def formation_edit(formation_id=None, create=False):
"""Edit or create a formation""" """Edit or create a formation"""
if create: if create:
H = [ H = [
@ -160,7 +160,7 @@ def formation_edit(formation_id=None, create=False, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("formation_id", {"default": formation_id, "input_type": "hidden"}), ("formation_id", {"default": formation_id, "input_type": "hidden"}),
( (

View File

@ -92,7 +92,7 @@ def do_matiere_create(args):
return r return r
def matiere_create(ue_id=None, REQUEST=None): def matiere_create(ue_id=None):
"""Creation d'une matiere""" """Creation d'une matiere"""
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
@ -117,7 +117,7 @@ associé.
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("ue_id", {"input_type": "hidden", "default": ue_id}), ("ue_id", {"input_type": "hidden", "default": ue_id}),
("titre", {"size": 30, "explanation": "nom de la matière."}), ("titre", {"size": 30, "explanation": "nom de la matière."}),
@ -189,7 +189,7 @@ def do_matiere_delete(oid):
) )
def matiere_delete(matiere_id=None, REQUEST=None): def matiere_delete(matiere_id=None):
"""Delete an UE""" """Delete an UE"""
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
@ -203,7 +203,7 @@ def matiere_delete(matiere_id=None, REQUEST=None):
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(UE["formation_id"]) dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(UE["formation_id"])
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("matiere_id", {"input_type": "hidden"}),), (("matiere_id", {"input_type": "hidden"}),),
initvalues=M, initvalues=M,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -218,7 +218,7 @@ def matiere_delete(matiere_id=None, REQUEST=None):
return flask.redirect(dest_url) return flask.redirect(dest_url)
def matiere_edit(matiere_id=None, REQUEST=None): def matiere_edit(matiere_id=None):
"""Edit matiere""" """Edit matiere"""
from app.scodoc import sco_formations from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
@ -257,7 +257,7 @@ associé.
</p>""" </p>"""
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("matiere_id", {"input_type": "hidden"}), ("matiere_id", {"input_type": "hidden"}),
( (

View File

@ -119,7 +119,7 @@ def do_module_create(args) -> int:
return r return r
def module_create(matiere_id=None, REQUEST=None): def module_create(matiere_id=None):
"""Creation d'un module""" """Creation d'un module"""
from app.scodoc import sco_formations from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
@ -145,7 +145,7 @@ def module_create(matiere_id=None, REQUEST=None):
default_num = 10 default_num = 10
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"code", "code",
@ -281,7 +281,7 @@ def do_module_delete(oid):
) )
def module_delete(module_id=None, REQUEST=None): def module_delete(module_id=None):
"""Delete a module""" """Delete a module"""
if not module_id: if not module_id:
raise ScoValueError("invalid module !") raise ScoValueError("invalid module !")
@ -297,7 +297,7 @@ def module_delete(module_id=None, REQUEST=None):
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"]) dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"])
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("module_id", {"input_type": "hidden"}),), (("module_id", {"input_type": "hidden"}),),
initvalues=Mod, initvalues=Mod,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -339,7 +339,7 @@ def check_module_code_unicity(code, field, formation_id, module_id=None):
return len(Mods) == 0 return len(Mods) == 0
def module_edit(module_id=None, REQUEST=None): def module_edit(module_id=None):
"""Edit a module""" """Edit a module"""
from app.scodoc import sco_formations from app.scodoc import sco_formations
from app.scodoc import sco_tag_module from app.scodoc import sco_tag_module
@ -391,7 +391,7 @@ def module_edit(module_id=None, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"code", "code",
@ -515,7 +515,7 @@ def module_edit(module_id=None, REQUEST=None):
# Edition en ligne du code Apogee # Edition en ligne du code Apogee
def edit_module_set_code_apogee(id=None, value=None, REQUEST=None): def edit_module_set_code_apogee(id=None, value=None):
"Set UE code apogee" "Set UE code apogee"
module_id = id module_id = id
value = value.strip("-_ \t") value = value.strip("-_ \t")
@ -531,7 +531,7 @@ def edit_module_set_code_apogee(id=None, value=None, REQUEST=None):
return value return value
def module_list(formation_id, REQUEST=None): def module_list(formation_id):
"""Liste des modules de la formation """Liste des modules de la formation
(XXX inutile ou a revoir) (XXX inutile ou a revoir)
""" """
@ -584,7 +584,7 @@ def module_count_moduleimpls(module_id):
return len(mods) return len(mods)
def formation_add_malus_modules(formation_id, titre=None, REQUEST=None): def formation_add_malus_modules(formation_id, titre=None, redirect=True):
"""Création d'un module de "malus" dans chaque UE d'une formation""" """Création d'un module de "malus" dans chaque UE d'une formation"""
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
@ -600,13 +600,13 @@ def formation_add_malus_modules(formation_id, titre=None, REQUEST=None):
] ]
) )
if nb_mod_malus == 0: if nb_mod_malus == 0:
ue_add_malus_module(ue["ue_id"], titre=titre, REQUEST=REQUEST) ue_add_malus_module(ue["ue_id"], titre=titre)
if REQUEST: if redirect:
return flask.redirect("ue_list?formation_id=" + str(formation_id)) return flask.redirect("ue_list?formation_id=" + str(formation_id))
def ue_add_malus_module(ue_id, titre=None, code=None, REQUEST=None): def ue_add_malus_module(ue_id, titre=None, code=None):
"""Add a malus module in this ue""" """Add a malus module in this ue"""
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue

View File

@ -186,12 +186,12 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
return None return None
def ue_create(formation_id=None, REQUEST=None): def ue_create(formation_id=None):
"""Creation d'une UE""" """Creation d'une UE"""
return ue_edit(create=True, formation_id=formation_id, REQUEST=REQUEST) return ue_edit(create=True, formation_id=formation_id)
def ue_edit(ue_id=None, create=False, formation_id=None, REQUEST=None): def ue_edit(ue_id=None, create=False, formation_id=None):
"""Modification ou creation d'une UE""" """Modification ou creation d'une UE"""
from app.scodoc import sco_formations from app.scodoc import sco_formations
@ -328,7 +328,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, REQUEST=None):
) )
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
fw, fw,
initvalues=initvalues, initvalues=initvalues,
submitlabel=submitlabel, submitlabel=submitlabel,
@ -958,7 +958,7 @@ def ue_is_locked(ue_id):
# ---- Table recap formation # ---- Table recap formation
def formation_table_recap(formation_id, format="html", REQUEST=None): def formation_table_recap(formation_id, format="html"):
"""Table recapitulant formation.""" """Table recapitulant formation."""
from app.scodoc import sco_formations from app.scodoc import sco_formations

View File

@ -123,7 +123,7 @@ def get_edt_transcodage_groups(formsemestre_id):
return edt2sco, sco2edt, msg return edt2sco, sco2edt, msg
def group_edt_json(group_id, start="", end="", REQUEST=None): # actuellement inutilisé def group_edt_json(group_id, start="", end=""): # actuellement inutilisé
"""EDT complet du semestre, au format JSON """EDT complet du semestre, au format JSON
TODO: indiquer un groupe TODO: indiquer un groupe
TODO: utiliser start et end (2 dates au format ISO YYYY-MM-DD) TODO: utiliser start et end (2 dates au format ISO YYYY-MM-DD)
@ -159,9 +159,7 @@ for e in events:
""" """
def experimental_calendar( def experimental_calendar(group_id=None, formsemestre_id=None): # inutilisé
group_id=None, formsemestre_id=None, REQUEST=None
): # inutilisé
"""experimental page""" """experimental page"""
return "\n".join( return "\n".join(
[ [

View File

@ -62,7 +62,6 @@ def apo_semset_maq_status(
block_export_res_ues=False, block_export_res_ues=False,
block_export_res_modules=False, block_export_res_modules=False,
block_export_res_sdj=True, block_export_res_sdj=True,
REQUEST=None,
): ):
"""Page statut / tableau de bord""" """Page statut / tableau de bord"""
if not semset_id: if not semset_id:
@ -83,7 +82,7 @@ def apo_semset_maq_status(
prefs = sco_preferences.SemPreferences() prefs = sco_preferences.SemPreferences()
tab_archives = table_apo_csv_list(semset, REQUEST=REQUEST) tab_archives = table_apo_csv_list(semset)
( (
ok_for_export, ok_for_export,
@ -430,7 +429,7 @@ def apo_semset_maq_status(
return "\n".join(H) return "\n".join(H)
def table_apo_csv_list(semset, REQUEST=None): def table_apo_csv_list(semset):
"""Table des archives (triée par date d'archivage)""" """Table des archives (triée par date d'archivage)"""
annee_scolaire = semset["annee_scolaire"] annee_scolaire = semset["annee_scolaire"]
sem_id = semset["sem_id"] sem_id = semset["sem_id"]
@ -484,7 +483,7 @@ def table_apo_csv_list(semset, REQUEST=None):
return tab return tab
def view_apo_etuds(semset_id, title="", nip_list="", format="html", REQUEST=None): def view_apo_etuds(semset_id, title="", nip_list="", format="html"):
"""Table des étudiants Apogée par nips """Table des étudiants Apogée par nips
nip_list est une chaine, codes nip séparés par des , nip_list est une chaine, codes nip séparés par des ,
""" """
@ -517,11 +516,10 @@ def view_apo_etuds(semset_id, title="", nip_list="", format="html", REQUEST=None
etuds=list(etuds.values()), etuds=list(etuds.values()),
keys=("nip", "etape_apo", "nom", "prenom", "inscriptions_scodoc"), keys=("nip", "etape_apo", "nom", "prenom", "inscriptions_scodoc"),
format=format, format=format,
REQUEST=REQUEST,
) )
def view_scodoc_etuds(semset_id, title="", nip_list="", format="html", REQUEST=None): def view_scodoc_etuds(semset_id, title="", nip_list="", format="html"):
"""Table des étudiants ScoDoc par nips ou etudids""" """Table des étudiants ScoDoc par nips ou etudids"""
if not isinstance(nip_list, str): if not isinstance(nip_list, str):
nip_list = str(nip_list) nip_list = str(nip_list)
@ -541,13 +539,10 @@ def view_scodoc_etuds(semset_id, title="", nip_list="", format="html", REQUEST=N
etuds=etuds, etuds=etuds,
keys=("code_nip", "nom", "prenom"), keys=("code_nip", "nom", "prenom"),
format=format, format=format,
REQUEST=REQUEST,
) )
def _view_etuds_page( def _view_etuds_page(semset_id, title="", etuds=[], keys=(), format="html"):
semset_id, title="", etuds=[], keys=(), format="html", REQUEST=None
):
# Tri les étudiants par nom: # Tri les étudiants par nom:
if etuds: if etuds:
etuds.sort(key=lambda x: (x["nom"], x["prenom"])) etuds.sort(key=lambda x: (x["nom"], x["prenom"]))
@ -590,9 +585,7 @@ def _view_etuds_page(
return "\n".join(H) + html_sco_header.sco_footer() return "\n".join(H) + html_sco_header.sco_footer()
def view_apo_csv_store( def view_apo_csv_store(semset_id="", csvfile=None, data="", autodetect=False):
semset_id="", csvfile=None, data="", autodetect=False, REQUEST=None
):
"""Store CSV data """Store CSV data
Le semset identifie l'annee scolaire et le semestre Le semset identifie l'annee scolaire et le semestre
Si csvfile, lit depuis FILE, sinon utilise data Si csvfile, lit depuis FILE, sinon utilise data
@ -627,7 +620,7 @@ def view_apo_csv_store(
return flask.redirect("apo_semset_maq_status?semset_id=" + semset_id) return flask.redirect("apo_semset_maq_status?semset_id=" + semset_id)
def view_apo_csv_download_and_store(etape_apo="", semset_id="", REQUEST=None): def view_apo_csv_download_and_store(etape_apo="", semset_id=""):
"""Download maquette and store it""" """Download maquette and store it"""
if not semset_id: if not semset_id:
raise ValueError("invalid null semset_id") raise ValueError("invalid null semset_id")
@ -639,12 +632,10 @@ def view_apo_csv_download_and_store(etape_apo="", semset_id="", REQUEST=None):
# here, data is utf8 # here, data is utf8
# but we store and generate latin1 files, to ease further import in Apogée # but we store and generate latin1 files, to ease further import in Apogée
data = data.decode(APO_PORTAL_ENCODING).encode(APO_INPUT_ENCODING) # XXX #py3 data = data.decode(APO_PORTAL_ENCODING).encode(APO_INPUT_ENCODING) # XXX #py3
return view_apo_csv_store(semset_id, data=data, autodetect=False, REQUEST=REQUEST) return view_apo_csv_store(semset_id, data=data, autodetect=False)
def view_apo_csv_delete( def view_apo_csv_delete(etape_apo="", semset_id="", dialog_confirmed=False):
etape_apo="", semset_id="", dialog_confirmed=False, REQUEST=None
):
"""Delete CSV file""" """Delete CSV file"""
if not semset_id: if not semset_id:
raise ValueError("invalid null semset_id") raise ValueError("invalid null semset_id")
@ -667,7 +658,7 @@ def view_apo_csv_delete(
return flask.redirect(dest_url + "&head_message=Archive%20supprimée") return flask.redirect(dest_url + "&head_message=Archive%20supprimée")
def view_apo_csv(etape_apo="", semset_id="", format="html", REQUEST=None): def view_apo_csv(etape_apo="", semset_id="", format="html"):
"""Visualise une maquette stockée """Visualise une maquette stockée
Si format="raw", renvoie le fichier maquette tel quel Si format="raw", renvoie le fichier maquette tel quel
""" """

View File

@ -314,9 +314,7 @@ def check_nom_prenom(cnx, nom="", prenom="", etudid=None):
return True, len(res) return True, len(res)
def _check_duplicate_code( def _check_duplicate_code(cnx, args, code_name, disable_notify=False, edit=True):
cnx, args, code_name, disable_notify=False, edit=True, REQUEST=None
):
etudid = args.get("etudid", None) etudid = args.get("etudid", None)
if args.get(code_name, None): if args.get(code_name, None):
etuds = identite_list(cnx, {code_name: str(args[code_name])}) etuds = identite_list(cnx, {code_name: str(args[code_name])})
@ -374,15 +372,15 @@ def _check_civilite(args):
args["civilite"] = input_civilite(civilite) # TODO: A faire valider args["civilite"] = input_civilite(civilite) # TODO: A faire valider
def identite_edit(cnx, args, disable_notify=False, REQUEST=None): def identite_edit(cnx, args, disable_notify=False):
"""Modifie l'identite d'un étudiant. """Modifie l'identite d'un étudiant.
Si pref notification et difference, envoie message notification, sauf si disable_notify Si pref notification et difference, envoie message notification, sauf si disable_notify
""" """
_check_duplicate_code( _check_duplicate_code(
cnx, args, "code_nip", disable_notify=disable_notify, edit=True, REQUEST=REQUEST cnx, args, "code_nip", disable_notify=disable_notify, edit=True
) )
_check_duplicate_code( _check_duplicate_code(
cnx, args, "code_ine", disable_notify=disable_notify, edit=True, REQUEST=REQUEST cnx, args, "code_ine", disable_notify=disable_notify, edit=True
) )
notify_to = None notify_to = None
if not disable_notify: if not disable_notify:
@ -410,10 +408,10 @@ def identite_edit(cnx, args, disable_notify=False, REQUEST=None):
) )
def identite_create(cnx, args, REQUEST=None): def identite_create(cnx, args):
"check unique etudid, then create" "check unique etudid, then create"
_check_duplicate_code(cnx, args, "code_nip", edit=False, REQUEST=REQUEST) _check_duplicate_code(cnx, args, "code_nip", edit=False)
_check_duplicate_code(cnx, args, "code_ine", edit=False, REQUEST=REQUEST) _check_duplicate_code(cnx, args, "code_ine", edit=False)
_check_civilite(args) _check_civilite(args)
if "etudid" in args: if "etudid" in args:
@ -577,8 +575,8 @@ admission_edit = _admissionEditor.edit
# Edition simultanee de identite et admission # Edition simultanee de identite et admission
class EtudIdentEditor(object): class EtudIdentEditor(object):
def create(self, cnx, args, REQUEST=None): def create(self, cnx, args):
etudid = identite_create(cnx, args, REQUEST) etudid = identite_create(cnx, args)
args["etudid"] = etudid args["etudid"] = etudid
admission_create(cnx, args) admission_create(cnx, args)
return etudid return etudid
@ -609,8 +607,8 @@ class EtudIdentEditor(object):
res.sort(key=itemgetter("nom", "prenom")) res.sort(key=itemgetter("nom", "prenom"))
return res return res
def edit(self, cnx, args, disable_notify=False, REQUEST=None): def edit(self, cnx, args, disable_notify=False):
identite_edit(cnx, args, disable_notify=disable_notify, REQUEST=REQUEST) identite_edit(cnx, args, disable_notify=disable_notify)
if "adm_id" in args: # safety net if "adm_id" in args: # safety net
admission_edit(cnx, args) admission_edit(cnx, args)
@ -659,8 +657,8 @@ def log_unknown_etud():
def get_etud_info(etudid=False, code_nip=False, filled=False) -> list: def get_etud_info(etudid=False, code_nip=False, filled=False) -> list:
"""infos sur un etudiant (API). If not foud, returns empty list. """infos sur un etudiant (API). If not foud, returns empty list.
On peut specifier etudid ou code_nip On peut specifier etudid ou code_nip
ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine ou bien cherche dans les argumenst de la requête courante:
(dans cet ordre). etudid, code_nip, code_ine (dans cet ordre).
""" """
if etudid is None: if etudid is None:
return [] return []
@ -673,7 +671,7 @@ def get_etud_info(etudid=False, code_nip=False, filled=False) -> list:
return etud return etud
def create_etud(cnx, args={}, REQUEST=None): def create_etud(cnx, args={}):
"""Creation d'un étudiant. génère aussi évenement et "news". """Creation d'un étudiant. génère aussi évenement et "news".
Args: Args:
@ -685,7 +683,7 @@ def create_etud(cnx, args={}, REQUEST=None):
from app.scodoc import sco_news from app.scodoc import sco_news
# creation d'un etudiant # creation d'un etudiant
etudid = etudident_create(cnx, args, REQUEST=REQUEST) etudid = etudident_create(cnx, args)
# crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !) # crée une adresse vide (chaque etudiant doit etre dans la table "adresse" !)
_ = adresse_create( _ = adresse_create(
cnx, cnx,

View File

@ -250,7 +250,6 @@ def do_evaluation_create(
publish_incomplete=None, publish_incomplete=None,
evaluation_type=None, evaluation_type=None,
numero=None, numero=None,
REQUEST=None,
**kw, # ceci pour absorber les arguments excedentaires de tf #sco8 **kw, # ceci pour absorber les arguments excedentaires de tf #sco8
): ):
"""Create an evaluation""" """Create an evaluation"""
@ -713,7 +712,7 @@ def do_evaluation_etat_in_mod(nt, moduleimpl_id):
return etat return etat
def formsemestre_evaluations_cal(formsemestre_id, REQUEST=None): def formsemestre_evaluations_cal(formsemestre_id):
"""Page avec calendrier de toutes les evaluations de ce semestre""" """Page avec calendrier de toutes les evaluations de ce semestre"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations
@ -843,9 +842,7 @@ def evaluation_date_first_completion(evaluation_id):
return max(date_premiere_note.values()) return max(date_premiere_note.values())
def formsemestre_evaluations_delai_correction( def formsemestre_evaluations_delai_correction(formsemestre_id, format="html"):
formsemestre_id, format="html", REQUEST=None
):
"""Experimental: un tableau indiquant pour chaque évaluation """Experimental: un tableau indiquant pour chaque évaluation
le nombre de jours avant la publication des notes. le nombre de jours avant la publication des notes.
@ -1109,7 +1106,6 @@ def evaluation_describe(evaluation_id="", edit_in_place=True):
def evaluation_create_form( def evaluation_create_form(
moduleimpl_id=None, moduleimpl_id=None,
evaluation_id=None, evaluation_id=None,
REQUEST=None,
edit=False, edit=False,
readonly=False, readonly=False,
page_title="Evaluation", page_title="Evaluation",
@ -1231,11 +1227,9 @@ def evaluation_create_form(
initvalues["visibulletinlist"] = ["X"] initvalues["visibulletinlist"] = ["X"]
else: else:
initvalues["visibulletinlist"] = [] initvalues["visibulletinlist"] = []
if ( vals = request.form if request.method == "POST" else request.args
REQUEST.form.get("tf_submitted", False) if vals.get("tf_submitted", False) and "visibulletinlist" not in vals:
and "visibulletinlist" not in REQUEST.form request.form["visibulletinlist"] = []
):
REQUEST.form["visibulletinlist"] = []
# #
form = [ form = [
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),
@ -1346,7 +1340,7 @@ def evaluation_create_form(
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, vals,
form, form,
cancelbutton="Annuler", cancelbutton="Annuler",
submitlabel=submitlabel, submitlabel=submitlabel,
@ -1368,7 +1362,7 @@ def evaluation_create_form(
tf[2]["visibulletin"] = False tf[2]["visibulletin"] = False
if not edit: if not edit:
# creation d'une evaluation # creation d'une evaluation
evaluation_id = do_evaluation_create(REQUEST=REQUEST, **tf[2]) evaluation_id = do_evaluation_create(**tf[2])
return flask.redirect(dest_url) return flask.redirect(dest_url)
else: else:
do_evaluation_edit(tf[2]) do_evaluation_edit(tf[2])

View File

@ -216,9 +216,7 @@ def get_set_formsemestre_id_dates(start_date, end_date):
return {x["id"] for x in s} return {x["id"] for x in s}
def scodoc_table_results( def scodoc_table_results(start_date="", end_date="", types_parcours=[], format="html"):
start_date="", end_date="", types_parcours=[], format="html", REQUEST=None
):
"""Page affichant la table des résultats """Page affichant la table des résultats
Les dates sont en dd/mm/yyyy (datepicker javascript) Les dates sont en dd/mm/yyyy (datepicker javascript)
types_parcours est la liste des types de parcours à afficher types_parcours est la liste des types de parcours à afficher

View File

@ -362,7 +362,7 @@ def table_etud_in_accessible_depts(expnom=None):
) )
def search_inscr_etud_by_nip(code_nip, REQUEST=None, format="json"): def search_inscr_etud_by_nip(code_nip, format="json"):
"""Recherche multi-departement d'un étudiant par son code NIP """Recherche multi-departement d'un étudiant par son code NIP
Seuls les départements accessibles par l'utilisateur sont cherchés. Seuls les départements accessibles par l'utilisateur sont cherchés.

View File

@ -77,7 +77,7 @@ def formsemestre_custommenu_html(formsemestre_id):
return htmlutils.make_menu("Liens", menu) return htmlutils.make_menu("Liens", menu)
def formsemestre_custommenu_edit(formsemestre_id, REQUEST=None): def formsemestre_custommenu_edit(formsemestre_id):
"""Dialog to edit the custom menu""" """Dialog to edit the custom menu"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dest_url = ( dest_url = (
@ -118,7 +118,7 @@ def formsemestre_custommenu_edit(formsemestre_id, REQUEST=None):
initvalues["url_" + str(item["custommenu_id"])] = item["url"] initvalues["url_" + str(item["custommenu_id"])] = item["url"]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
initvalues=initvalues, initvalues=initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -66,7 +66,7 @@ def _default_sem_title(F):
return F["titre"] return F["titre"]
def formsemestre_createwithmodules(REQUEST=None): def formsemestre_createwithmodules():
"""Page création d'un semestre""" """Page création d'un semestre"""
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
@ -77,7 +77,7 @@ def formsemestre_createwithmodules(REQUEST=None):
), ),
"""<h2>Mise en place d'un semestre de formation</h2>""", """<h2>Mise en place d'un semestre de formation</h2>""",
] ]
r = do_formsemestre_createwithmodules(REQUEST=REQUEST) r = do_formsemestre_createwithmodules()
if isinstance(r, str): if isinstance(r, str):
H.append(r) H.append(r)
else: else:
@ -85,7 +85,7 @@ def formsemestre_createwithmodules(REQUEST=None):
return "\n".join(H) + html_sco_header.sco_footer() return "\n".join(H) + html_sco_header.sco_footer()
def formsemestre_editwithmodules(REQUEST, formsemestre_id): def formsemestre_editwithmodules(formsemestre_id):
"""Page modification semestre""" """Page modification semestre"""
# portage from dtml # portage from dtml
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
@ -104,12 +104,13 @@ def formsemestre_editwithmodules(REQUEST, formsemestre_id):
% scu.icontag("lock_img", border="0", title="Semestre verrouillé") % scu.icontag("lock_img", border="0", title="Semestre verrouillé")
) )
else: else:
r = do_formsemestre_createwithmodules(REQUEST=REQUEST, edit=1) r = do_formsemestre_createwithmodules(edit=1)
if isinstance(r, str): if isinstance(r, str):
H.append(r) H.append(r)
else: else:
return r # response redirect return r # response redirect
if not REQUEST.form.get("tf_submitted", False): vals = request.form if request.method == "POST" else request.args
if not vals.get("tf_submitted", False):
H.append( H.append(
"""<p class="help">Seuls les modules cochés font partie de ce semestre. Pour les retirer, les décocher et appuyer sur le bouton "modifier". """<p class="help">Seuls les modules cochés font partie de ce semestre. Pour les retirer, les décocher et appuyer sur le bouton "modifier".
</p> </p>
@ -120,7 +121,7 @@ def formsemestre_editwithmodules(REQUEST, formsemestre_id):
return "\n".join(H) + html_sco_header.sco_footer() return "\n".join(H) + html_sco_header.sco_footer()
def can_edit_sem(REQUEST, formsemestre_id="", sem=None): def can_edit_sem(formsemestre_id="", sem=None):
"""Return sem if user can edit it, False otherwise""" """Return sem if user can edit it, False otherwise"""
sem = sem or sco_formsemestre.get_formsemestre(formsemestre_id) sem = sem or sco_formsemestre.get_formsemestre(formsemestre_id)
if not current_user.has_permission(Permission.ScoImplement): # pas chef if not current_user.has_permission(Permission.ScoImplement): # pas chef
@ -129,11 +130,12 @@ def can_edit_sem(REQUEST, formsemestre_id="", sem=None):
return sem return sem
def do_formsemestre_createwithmodules(REQUEST=None, edit=False): def do_formsemestre_createwithmodules(edit=False):
"Form choix modules / responsables et creation formsemestre" "Form choix modules / responsables et creation formsemestre"
# Fonction accessible à tous, controle acces à la main: # Fonction accessible à tous, controle acces à la main:
vals = request.form if request.method == "POST" else request.args
if edit: if edit:
formsemestre_id = int(REQUEST.form["formsemestre_id"]) formsemestre_id = int(vals["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not current_user.has_permission(Permission.ScoImplement): if not current_user.has_permission(Permission.ScoImplement):
if not edit: if not edit:
@ -155,14 +157,14 @@ def do_formsemestre_createwithmodules(REQUEST=None, edit=False):
uid2display[u.id] = u.get_nomplogin() uid2display[u.id] = u.get_nomplogin()
allowed_user_names = list(uid2display.values()) + [""] allowed_user_names = list(uid2display.values()) + [""]
# #
formation_id = int(REQUEST.form["formation_id"]) formation_id = int(vals["formation_id"])
F = sco_formations.formation_list(args={"formation_id": formation_id}) F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F: if not F:
raise ScoValueError("Formation inexistante !") raise ScoValueError("Formation inexistante !")
F = F[0] F = F[0]
if not edit: if not edit:
initvalues = {"titre": _default_sem_title(F)} initvalues = {"titre": _default_sem_title(F)}
semestre_id = int(REQUEST.form["semestre_id"]) semestre_id = int(vals["semestre_id"])
sem_module_ids = set() sem_module_ids = set()
else: else:
# setup form init values # setup form init values
@ -308,7 +310,9 @@ def do_formsemestre_createwithmodules(REQUEST=None, edit=False):
{ {
"size": 40, "size": 40,
"title": "Nom de ce semestre", "title": "Nom de ce semestre",
"explanation": """n'indiquez pas les dates, ni le semestre, ni la modalité dans le titre: ils seront automatiquement ajoutés <input type="button" value="remettre titre par défaut" onClick="document.tf.titre.value='%s';"/>""" "explanation": """n'indiquez pas les dates, ni le semestre, ni la modalité dans
le titre: ils seront automatiquement ajoutés <input type="button"
value="remettre titre par défaut" onClick="document.tf.titre.value='%s';"/>"""
% _default_sem_title(F), % _default_sem_title(F),
}, },
), ),
@ -541,7 +545,7 @@ def do_formsemestre_createwithmodules(REQUEST=None, edit=False):
select_name = "%s!group_id" % mod["module_id"] select_name = "%s!group_id" % mod["module_id"]
def opt_selected(gid): def opt_selected(gid):
if gid == REQUEST.form.get(select_name): if gid == vals.get(select_name):
return "selected" return "selected"
else: else:
return "" return ""
@ -630,38 +634,29 @@ def do_formsemestre_createwithmodules(REQUEST=None, edit=False):
initvalues["gestion_compensation_lst"] = ["X"] initvalues["gestion_compensation_lst"] = ["X"]
else: else:
initvalues["gestion_compensation_lst"] = [] initvalues["gestion_compensation_lst"] = []
if ( if vals.get("tf_submitted", False) and "gestion_compensation_lst" not in vals:
REQUEST.form.get("tf_submitted", False) vals["gestion_compensation_lst"] = []
and "gestion_compensation_lst" not in REQUEST.form
):
REQUEST.form["gestion_compensation_lst"] = []
initvalues["gestion_semestrielle"] = initvalues.get("gestion_semestrielle", False) initvalues["gestion_semestrielle"] = initvalues.get("gestion_semestrielle", False)
if initvalues["gestion_semestrielle"]: if initvalues["gestion_semestrielle"]:
initvalues["gestion_semestrielle_lst"] = ["X"] initvalues["gestion_semestrielle_lst"] = ["X"]
else: else:
initvalues["gestion_semestrielle_lst"] = [] initvalues["gestion_semestrielle_lst"] = []
if ( if vals.get("tf_submitted", False) and "gestion_semestrielle_lst" not in vals:
REQUEST.form.get("tf_submitted", False) vals["gestion_semestrielle_lst"] = []
and "gestion_semestrielle_lst" not in REQUEST.form
):
REQUEST.form["gestion_semestrielle_lst"] = []
initvalues["bul_hide_xml"] = initvalues.get("bul_hide_xml", False) initvalues["bul_hide_xml"] = initvalues.get("bul_hide_xml", False)
if not initvalues["bul_hide_xml"]: if not initvalues["bul_hide_xml"]:
initvalues["bul_publish_xml_lst"] = ["X"] initvalues["bul_publish_xml_lst"] = ["X"]
else: else:
initvalues["bul_publish_xml_lst"] = [] initvalues["bul_publish_xml_lst"] = []
if ( if vals.get("tf_submitted", False) and "bul_publish_xml_lst" not in vals:
REQUEST.form.get("tf_submitted", False) vals["bul_publish_xml_lst"] = []
and "bul_publish_xml_lst" not in REQUEST.form
):
REQUEST.form["bul_publish_xml_lst"] = []
# #
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, vals,
modform, modform,
submitlabel=submitlabel, submitlabel=submitlabel,
cancelbutton="Annuler", cancelbutton="Annuler",
@ -792,7 +787,6 @@ def do_formsemestre_createwithmodules(REQUEST=None, edit=False):
moduleimpl_id, moduleimpl_id,
formsemestre_id, formsemestre_id,
etudids, etudids,
REQUEST=REQUEST,
) )
msg += [ msg += [
"inscription de %d étudiants au module %s" "inscription de %d étudiants au module %s"
@ -873,7 +867,7 @@ def formsemestre_delete_moduleimpls(formsemestre_id, module_ids_to_del):
return ok, msg return ok, msg
def formsemestre_clone(formsemestre_id, REQUEST=None): def formsemestre_clone(formsemestre_id):
""" """
Formulaire clonage d'un semestre Formulaire clonage d'un semestre
""" """
@ -965,7 +959,7 @@ def formsemestre_clone(formsemestre_id, REQUEST=None):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
submitlabel="Dupliquer ce semestre", submitlabel="Dupliquer ce semestre",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -990,7 +984,6 @@ def formsemestre_clone(formsemestre_id, REQUEST=None):
tf[2]["date_fin"], tf[2]["date_fin"],
clone_evaluations=tf[2]["clone_evaluations"], clone_evaluations=tf[2]["clone_evaluations"],
clone_partitions=tf[2]["clone_partitions"], clone_partitions=tf[2]["clone_partitions"],
REQUEST=REQUEST,
) )
return flask.redirect( return flask.redirect(
"formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé" "formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé"
@ -1005,7 +998,6 @@ def do_formsemestre_clone(
date_fin, # 'dd/mm/yyyy' date_fin, # 'dd/mm/yyyy'
clone_evaluations=False, clone_evaluations=False,
clone_partitions=False, clone_partitions=False,
REQUEST=None,
): ):
"""Clone a semestre: make copy, same modules, same options, same resps, same partitions. """Clone a semestre: make copy, same modules, same options, same resps, same partitions.
New dates, responsable_id New dates, responsable_id
@ -1045,7 +1037,7 @@ def do_formsemestre_clone(
args = e.copy() args = e.copy()
del args["jour"] # erase date del args["jour"] # erase date
args["moduleimpl_id"] = mid args["moduleimpl_id"] = mid
_ = sco_evaluations.do_evaluation_create(REQUEST=REQUEST, **args) _ = sco_evaluations.do_evaluation_create(**args)
# 3- copy uecoefs # 3- copy uecoefs
objs = sco_formsemestre.formsemestre_uecoef_list( objs = sco_formsemestre.formsemestre_uecoef_list(
@ -1240,7 +1232,7 @@ def _reassociate_moduleimpls(cnx, formsemestre_id, ues_old2new, modules_old2new)
sco_parcours_dut.scolar_formsemestre_validation_edit(cnx, e) sco_parcours_dut.scolar_formsemestre_validation_edit(cnx, e)
def formsemestre_delete(formsemestre_id, REQUEST=None): def formsemestre_delete(formsemestre_id):
"""Delete a formsemestre (affiche avertissements)""" """Delete a formsemestre (affiche avertissements)"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
@ -1272,7 +1264,7 @@ def formsemestre_delete(formsemestre_id, REQUEST=None):
submit_label = "Confirmer la suppression du semestre" submit_label = "Confirmer la suppression du semestre"
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("formsemestre_id", {"input_type": "hidden"}),), (("formsemestre_id", {"input_type": "hidden"}),),
initvalues=F, initvalues=F,
submitlabel=submit_label, submitlabel=submit_label,
@ -1431,7 +1423,7 @@ def do_formsemestre_delete(formsemestre_id):
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
def formsemestre_edit_options(formsemestre_id, REQUEST=None): def formsemestre_edit_options(formsemestre_id):
"""dialog to change formsemestre options """dialog to change formsemestre options
(accessible par ScoImplement ou dir. etudes) (accessible par ScoImplement ou dir. etudes)
""" """
@ -1439,12 +1431,10 @@ def formsemestre_edit_options(formsemestre_id, REQUEST=None):
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id) ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
if not ok: if not ok:
return err return err
return sco_preferences.SemPreferences(formsemestre_id).edit( return sco_preferences.SemPreferences(formsemestre_id).edit(categories=["bul"])
REQUEST=REQUEST, categories=["bul"]
)
def formsemestre_change_lock(formsemestre_id, REQUEST=None, dialog_confirmed=False): def formsemestre_change_lock(formsemestre_id, dialog_confirmed=False) -> None:
"""Change etat (verrouille si ouvert, déverrouille si fermé) """Change etat (verrouille si ouvert, déverrouille si fermé)
nota: etat (1 ouvert, 0 fermé) nota: etat (1 ouvert, 0 fermé)
""" """
@ -1454,7 +1444,7 @@ def formsemestre_change_lock(formsemestre_id, REQUEST=None, dialog_confirmed=Fal
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etat = not sem["etat"] etat = not sem["etat"]
if REQUEST and not dialog_confirmed: if not dialog_confirmed:
if etat: if etat:
msg = "déverrouillage" msg = "déverrouillage"
else: else:
@ -1474,14 +1464,10 @@ def formsemestre_change_lock(formsemestre_id, REQUEST=None, dialog_confirmed=Fal
args = {"formsemestre_id": formsemestre_id, "etat": etat} args = {"formsemestre_id": formsemestre_id, "etat": etat}
sco_formsemestre.do_formsemestre_edit(args) sco_formsemestre.do_formsemestre_edit(args)
if REQUEST:
return flask.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
)
def formsemestre_change_publication_bul( def formsemestre_change_publication_bul(
formsemestre_id, REQUEST=None, dialog_confirmed=False formsemestre_id, dialog_confirmed=False, redirect=True
): ):
"""Change etat publication bulletins sur portail""" """Change etat publication bulletins sur portail"""
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id) ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
@ -1490,7 +1476,7 @@ def formsemestre_change_publication_bul(
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etat = not sem["bul_hide_xml"] etat = not sem["bul_hide_xml"]
if REQUEST and not dialog_confirmed: if not dialog_confirmed:
if etat: if etat:
msg = "non" msg = "non"
else: else:
@ -1509,14 +1495,14 @@ def formsemestre_change_publication_bul(
args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat} args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat}
sco_formsemestre.do_formsemestre_edit(args) sco_formsemestre.do_formsemestre_edit(args)
if REQUEST: if redirect:
return flask.redirect( return flask.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id "formsemestre_status?formsemestre_id=%s" % formsemestre_id
) )
return None return None
def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None, REQUEST=None): def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None):
"""Changement manuel des coefficients des UE capitalisées.""" """Changement manuel des coefficients des UE capitalisées."""
from app.scodoc import notes_table from app.scodoc import notes_table
@ -1585,7 +1571,7 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
submitlabel="Changer les coefficients", submitlabel="Changer les coefficients",
cancelbutton="Annuler", cancelbutton="Annuler",

View File

@ -52,7 +52,7 @@ from app.scodoc import sco_parcours_dut
from app.scodoc import sco_etud from app.scodoc import sco_etud
def formsemestre_ext_create(etudid, sem_params, REQUEST=None): def formsemestre_ext_create(etudid, sem_params):
"""Crée un formsemestre exterieur et y inscrit l'étudiant. """Crée un formsemestre exterieur et y inscrit l'étudiant.
sem_params: dict nécessaire à la création du formsemestre sem_params: dict nécessaire à la création du formsemestre
""" """
@ -79,7 +79,7 @@ def formsemestre_ext_create(etudid, sem_params, REQUEST=None):
return formsemestre_id return formsemestre_id
def formsemestre_ext_create_form(etudid, formsemestre_id, REQUEST=None): def formsemestre_ext_create_form(etudid, formsemestre_id):
"""Formulaire creation/inscription à un semestre extérieur""" """Formulaire creation/inscription à un semestre extérieur"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
H = [ H = [
@ -182,7 +182,7 @@ def formsemestre_ext_create_form(etudid, formsemestre_id, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="post", method="post",
@ -204,13 +204,13 @@ def formsemestre_ext_create_form(etudid, formsemestre_id, REQUEST=None):
) )
else: else:
tf[2]["formation_id"] = orig_sem["formation_id"] tf[2]["formation_id"] = orig_sem["formation_id"]
formsemestre_ext_create(etudid, tf[2], REQUEST=REQUEST) formsemestre_ext_create(etudid, tf[2])
return flask.redirect( return flask.redirect(
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
) )
def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid, REQUEST=None): def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid):
"""Edition des validations d'UE et de semestre (jury) """Edition des validations d'UE et de semestre (jury)
pour un semestre extérieur. pour un semestre extérieur.
On peut saisir pour chaque UE du programme de formation On peut saisir pour chaque UE du programme de formation
@ -222,8 +222,10 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid, REQUEST=None):
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
ue_list = _list_ue_with_coef_and_validations(sem, etudid) ue_list = _list_ue_with_coef_and_validations(sem, etudid)
descr = _ue_form_description(ue_list, REQUEST.form) descr = _ue_form_description(
if REQUEST and REQUEST.method == "GET": ue_list, request.form if request.method == "POST" else request.args
)
if request.method == "GET":
initvalues = { initvalues = {
"note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "") "note_" + str(ue["ue_id"]): ue["validation"].get("moy_ue", "")
for ue in ue_list for ue in ue_list
@ -232,7 +234,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid, REQUEST=None):
initvalues = {} initvalues = {}
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cssclass="tf_ext_edit_ue_validations", cssclass="tf_ext_edit_ue_validations",
submitlabel="Enregistrer ces validations", submitlabel="Enregistrer ces validations",
@ -242,19 +244,19 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid, REQUEST=None):
if tf[0] == -1: if tf[0] == -1:
return "<h4>annulation</h4>" return "<h4>annulation</h4>"
else: else:
H = _make_page(etud, sem, tf, REQUEST=REQUEST) H = _make_page(etud, sem, tf)
if tf[0] == 0: # premier affichage if tf[0] == 0: # premier affichage
return "\n".join(H) return "\n".join(H)
else: # soumission else: # soumission
# simule erreur # simule erreur
ok, message = _check_values(ue_list, tf[2]) ok, message = _check_values(ue_list, tf[2])
if not ok: if not ok:
H = _make_page(etud, sem, tf, message=message, REQUEST=REQUEST) H = _make_page(etud, sem, tf, message=message)
return "\n".join(H) return "\n".join(H)
else: else:
# Submit # Submit
_record_ue_validations_and_coefs( _record_ue_validations_and_coefs(
formsemestre_id, etudid, ue_list, tf[2], REQUEST=REQUEST formsemestre_id, etudid, ue_list, tf[2]
) )
return flask.redirect( return flask.redirect(
"formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s" "formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s"
@ -262,7 +264,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid, REQUEST=None):
) )
def _make_page(etud, sem, tf, message="", REQUEST=None): def _make_page(etud, sem, tf, message=""):
nt = sco_cache.NotesTableCache.get(sem["formsemestre_id"]) nt = sco_cache.NotesTableCache.get(sem["formsemestre_id"])
moy_gen = nt.get_etud_moy_gen(etud["etudid"]) moy_gen = nt.get_etud_moy_gen(etud["etudid"])
H = [ H = [
@ -465,9 +467,7 @@ def _list_ue_with_coef_and_validations(sem, etudid):
return ue_list return ue_list
def _record_ue_validations_and_coefs( def _record_ue_validations_and_coefs(formsemestre_id, etudid, ue_list, values):
formsemestre_id, etudid, ue_list, values, REQUEST=None
):
for ue in ue_list: for ue in ue_list:
code = values.get("valid_" + str(ue["ue_id"]), False) code = values.get("valid_" + str(ue["ue_id"]), False)
if code == "None": if code == "None":
@ -492,5 +492,4 @@ def _record_ue_validations_and_coefs(
now_dmy, now_dmy,
code=code, code=code,
ue_coefficient=coef, ue_coefficient=coef,
REQUEST=REQUEST,
) )

View File

@ -248,7 +248,7 @@ def do_formsemestre_inscription_with_modules(
def formsemestre_inscription_with_modules_etud( def formsemestre_inscription_with_modules_etud(
formsemestre_id, etudid=None, group_ids=None, REQUEST=None formsemestre_id, etudid=None, group_ids=None
): ):
"""Form. inscription d'un étudiant au semestre. """Form. inscription d'un étudiant au semestre.
Si etudid n'est pas specifié, form. choix etudiant. Si etudid n'est pas specifié, form. choix etudiant.
@ -263,7 +263,7 @@ def formsemestre_inscription_with_modules_etud(
) )
return formsemestre_inscription_with_modules( return formsemestre_inscription_with_modules(
etudid, formsemestre_id, REQUEST=REQUEST, group_ids=group_ids etudid, formsemestre_id, group_ids=group_ids
) )
@ -318,7 +318,7 @@ def formsemestre_inscription_with_modules_form(etudid, only_ext=False):
def formsemestre_inscription_with_modules( def formsemestre_inscription_with_modules(
etudid, formsemestre_id, group_ids=None, multiple_ok=False, REQUEST=None etudid, formsemestre_id, group_ids=None, multiple_ok=False
): ):
""" """
Inscription de l'etud dans ce semestre. Inscription de l'etud dans ce semestre.
@ -430,7 +430,7 @@ def formsemestre_inscription_with_modules(
return "\n".join(H) + F return "\n".join(H) + F
def formsemestre_inscription_option(etudid, formsemestre_id, REQUEST=None): def formsemestre_inscription_option(etudid, formsemestre_id):
"""Dialogue pour (dés)inscription à des modules optionnels.""" """Dialogue pour (dés)inscription à des modules optionnels."""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]: if not sem["etat"]:
@ -467,7 +467,8 @@ def formsemestre_inscription_option(etudid, formsemestre_id, REQUEST=None):
modimpls_by_ue_names[ue_id].append( modimpls_by_ue_names[ue_id].append(
"%s %s" % (mod["module"]["code"], mod["module"]["titre"]) "%s %s" % (mod["module"]["code"], mod["module"]["titre"])
) )
if not REQUEST.form.get("tf_submitted", False): vals = request.form if request.method == "POST" else request.args
if not vals.get("tf_submitted", False):
# inscrit ? # inscrit ?
for ins in inscr: for ins in inscr:
if ins["moduleimpl_id"] == mod["moduleimpl_id"]: if ins["moduleimpl_id"] == mod["moduleimpl_id"]:
@ -533,7 +534,7 @@ function chkbx_select(field_id, state) {
) )
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
initvalues, initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",
@ -658,7 +659,7 @@ function chkbx_select(field_id, state) {
def do_moduleimpl_incription_options( def do_moduleimpl_incription_options(
etudid, modulesimpls_ainscrire, modulesimpls_adesinscrire, REQUEST=None etudid, modulesimpls_ainscrire, modulesimpls_adesinscrire
): ):
""" """
Effectue l'inscription et la description aux modules optionnels Effectue l'inscription et la description aux modules optionnels
@ -710,7 +711,6 @@ def do_moduleimpl_incription_options(
oid, formsemestre_id=mod["formsemestre_id"] oid, formsemestre_id=mod["formsemestre_id"]
) )
if REQUEST:
H = [ H = [
html_sco_header.sco_header(), html_sco_header.sco_header(),
"""<h3>Modifications effectuées</h3> """<h3>Modifications effectuées</h3>
@ -755,7 +755,7 @@ def list_inscrits_ailleurs(formsemestre_id):
return d return d
def formsemestre_inscrits_ailleurs(formsemestre_id, REQUEST=None): def formsemestre_inscrits_ailleurs(formsemestre_id):
"""Page listant les étudiants inscrits dans un autre semestre """Page listant les étudiants inscrits dans un autre semestre
dont les dates recouvrent le semestre indiqué. dont les dates recouvrent le semestre indiqué.
""" """

View File

@ -488,7 +488,7 @@ def retreive_formsemestre_from_request() -> int:
# Element HTML decrivant un semestre (barre de menu et infos) # Element HTML decrivant un semestre (barre de menu et infos)
def formsemestre_page_title(): def formsemestre_page_title():
"""Element HTML decrivant un semestre (barre de menu et infos) """Element HTML decrivant un semestre (barre de menu et infos)
Cherche dans REQUEST si un semestre est défini (formsemestre_id ou moduleimpl ou evaluation ou group) Cherche dans la requete si un semestre est défini (formsemestre_id ou moduleimpl ou evaluation ou group)
""" """
formsemestre_id = retreive_formsemestre_from_request() formsemestre_id = retreive_formsemestre_from_request()
# #
@ -568,7 +568,7 @@ def fill_formsemestre(sem):
# Description du semestre sous forme de table exportable # Description du semestre sous forme de table exportable
def formsemestre_description_table(formsemestre_id, REQUEST=None, with_evals=False): def formsemestre_description_table(formsemestre_id, with_evals=False):
"""Description du semestre sous forme de table exportable """Description du semestre sous forme de table exportable
Liste des modules et de leurs coefficients Liste des modules et de leurs coefficients
""" """
@ -610,7 +610,7 @@ def formsemestre_description_table(formsemestre_id, REQUEST=None, with_evals=Fal
moduleimpl_id=M["moduleimpl_id"] moduleimpl_id=M["moduleimpl_id"]
) )
enseignants = ", ".join( enseignants = ", ".join(
[sco_users.user_info(m["ens_id"], REQUEST)["nomprenom"] for m in M["ens"]] [sco_users.user_info(m["ens_id"])["nomprenom"] for m in M["ens"]]
) )
l = { l = {
"UE": M["ue"]["acronyme"], "UE": M["ue"]["acronyme"],
@ -708,16 +708,12 @@ def formsemestre_description_table(formsemestre_id, REQUEST=None, with_evals=Fal
) )
def formsemestre_description( def formsemestre_description(formsemestre_id, format="html", with_evals=False):
formsemestre_id, format="html", with_evals=False, REQUEST=None
):
"""Description du semestre sous forme de table exportable """Description du semestre sous forme de table exportable
Liste des modules et de leurs coefficients Liste des modules et de leurs coefficients
""" """
with_evals = int(with_evals) with_evals = int(with_evals)
tab = formsemestre_description_table( tab = formsemestre_description_table(formsemestre_id, with_evals=with_evals)
formsemestre_id, REQUEST, with_evals=with_evals
)
tab.html_before_table = """<form name="f" method="get" action="%s"> tab.html_before_table = """<form name="f" method="get" action="%s">
<input type="hidden" name="formsemestre_id" value="%s"></input> <input type="hidden" name="formsemestre_id" value="%s"></input>
<input type="checkbox" name="with_evals" value="1" onchange="document.f.submit()" """ % ( <input type="checkbox" name="with_evals" value="1" onchange="document.f.submit()" """ % (
@ -732,7 +728,7 @@ def formsemestre_description(
# genere liste html pour accès aux groupes de ce semestre # genere liste html pour accès aux groupes de ce semestre
def _make_listes_sem(sem, REQUEST=None, with_absences=True): def _make_listes_sem(sem, with_absences=True):
# construit l'URL "destination" # construit l'URL "destination"
# (a laquelle on revient apres saisie absences) # (a laquelle on revient apres saisie absences)
destination = url_for( destination = url_for(
@ -897,7 +893,7 @@ def html_expr_diagnostic(diagnostics):
return "".join(H) return "".join(H)
def formsemestre_status_head(formsemestre_id=None, REQUEST=None, page_title=None): def formsemestre_status_head(formsemestre_id=None, page_title=None):
"""En-tête HTML des pages "semestre" """ """En-tête HTML des pages "semestre" """
semlist = sco_formsemestre.do_formsemestre_list( semlist = sco_formsemestre.do_formsemestre_list(
args={"formsemestre_id": formsemestre_id} args={"formsemestre_id": formsemestre_id}
@ -965,7 +961,7 @@ Il y a des notes en attente ! Le classement des étudiants n'a qu'une valeur ind
return "".join(H) return "".join(H)
def formsemestre_status(formsemestre_id=None, REQUEST=None): def formsemestre_status(formsemestre_id=None):
"""Tableau de bord semestre HTML""" """Tableau de bord semestre HTML"""
# porté du DTML # porté du DTML
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -978,7 +974,7 @@ def formsemestre_status(formsemestre_id=None, REQUEST=None):
# ) # )
prev_ue_id = None prev_ue_id = None
can_edit = sco_formsemestre_edit.can_edit_sem(REQUEST, formsemestre_id, sem=sem) can_edit = sco_formsemestre_edit.can_edit_sem(formsemestre_id, sem=sem)
H = [ H = [
html_sco_header.sco_header(page_title="Semestre %s" % sem["titreannee"]), html_sco_header.sco_header(page_title="Semestre %s" % sem["titreannee"]),
@ -1021,11 +1017,9 @@ def formsemestre_status(formsemestre_id=None, REQUEST=None):
ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list( ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
moduleimpl_id=M["moduleimpl_id"] moduleimpl_id=M["moduleimpl_id"]
) )
mails_enseignants.add( mails_enseignants.add(sco_users.user_info(M["responsable_id"])["email"])
sco_users.user_info(M["responsable_id"], REQUEST)["email"]
)
mails_enseignants |= set( mails_enseignants |= set(
[sco_users.user_info(m["ens_id"], REQUEST)["email"] for m in M["ens"]] [sco_users.user_info(m["ens_id"])["email"] for m in M["ens"]]
) )
ue = M["ue"] ue = M["ue"]
if prev_ue_id != ue["ue_id"]: if prev_ue_id != ue["ue_id"]:
@ -1150,7 +1144,7 @@ def formsemestre_status(formsemestre_id=None, REQUEST=None):
# --- LISTE DES ETUDIANTS # --- LISTE DES ETUDIANTS
H += [ H += [
'<div id="groupes">', '<div id="groupes">',
_make_listes_sem(sem, REQUEST), _make_listes_sem(sem),
"</div>", "</div>",
] ]
# --- Lien mail enseignants: # --- Lien mail enseignants:

View File

@ -64,7 +64,6 @@ def formsemestre_validation_etud_form(
desturl=None, desturl=None,
sortcol=None, sortcol=None,
readonly=True, readonly=True,
REQUEST=None,
): ):
nt = sco_cache.NotesTableCache.get( nt = sco_cache.NotesTableCache.get(
formsemestre_id formsemestre_id
@ -336,7 +335,6 @@ def formsemestre_validation_etud(
codechoice=None, # required codechoice=None, # required
desturl="", desturl="",
sortcol=None, sortcol=None,
REQUEST=None,
): ):
"""Enregistre validation""" """Enregistre validation"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
@ -352,7 +350,7 @@ def formsemestre_validation_etud(
if not selected_choice: if not selected_choice:
raise ValueError("code choix invalide ! (%s)" % codechoice) raise ValueError("code choix invalide ! (%s)" % codechoice)
# #
Se.valide_decision(selected_choice, REQUEST) # enregistre Se.valide_decision(selected_choice) # enregistre
return _redirect_valid_choice( return _redirect_valid_choice(
formsemestre_id, etudid, Se, selected_choice, desturl, sortcol formsemestre_id, etudid, Se, selected_choice, desturl, sortcol
) )
@ -367,7 +365,6 @@ def formsemestre_validation_etud_manu(
assidu=False, assidu=False,
desturl="", desturl="",
sortcol=None, sortcol=None,
REQUEST=None,
redirect=True, redirect=True,
): ):
"""Enregistre validation""" """Enregistre validation"""
@ -397,7 +394,7 @@ def formsemestre_validation_etud_manu(
formsemestre_id_utilise_pour_compenser=formsemestre_id_utilise_pour_compenser, formsemestre_id_utilise_pour_compenser=formsemestre_id_utilise_pour_compenser,
) )
# #
Se.valide_decision(choice, REQUEST) # enregistre Se.valide_decision(choice) # enregistre
if redirect: if redirect:
return _redirect_valid_choice( return _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol formsemestre_id, etudid, Se, choice, desturl, sortcol
@ -817,7 +814,7 @@ def form_decision_manuelle(Se, formsemestre_id, etudid, desturl="", sortcol=None
# ----------- # -----------
def formsemestre_validation_auto(formsemestre_id, REQUEST): def formsemestre_validation_auto(formsemestre_id):
"Formulaire saisie automatisee des decisions d'un semestre" "Formulaire saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [ H = [
@ -847,7 +844,7 @@ def formsemestre_validation_auto(formsemestre_id, REQUEST):
return "\n".join(H) return "\n".join(H)
def do_formsemestre_validation_auto(formsemestre_id, REQUEST): def do_formsemestre_validation_auto(formsemestre_id):
"Saisie automatisee des decisions d'un semestre" "Saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
next_semestre_id = sem["semestre_id"] + 1 next_semestre_id = sem["semestre_id"] + 1
@ -903,7 +900,6 @@ def do_formsemestre_validation_auto(formsemestre_id, REQUEST):
code_etat=ADM, code_etat=ADM,
devenir="NEXT", devenir="NEXT",
assidu=True, assidu=True,
REQUEST=REQUEST,
redirect=False, redirect=False,
) )
nb_valid += 1 nb_valid += 1
@ -968,7 +964,7 @@ def formsemestre_validation_suppress_etud(formsemestre_id, etudid):
) # > suppr. decision jury (peut affecter de plusieurs semestres utilisant UE capitalisée) ) # > suppr. decision jury (peut affecter de plusieurs semestres utilisant UE capitalisée)
def formsemestre_validate_previous_ue(formsemestre_id, etudid, REQUEST=None): def formsemestre_validate_previous_ue(formsemestre_id, etudid):
"""Form. saisie UE validée hors ScoDoc """Form. saisie UE validée hors ScoDoc
(pour étudiants arrivant avec un UE antérieurement validée). (pour étudiants arrivant avec un UE antérieurement validée).
""" """
@ -1012,7 +1008,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid, REQUEST=None):
ue_ids = [""] + [ue["ue_id"] for ue in ues] ue_ids = [""] + [ue["ue_id"] for ue in ues]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
("formsemestre_id", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}),
@ -1085,7 +1081,6 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid, REQUEST=None):
tf[2]["moy_ue"], tf[2]["moy_ue"],
tf[2]["date"], tf[2]["date"],
semestre_id=semestre_id, semestre_id=semestre_id,
REQUEST=REQUEST,
) )
return flask.redirect( return flask.redirect(
scu.ScoURL() scu.ScoURL()
@ -1103,7 +1098,6 @@ def do_formsemestre_validate_previous_ue(
code=ADM, code=ADM,
semestre_id=None, semestre_id=None,
ue_coefficient=None, ue_coefficient=None,
REQUEST=None,
): ):
"""Enregistre (ou modifie) validation d'UE (obtenue hors ScoDoc). """Enregistre (ou modifie) validation d'UE (obtenue hors ScoDoc).
Si le coefficient est spécifié, modifie le coefficient de Si le coefficient est spécifié, modifie le coefficient de
@ -1159,7 +1153,7 @@ def _invalidate_etud_formation_caches(etudid, formation_id):
) # > modif decision UE (inval tous semestres avec cet etudiant, ok mais conservatif) ) # > modif decision UE (inval tous semestres avec cet etudiant, ok mais conservatif)
def get_etud_ue_cap_html(etudid, formsemestre_id, ue_id, REQUEST=None): def get_etud_ue_cap_html(etudid, formsemestre_id, ue_id):
"""Ramene bout de HTML pour pouvoir supprimer une validation de cette UE""" """Ramene bout de HTML pour pouvoir supprimer une validation de cette UE"""
valids = ndb.SimpleDictFetch( valids = ndb.SimpleDictFetch(
"""SELECT SFV.* """SELECT SFV.*
@ -1195,7 +1189,7 @@ def get_etud_ue_cap_html(etudid, formsemestre_id, ue_id, REQUEST=None):
return "\n".join(H) return "\n".join(H)
def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id, REQUEST=None): def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id):
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre""" """Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
log("etud_ue_suppress_validation( %s, %s, %s)" % (etudid, formsemestre_id, ue_id)) log("etud_ue_suppress_validation( %s, %s, %s)" % (etudid, formsemestre_id, ue_id))
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()

View File

@ -43,7 +43,7 @@ from xml.etree.ElementTree import Element
import flask import flask
from flask import g, request from flask import g, request
from flask import url_for from flask import url_for, make_response
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
@ -468,7 +468,7 @@ def get_etud_groups_in_partition(partition_id):
return R return R
def formsemestre_partition_list(formsemestre_id, format="xml", REQUEST=None): def formsemestre_partition_list(formsemestre_id, format="xml"):
"""Get partitions and groups in this semestre """Get partitions and groups in this semestre
Supported formats: xml, json Supported formats: xml, json
""" """
@ -480,7 +480,7 @@ def formsemestre_partition_list(formsemestre_id, format="xml", REQUEST=None):
# Encore utilisé par groupmgr.js # Encore utilisé par groupmgr.js
def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD def XMLgetGroupsInPartition(partition_id): # was XMLgetGroupesTD
""" """
Deprecated: use group_list Deprecated: use group_list
Liste des étudiants dans chaque groupe de cette partition. Liste des étudiants dans chaque groupe de cette partition.
@ -499,8 +499,7 @@ def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD
groups = get_partition_groups(partition) groups = get_partition_groups(partition)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > inscrdict nt = sco_cache.NotesTableCache.get(formsemestre_id) # > inscrdict
etuds_set = set(nt.inscrdict) etuds_set = set(nt.inscrdict)
# XML response: # Build XML:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = Element("ajax-response") doc = Element("ajax-response")
x_response = Element("response", type="object", id="MyUpdater") x_response = Element("response", type="object", id="MyUpdater")
doc.append(x_response) doc.append(x_response)
@ -552,7 +551,11 @@ def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD
) )
) )
log("XMLgetGroupsInPartition: %s seconds" % (time.time() - t0)) log("XMLgetGroupsInPartition: %s seconds" % (time.time() - t0))
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING) # XML response:
data = sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
response = make_response(data)
response.headers["Content-Type"] = scu.XML_MIMETYPE
return response
def comp_origin(etud, cur_sem): def comp_origin(etud, cur_sem):
@ -652,7 +655,6 @@ def setGroups(
groupsLists="", # members of each existing group groupsLists="", # members of each existing group
groupsToCreate="", # name and members of new groups groupsToCreate="", # name and members of new groups
groupsToDelete="", # groups to delete groupsToDelete="", # groups to delete
REQUEST=None,
): ):
"""Affect groups (Ajax request) """Affect groups (Ajax request)
groupsLists: lignes de la forme "group_id;etudid;...\n" groupsLists: lignes de la forme "group_id;etudid;...\n"
@ -716,7 +718,7 @@ def setGroups(
# Supprime les groupes indiqués comme supprimés: # Supprime les groupes indiqués comme supprimés:
for group_id in groupsToDelete: for group_id in groupsToDelete:
suppressGroup(group_id, partition_id=partition_id, REQUEST=REQUEST) suppressGroup(group_id, partition_id=partition_id)
# Crée les nouveaux groupes # Crée les nouveaux groupes
for line in groupsToCreate.split("\n"): # for each group_name (one per line) for line in groupsToCreate.split("\n"): # for each group_name (one per line)
@ -733,10 +735,12 @@ def setGroups(
for etudid in fs[1:-1]: for etudid in fs[1:-1]:
change_etud_group_in_partition(etudid, group_id, partition) change_etud_group_in_partition(etudid, group_id, partition)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE) data = (
return (
'<?xml version="1.0" encoding="utf-8"?><response>Groupes enregistrés</response>' '<?xml version="1.0" encoding="utf-8"?><response>Groupes enregistrés</response>'
) )
response = make_response(data)
response.headers["Content-Type"] = scu.XML_MIMETYPE
return response
def createGroup(partition_id, group_name="", default=False): def createGroup(partition_id, group_name="", default=False):
@ -764,7 +768,7 @@ def createGroup(partition_id, group_name="", default=False):
return group_id return group_id
def suppressGroup(group_id, partition_id=None, REQUEST=None): def suppressGroup(group_id, partition_id=None):
"""form suppression d'un groupe. """form suppression d'un groupe.
(ne desinscrit pas les etudiants, change juste leur (ne desinscrit pas les etudiants, change juste leur
affectation aux groupes) affectation aux groupes)
@ -840,7 +844,7 @@ def getArrowIconsTags():
return arrow_up, arrow_down, arrow_none return arrow_up, arrow_down, arrow_none
def editPartitionForm(formsemestre_id=None, REQUEST=None): def editPartitionForm(formsemestre_id=None):
"""Form to create/suppress partitions""" """Form to create/suppress partitions"""
# ad-hoc form # ad-hoc form
if not sco_permissions_check.can_change_groups(formsemestre_id): if not sco_permissions_check.can_change_groups(formsemestre_id):
@ -968,7 +972,7 @@ def editPartitionForm(formsemestre_id=None, REQUEST=None):
return "\n".join(H) + html_sco_header.sco_footer() return "\n".join(H) + html_sco_header.sco_footer()
def partition_set_attr(partition_id, attr, value, REQUEST=None): def partition_set_attr(partition_id, attr, value):
"""Set partition attribute: bul_show_rank or show_in_lists""" """Set partition attribute: bul_show_rank or show_in_lists"""
if attr not in {"bul_show_rank", "show_in_lists"}: if attr not in {"bul_show_rank", "show_in_lists"}:
raise ValueError("invalid partition attribute: %s" % attr) raise ValueError("invalid partition attribute: %s" % attr)
@ -991,9 +995,7 @@ def partition_set_attr(partition_id, attr, value, REQUEST=None):
return "enregistré" return "enregistré"
def partition_delete( def partition_delete(partition_id, force=False, redirect=1, dialog_confirmed=False):
partition_id, REQUEST=None, force=False, redirect=1, dialog_confirmed=False
):
"""Suppress a partition (and all groups within). """Suppress a partition (and all groups within).
default partition cannot be suppressed (unless force)""" default partition cannot be suppressed (unless force)"""
partition = get_partition(partition_id) partition = get_partition(partition_id)
@ -1036,7 +1038,7 @@ def partition_delete(
) )
def partition_move(partition_id, after=0, REQUEST=None, redirect=1): def partition_move(partition_id, after=0, redirect=1):
"""Move before/after previous one (decrement/increment numero)""" """Move before/after previous one (decrement/increment numero)"""
partition = get_partition(partition_id) partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"] formsemestre_id = partition["formsemestre_id"]
@ -1071,7 +1073,7 @@ def partition_move(partition_id, after=0, REQUEST=None, redirect=1):
) )
def partition_rename(partition_id, REQUEST=None): def partition_rename(partition_id):
"""Form to rename a partition""" """Form to rename a partition"""
partition = get_partition(partition_id) partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"] formsemestre_id = partition["formsemestre_id"]
@ -1080,7 +1082,7 @@ def partition_rename(partition_id, REQUEST=None):
H = ["<h2>Renommer une partition</h2>"] H = ["<h2>Renommer une partition</h2>"]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("partition_id", {"default": partition_id, "input_type": "hidden"}), ("partition_id", {"default": partition_id, "input_type": "hidden"}),
( (
@ -1110,12 +1112,10 @@ def partition_rename(partition_id, REQUEST=None):
) )
else: else:
# form submission # form submission
return partition_set_name( return partition_set_name(partition_id, tf[2]["partition_name"])
partition_id, tf[2]["partition_name"], REQUEST=REQUEST, redirect=1
)
def partition_set_name(partition_id, partition_name, REQUEST=None, redirect=1): def partition_set_name(partition_id, partition_name, redirect=1):
"""Set partition name""" """Set partition name"""
partition_name = partition_name.strip() partition_name = partition_name.strip()
if not partition_name: if not partition_name:
@ -1153,7 +1153,7 @@ def partition_set_name(partition_id, partition_name, REQUEST=None, redirect=1):
) )
def group_set_name(group_id, group_name, REQUEST=None, redirect=1): def group_set_name(group_id, group_name, redirect=1):
"""Set group name""" """Set group name"""
if group_name: if group_name:
group_name = group_name.strip() group_name = group_name.strip()
@ -1180,7 +1180,7 @@ def group_set_name(group_id, group_name, REQUEST=None, redirect=1):
) )
def group_rename(group_id, REQUEST=None): def group_rename(group_id):
"""Form to rename a group""" """Form to rename a group"""
group = get_group(group_id) group = get_group(group_id)
formsemestre_id = group["formsemestre_id"] formsemestre_id = group["formsemestre_id"]
@ -1189,7 +1189,7 @@ def group_rename(group_id, REQUEST=None):
H = ["<h2>Renommer un groupe de %s</h2>" % group["partition_name"]] H = ["<h2>Renommer un groupe de %s</h2>" % group["partition_name"]]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("group_id", {"default": group_id, "input_type": "hidden"}), ("group_id", {"default": group_id, "input_type": "hidden"}),
( (
@ -1223,12 +1223,10 @@ def group_rename(group_id, REQUEST=None):
) )
else: else:
# form submission # form submission
return group_set_name( return group_set_name(group_id, tf[2]["group_name"], redirect=1)
group_id, tf[2]["group_name"], REQUEST=REQUEST, redirect=1
)
def groups_auto_repartition(partition_id=None, REQUEST=None): def groups_auto_repartition(partition_id=None):
"""Reparti les etudiants dans des groupes dans une partition, en respectant le niveau """Reparti les etudiants dans des groupes dans une partition, en respectant le niveau
et la mixité. et la mixité.
""" """
@ -1269,7 +1267,7 @@ def groups_auto_repartition(partition_id=None, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
{}, {},
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1299,7 +1297,7 @@ def groups_auto_repartition(partition_id=None, REQUEST=None):
# checkGroupName(group_name) # checkGroupName(group_name)
# except: # except:
# H.append('<p class="warning">Nom de groupe invalide: %s</p>'%group_name) # H.append('<p class="warning">Nom de groupe invalide: %s</p>'%group_name)
# return '\n'.join(H) + tf[1] + html_sco_header.sco_footer( REQUEST) # return '\n'.join(H) + tf[1] + html_sco_header.sco_footer()
group_ids.append(createGroup(partition_id, group_name)) group_ids.append(createGroup(partition_id, group_name))
# #
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > identdict nt = sco_cache.NotesTableCache.get(formsemestre_id) # > identdict

View File

@ -33,7 +33,7 @@ from app.scodoc import sco_groups
from app.scodoc.sco_exceptions import AccessDenied from app.scodoc.sco_exceptions import AccessDenied
def affectGroups(partition_id, REQUEST=None): def affectGroups(partition_id):
"""Formulaire affectation des etudiants aux groupes de la partition. """Formulaire affectation des etudiants aux groupes de la partition.
Permet aussi la creation et la suppression de groupes. Permet aussi la creation et la suppression de groupes.
""" """

View File

@ -219,21 +219,20 @@ def sco_import_generate_excel_sample(
def students_import_excel( def students_import_excel(
csvfile, csvfile,
REQUEST=None,
formsemestre_id=None, formsemestre_id=None,
check_homonyms=True, check_homonyms=True,
require_ine=False, require_ine=False,
return_html=True,
): ):
"import students from Excel file" "import students from Excel file"
diag = scolars_import_excel_file( diag = scolars_import_excel_file(
csvfile, csvfile,
REQUEST,
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
check_homonyms=check_homonyms, check_homonyms=check_homonyms,
require_ine=require_ine, require_ine=require_ine,
exclude_cols=["photo_filename"], exclude_cols=["photo_filename"],
) )
if REQUEST: if return_html:
if formsemestre_id: if formsemestre_id:
dest = url_for( dest = url_for(
"notes.formsemestre_status", "notes.formsemestre_status",
@ -254,7 +253,6 @@ def students_import_excel(
def scolars_import_excel_file( def scolars_import_excel_file(
datafile, datafile,
REQUEST,
formsemestre_id=None, formsemestre_id=None,
check_homonyms=True, check_homonyms=True,
require_ine=False, require_ine=False,
@ -419,7 +417,6 @@ def scolars_import_excel_file(
formsemestre_to_invalidate.add( formsemestre_to_invalidate.add(
_import_one_student( _import_one_student(
cnx, cnx,
REQUEST,
formsemestre_id, formsemestre_id,
values, values,
GroupIdInferers, GroupIdInferers,
@ -492,16 +489,15 @@ def scolars_import_excel_file(
def students_import_admission( def students_import_admission(
csvfile, type_admission="", REQUEST=None, formsemestre_id=None csvfile, type_admission="", formsemestre_id=None, return_html=True
): ):
"import donnees admission from Excel file (v2016)" "import donnees admission from Excel file (v2016)"
diag = scolars_import_admission( diag = scolars_import_admission(
csvfile, csvfile,
REQUEST,
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
type_admission=type_admission, type_admission=type_admission,
) )
if REQUEST: if return_html:
H = [html_sco_header.sco_header(page_title="Import données admissions")] H = [html_sco_header.sco_header(page_title="Import données admissions")]
H.append("<p>Import terminé !</p>") H.append("<p>Import terminé !</p>")
H.append( H.append(
@ -520,7 +516,6 @@ def students_import_admission(
def _import_one_student( def _import_one_student(
cnx, cnx,
REQUEST,
formsemestre_id, formsemestre_id,
values, values,
GroupIdInferers, GroupIdInferers,
@ -538,7 +533,7 @@ def _import_one_student(
) )
# Identite # Identite
args = values.copy() args = values.copy()
etudid = sco_etud.identite_create(cnx, args, REQUEST=REQUEST) etudid = sco_etud.identite_create(cnx, args)
created_etudids.append(etudid) created_etudids.append(etudid)
# Admissions # Admissions
args["etudid"] = etudid args["etudid"] = etudid
@ -587,9 +582,7 @@ def _is_new_ine(cnx, code_ine):
# ------ Fonction ré-écrite en nov 2016 pour lire des fichiers sans etudid (fichiers APB) # ------ Fonction ré-écrite en nov 2016 pour lire des fichiers sans etudid (fichiers APB)
def scolars_import_admission( def scolars_import_admission(datafile, formsemestre_id=None, type_admission=None):
datafile, REQUEST, formsemestre_id=None, type_admission=None
):
"""Importe données admission depuis un fichier Excel quelconque """Importe données admission depuis un fichier Excel quelconque
par exemple ceux utilisés avec APB par exemple ceux utilisés avec APB

View File

@ -265,7 +265,6 @@ def formsemestre_inscr_passage(
inscrit_groupes=False, inscrit_groupes=False,
submitted=False, submitted=False,
dialog_confirmed=False, dialog_confirmed=False,
REQUEST=None,
): ):
"""Form. pour inscription des etudiants d'un semestre dans un autre """Form. pour inscription des etudiants d'un semestre dans un autre
(donné par formsemestre_id). (donné par formsemestre_id).
@ -313,7 +312,6 @@ def formsemestre_inscr_passage(
if not submitted: if not submitted:
H += build_page( H += build_page(
REQUEST,
sem, sem,
auth_etuds_by_sem, auth_etuds_by_sem,
inscrits, inscrits,
@ -398,7 +396,6 @@ def formsemestre_inscr_passage(
def build_page( def build_page(
REQUEST,
sem, sem,
auth_etuds_by_sem, auth_etuds_by_sem,
inscrits, inscrits,

View File

@ -56,7 +56,7 @@ from app.scodoc.gen_tables import GenTable
from app.scodoc.htmlutils import histogram_notes from app.scodoc.htmlutils import histogram_notes
def do_evaluation_listenotes(REQUEST): def do_evaluation_listenotes():
""" """
Affichage des notes d'une évaluation Affichage des notes d'une évaluation
@ -64,12 +64,13 @@ def do_evaluation_listenotes(REQUEST):
(si moduleimpl_id, affiche toutes les évaluatons du module) (si moduleimpl_id, affiche toutes les évaluatons du module)
""" """
mode = None mode = None
if "evaluation_id" in REQUEST.form: vals = request.form if request.method == "POST" else request.args
evaluation_id = int(REQUEST.form["evaluation_id"]) if "evaluation_id" in vals:
evaluation_id = int(vals["evaluation_id"])
mode = "eval" mode = "eval"
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
if "moduleimpl_id" in REQUEST.form: if "moduleimpl_id" in vals:
moduleimpl_id = int(REQUEST.form["moduleimpl_id"]) moduleimpl_id = int(vals["moduleimpl_id"])
mode = "module" mode = "module"
evals = sco_evaluations.do_evaluation_list({"moduleimpl_id": moduleimpl_id}) evals = sco_evaluations.do_evaluation_list({"moduleimpl_id": moduleimpl_id})
if not mode: if not mode:
@ -77,7 +78,7 @@ def do_evaluation_listenotes(REQUEST):
if not evals: if not evals:
return "<p>Aucune évaluation !</p>" return "<p>Aucune évaluation !</p>"
format = REQUEST.form.get("format", "html") format = vals.get("format", "html")
E = evals[0] # il y a au moins une evaluation E = evals[0] # il y a au moins une evaluation
# description de l'evaluation # description de l'evaluation
if mode == "eval": if mode == "eval":
@ -178,7 +179,7 @@ def do_evaluation_listenotes(REQUEST):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cancelbutton=None, cancelbutton=None,
submitbutton=None, submitbutton=None,
@ -201,7 +202,6 @@ def do_evaluation_listenotes(REQUEST):
hide_groups = tf[2]["hide_groups"] hide_groups = tf[2]["hide_groups"]
with_emails = tf[2]["with_emails"] with_emails = tf[2]["with_emails"]
return _make_table_notes( return _make_table_notes(
REQUEST,
tf[1], tf[1],
evals, evals,
format=format, format=format,
@ -214,7 +214,6 @@ def do_evaluation_listenotes(REQUEST):
def _make_table_notes( def _make_table_notes(
REQUEST,
html_form, html_form,
evals, evals,
format="", format="",
@ -760,9 +759,7 @@ def evaluation_check_absences(evaluation_id):
return ValButAbs, AbsNonSignalee, ExcNonSignalee, ExcNonJust, AbsButExc return ValButAbs, AbsNonSignalee, ExcNonSignalee, ExcNonJust, AbsButExc
def evaluation_check_absences_html( def evaluation_check_absences_html(evaluation_id, with_header=True, show_ok=True):
evaluation_id, with_header=True, show_ok=True, REQUEST=None
):
"""Affiche etat verification absences d'une evaluation""" """Affiche etat verification absences d'une evaluation"""
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
@ -859,7 +856,7 @@ def evaluation_check_absences_html(
return "\n".join(H) return "\n".join(H)
def formsemestre_check_absences_html(formsemestre_id, REQUEST=None): def formsemestre_check_absences_html(formsemestre_id):
"""Affiche etat verification absences pour toutes les evaluations du semestre !""" """Affiche etat verification absences pour toutes les evaluations du semestre !"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [ H = [
@ -891,7 +888,6 @@ def formsemestre_check_absences_html(formsemestre_id, REQUEST=None):
E["evaluation_id"], E["evaluation_id"],
with_header=False, with_header=False,
show_ok=False, show_ok=False,
REQUEST=REQUEST,
) )
) )
if evals: if evals:

View File

@ -63,7 +63,7 @@ def formsemestre_table_etuds_lycees(
) )
def scodoc_table_etuds_lycees(format="html", REQUEST=None): def scodoc_table_etuds_lycees(format="html"):
"""Table avec _tous_ les étudiants des semestres non verrouillés """Table avec _tous_ les étudiants des semestres non verrouillés
de _tous_ les départements. de _tous_ les départements.
""" """
@ -181,7 +181,6 @@ def formsemestre_etuds_lycees(
format="html", format="html",
only_primo=False, only_primo=False,
no_grouping=False, no_grouping=False,
REQUEST=None,
): ):
"""Table des lycées d'origine""" """Table des lycées d'origine"""
tab, etuds_by_lycee = formsemestre_table_etuds_lycees( tab, etuds_by_lycee = formsemestre_table_etuds_lycees(
@ -197,7 +196,7 @@ def formsemestre_etuds_lycees(
return t return t
F = [ F = [
sco_report.tsp_form_primo_group( sco_report.tsp_form_primo_group(
REQUEST, only_primo, no_grouping, formsemestre_id, format only_primo, no_grouping, formsemestre_id, format
) )
] ]
H = [ H = [

View File

@ -88,14 +88,14 @@ def do_modalite_list(*args, **kw):
return _modaliteEditor.list(cnx, *args, **kw) return _modaliteEditor.list(cnx, *args, **kw)
def do_modalite_create(args, REQUEST=None): def do_modalite_create(args):
"create a modalite" "create a modalite"
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = _modaliteEditor.create(cnx, args) r = _modaliteEditor.create(cnx, args)
return r return r
def do_modalite_delete(oid, REQUEST=None): def do_modalite_delete(oid):
"delete a modalite" "delete a modalite"
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
log("do_modalite_delete: form_modalite_id=%s" % oid) log("do_modalite_delete: form_modalite_id=%s" % oid)

View File

@ -100,9 +100,7 @@ def do_moduleimpl_delete(oid, formsemestre_id=None):
) # > moduleimpl_delete ) # > moduleimpl_delete
def do_moduleimpl_list( def do_moduleimpl_list(moduleimpl_id=None, formsemestre_id=None, module_id=None):
moduleimpl_id=None, formsemestre_id=None, module_id=None, REQUEST=None
):
"list moduleimpls" "list moduleimpls"
args = locals() args = locals()
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -110,7 +108,7 @@ def do_moduleimpl_list(
# Ajoute la liste des enseignants # Ajoute la liste des enseignants
for mo in modimpls: for mo in modimpls:
mo["ens"] = do_ens_list(args={"moduleimpl_id": mo["moduleimpl_id"]}) mo["ens"] = do_ens_list(args={"moduleimpl_id": mo["moduleimpl_id"]})
return scu.return_text_if_published(modimpls, REQUEST) return modimpls
def do_moduleimpl_edit(args, formsemestre_id=None, cnx=None): def do_moduleimpl_edit(args, formsemestre_id=None, cnx=None):
@ -125,7 +123,7 @@ def do_moduleimpl_edit(args, formsemestre_id=None, cnx=None):
def do_moduleimpl_withmodule_list( def do_moduleimpl_withmodule_list(
moduleimpl_id=None, formsemestre_id=None, module_id=None, REQUEST=None moduleimpl_id=None, formsemestre_id=None, module_id=None
): ):
"""Liste les moduleimpls et ajoute dans chacun le module correspondant """Liste les moduleimpls et ajoute dans chacun le module correspondant
Tri la liste par semestre/UE/numero_matiere/numero_module. Tri la liste par semestre/UE/numero_matiere/numero_module.
@ -137,7 +135,6 @@ def do_moduleimpl_withmodule_list(
from app.scodoc import sco_edit_module from app.scodoc import sco_edit_module
args = locals() args = locals()
del args["REQUEST"]
modimpls = do_moduleimpl_list( modimpls = do_moduleimpl_list(
**{ **{
"moduleimpl_id": moduleimpl_id, "moduleimpl_id": moduleimpl_id,
@ -166,16 +163,14 @@ def do_moduleimpl_withmodule_list(
) )
) )
return scu.return_text_if_published(modimpls, REQUEST) return modimpls
def do_moduleimpl_inscription_list(moduleimpl_id=None, etudid=None, REQUEST=None): def do_moduleimpl_inscription_list(moduleimpl_id=None, etudid=None):
"list moduleimpl_inscriptions" "list moduleimpl_inscriptions"
args = locals() args = locals()
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
return scu.return_text_if_published( return _moduleimpl_inscriptionEditor.list(cnx, args)
_moduleimpl_inscriptionEditor.list(cnx, args), REQUEST
)
def do_moduleimpl_listeetuds(moduleimpl_id): def do_moduleimpl_listeetuds(moduleimpl_id):
@ -244,9 +239,7 @@ def do_moduleimpl_inscription_delete(oid, formsemestre_id=None):
) # > moduleimpl_inscription ) # > moduleimpl_inscription
def do_moduleimpl_inscrit_etuds( def do_moduleimpl_inscrit_etuds(moduleimpl_id, formsemestre_id, etudids, reset=False):
moduleimpl_id, formsemestre_id, etudids, reset=False, REQUEST=None
):
"""Inscrit les etudiants (liste d'etudids) a ce module. """Inscrit les etudiants (liste d'etudids) a ce module.
Si reset, desinscrit tous les autres. Si reset, desinscrit tous les autres.
""" """
@ -309,7 +302,7 @@ def do_ens_create(args):
return r return r
def can_change_module_resp(REQUEST, moduleimpl_id): def can_change_module_resp(moduleimpl_id):
"""Check if current user can modify module resp. (raise exception if not). """Check if current user can modify module resp. (raise exception if not).
= Admin, et dir des etud. (si option l'y autorise) = Admin, et dir des etud. (si option l'y autorise)
""" """

View File

@ -51,9 +51,7 @@ from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
def moduleimpl_inscriptions_edit( def moduleimpl_inscriptions_edit(moduleimpl_id, etuds=[], submitted=False):
moduleimpl_id, etuds=[], submitted=False, REQUEST=None
):
"""Formulaire inscription des etudiants a ce module """Formulaire inscription des etudiants a ce module
* Gestion des inscriptions * Gestion des inscriptions
Nom TD TA TP (triable) Nom TD TA TP (triable)
@ -200,7 +198,7 @@ def moduleimpl_inscriptions_edit(
else: # SUBMISSION else: # SUBMISSION
# inscrit a ce module tous les etuds selectionnes # inscrit a ce module tous les etuds selectionnes
sco_moduleimpl.do_moduleimpl_inscrit_etuds( sco_moduleimpl.do_moduleimpl_inscrit_etuds(
moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST moduleimpl_id, formsemestre_id, etuds, reset=True
) )
return flask.redirect("moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id)) return flask.redirect("moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id))
# #
@ -231,7 +229,7 @@ def _make_menu(partitions, title="", check="true"):
) )
def moduleimpl_inscriptions_stats(formsemestre_id, REQUEST=None): def moduleimpl_inscriptions_stats(formsemestre_id):
"""Affiche quelques informations sur les inscriptions """Affiche quelques informations sur les inscriptions
aux modules de ce semestre. aux modules de ce semestre.
@ -523,7 +521,7 @@ def is_inscrit_ue(etudid, formsemestre_id, ue_id):
return r return r
def do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None): def do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id):
"""Desincrit l'etudiant de tous les modules de cette UE dans ce semestre.""" """Desincrit l'etudiant de tous les modules de cette UE dans ce semestre."""
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
@ -543,7 +541,6 @@ def do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None):
""", """,
{"etudid": etudid, "formsemestre_id": formsemestre_id, "ue_id": ue_id}, {"etudid": etudid, "formsemestre_id": formsemestre_id, "ue_id": ue_id},
) )
if REQUEST:
logdb( logdb(
cnx, cnx,
method="etud_desinscrit_ue", method="etud_desinscrit_ue",
@ -556,7 +553,7 @@ def do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None):
) # > desinscription etudiant des modules ) # > desinscription etudiant des modules
def do_etud_inscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None): def do_etud_inscrit_ue(etudid, formsemestre_id, ue_id):
"""Incrit l'etudiant de tous les modules de cette UE dans ce semestre.""" """Incrit l'etudiant de tous les modules de cette UE dans ce semestre."""
# Verifie qu'il est bien inscrit au semestre # Verifie qu'il est bien inscrit au semestre
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(

View File

@ -55,7 +55,7 @@ from app.scodoc import sco_users
# ported from old DTML code in oct 2009 # ported from old DTML code in oct 2009
# menu evaluation dans moduleimpl # menu evaluation dans moduleimpl
def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0, REQUEST=None): def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0):
"Menu avec actions sur une evaluation" "Menu avec actions sur une evaluation"
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
modimpl = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0] modimpl = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
@ -154,7 +154,7 @@ def moduleimpl_evaluation_menu(evaluation_id, nbnotes=0, REQUEST=None):
return htmlutils.make_menu("actions", menuEval, alone=True) return htmlutils.make_menu("actions", menuEval, alone=True)
def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None): def moduleimpl_status(moduleimpl_id=None, partition_id=None):
"""Tableau de bord module (liste des evaluations etc)""" """Tableau de bord module (liste des evaluations etc)"""
M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
formsemestre_id = M["formsemestre_id"] formsemestre_id = M["formsemestre_id"]
@ -190,7 +190,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None):
f"""<span class="blacktt">({module_resp.user_name})</span>""", f"""<span class="blacktt">({module_resp.user_name})</span>""",
] ]
try: try:
sco_moduleimpl.can_change_module_resp(REQUEST, moduleimpl_id) sco_moduleimpl.can_change_module_resp(moduleimpl_id)
H.append( H.append(
"""<a class="stdlink" href="edit_moduleimpl_resp?moduleimpl_id=%s">modifier</a>""" """<a class="stdlink" href="edit_moduleimpl_resp?moduleimpl_id=%s">modifier</a>"""
% moduleimpl_id % moduleimpl_id
@ -514,7 +514,6 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None):
moduleimpl_evaluation_menu( moduleimpl_evaluation_menu(
eval["evaluation_id"], eval["evaluation_id"],
nbnotes=etat["nb_notes"], nbnotes=etat["nb_notes"],
REQUEST=REQUEST,
) )
) )
H.append("</td>") H.append("</td>")

View File

@ -30,7 +30,7 @@
Fiche description d'un étudiant et de son parcours Fiche description d'un étudiant et de son parcours
""" """
from flask import url_for, g from flask import url_for, g, request
from flask_login import current_user from flask_login import current_user
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -143,18 +143,18 @@ def _menuScolarite(authuser, sem, etudid):
) )
def ficheEtud(etudid=None, REQUEST=None): def ficheEtud(etudid=None):
"fiche d'informations sur un etudiant" "fiche d'informations sur un etudiant"
authuser = current_user authuser = current_user
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
if etudid and REQUEST: if etudid:
# la sidebar est differente s'il y a ou pas un etudid # la sidebar est differente s'il y a ou pas un etudid
# voir html_sidebar.sidebar() # voir html_sidebar.sidebar()
REQUEST.form["etudid"] = etudid g.etudid = etudid
args = sco_etud.make_etud_args(etudid=etudid) args = sco_etud.make_etud_args(etudid=etudid)
etuds = sco_etud.etudident_list(cnx, args) etuds = sco_etud.etudident_list(cnx, args)
if not etuds: if not etuds:
log("ficheEtud: etudid=%s REQUEST.form=%s" % (etudid, REQUEST.form)) log("ficheEtud: etudid=%s request.args=%s" % (etudid, request.args))
raise ScoValueError("Etudiant inexistant !") raise ScoValueError("Etudiant inexistant !")
etud = etuds[0] etud = etuds[0]
etudid = etud["etudid"] etudid = etud["etudid"]
@ -356,7 +356,7 @@ def ficheEtud(etudid=None, REQUEST=None):
# Fichiers archivés: # Fichiers archivés:
info["fichiers_archive_htm"] = ( info["fichiers_archive_htm"] = (
'<div class="fichetitre">Fichiers associés</div>' '<div class="fichetitre">Fichiers associés</div>'
+ sco_archives_etud.etud_list_archives_html(REQUEST, etudid) + sco_archives_etud.etud_list_archives_html(etudid)
) )
# Devenir de l'étudiant: # Devenir de l'étudiant:
@ -417,7 +417,7 @@ def ficheEtud(etudid=None, REQUEST=None):
) )
else: else:
info["groupes_row"] = "" info["groupes_row"] = ""
info["menus_etud"] = menus_etud(REQUEST) info["menus_etud"] = menus_etud(etudid)
tmpl = """<div class="menus_etud">%(menus_etud)s</div> tmpl = """<div class="menus_etud">%(menus_etud)s</div>
<div class="ficheEtud" id="ficheEtud"><table> <div class="ficheEtud" id="ficheEtud"><table>
<tr><td> <tr><td>
@ -499,13 +499,11 @@ def ficheEtud(etudid=None, REQUEST=None):
return header + tmpl % info + html_sco_header.sco_footer() return header + tmpl % info + html_sco_header.sco_footer()
def menus_etud(REQUEST=None): def menus_etud(etudid):
"""Menu etudiant (operations sur l'etudiant)""" """Menu etudiant (operations sur l'etudiant)"""
if "etudid" not in REQUEST.form:
return ""
authuser = current_user authuser = current_user
etud = sco_etud.get_etud_info(filled=True)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
menuEtud = [ menuEtud = [
{ {
@ -544,7 +542,7 @@ def menus_etud(REQUEST=None):
return htmlutils.make_menu("Etudiant", menuEtud, alone=True) 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. """An HTML div with basic information and links about this etud.
Used for popups information windows. Used for popups information windows.
""" """

View File

@ -535,7 +535,7 @@ class SituationEtudParcoursGeneric(object):
validated = True validated = True
return s return s
def valide_decision(self, decision, REQUEST): def valide_decision(self, decision):
"""Enregistre la decision (instance de DecisionSem) """Enregistre la decision (instance de DecisionSem)
Enregistre codes semestre et UE, et autorisations inscription. Enregistre codes semestre et UE, et autorisations inscription.
""" """

View File

@ -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 from app.scodoc.sco_exceptions import ScoGenError
import datetime import datetime
import glob import glob
@ -120,7 +121,7 @@ def etud_photo_url(etud, size="small", fast=False):
return photo_url 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) """Returns photo image (HTTP response)
If not etudid, use "unknown" image 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) filename = photo_pathname(etud, size=size)
if not filename: if not filename:
filename = UNKNOWN_IMAGE_PATH filename = UNKNOWN_IMAGE_PATH
return _http_jpeg_file(filename, REQUEST=REQUEST) return _http_jpeg_file(filename)
def _http_jpeg_file(filename, REQUEST=None): def _http_jpeg_file(filename):
"""returns an image. """returns an image as a Flask response"""
This function will be modified when we kill #zope
"""
st = os.stat(filename) st = os.stat(filename)
last_modified = st.st_mtime # float timestamp 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 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") header = request.headers.get("If-Modified-Since")
if header is not None: if header is not None:
header = header.split(";")[0] header = header.split(";")[0]
@ -161,13 +152,20 @@ def _http_jpeg_file(filename, REQUEST=None):
try: try:
dt = datetime.datetime.strptime(header, "%a, %d %b %Y %H:%M:%S GMT") dt = datetime.datetime.strptime(header, "%a, %d %b %Y %H:%M:%S GMT")
mod_since = dt.timestamp() mod_since = dt.timestamp()
except: except ValueError:
mod_since = None mod_since = None
if (mod_since is not None) and last_modified <= mod_since: if (mod_since is not None) and last_modified <= mod_since:
RESPONSE.setStatus(304) # not modified return "", 304 # not modified
return "" #
last_modified_str = time.strftime(
return open(filename, mode="rb").read() "%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"): 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. """HTML img tag for the photo, in full size.
Full-size images are always stored locally in the filesystem. Full-size images are always stored locally in the filesystem.
They are the original uploaded images, converted in jpeg. They are the original uploaded images, converted in jpeg.
@ -263,7 +261,7 @@ def store_photo(etud, data):
return 1, "ok" return 1, "ok"
def suppress_photo(etud, REQUEST=None): def suppress_photo(etud):
"""Suppress a photo""" """Suppress a photo"""
log("suppress_photo etudid=%s" % etud["etudid"]) log("suppress_photo etudid=%s" % etud["etudid"])
rel_path = photo_pathname(etud) rel_path = photo_pathname(etud)
@ -281,7 +279,6 @@ def suppress_photo(etud, REQUEST=None):
log("removing file %s" % filename) log("removing file %s" % filename)
os.remove(filename) os.remove(filename)
# 3- log # 3- log
if REQUEST:
logdb(cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"]) logdb(cnx, method="changePhoto", msg="suppression", etudid=etud["etudid"])

View File

@ -164,7 +164,7 @@ def _getEtudInfoGroupes(group_ids, etat=None):
return etuds return etuds
def formsemestre_poursuite_report(formsemestre_id, format="html", REQUEST=None): def formsemestre_poursuite_report(formsemestre_id, format="html"):
"""Table avec informations "poursuite" """ """Table avec informations "poursuite" """
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds = _getEtudInfoGroupes([sco_groups.get_default_group(formsemestre_id)]) etuds = _getEtudInfoGroupes([sco_groups.get_default_group(formsemestre_id)])

View File

@ -77,7 +77,7 @@ sinon, elle ne concerne que le semestre indiqué.
- avoir un mapping (read only) de toutes les valeurs: - avoir un mapping (read only) de toutes les valeurs:
sco_preferences.SemPreferences(formsemestre_id) sco_preferences.SemPreferences(formsemestre_id)
- editer les preferences globales: - 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: - editer les preferences d'un semestre:
SemPreferences(formsemestre_id).edit() SemPreferences(formsemestre_id).edit()
@ -2014,7 +2014,7 @@ class BasePreferences(object):
self._editor.delete(cnx, pdb[0]["pref_id"]) self._editor.delete(cnx, pdb[0]["pref_id"])
sco_cache.invalidate_formsemestre() # > modif preferences sco_cache.invalidate_formsemestre() # > modif preferences
def edit(self, REQUEST): def edit(self):
"""HTML dialog: edit global preferences""" """HTML dialog: edit global preferences"""
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
@ -2033,7 +2033,7 @@ class BasePreferences(object):
form = self.build_tf_form() form = self.build_tf_form()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
initvalues=self.prefs[None], initvalues=self.prefs[None],
submitlabel="Enregistrer les modifications", submitlabel="Enregistrer les modifications",
@ -2143,7 +2143,7 @@ class SemPreferences(object):
return self.base_prefs.is_global(self.formsemestre_id, name) return self.base_prefs.is_global(self.formsemestre_id, name)
# The dialog # The dialog
def edit(self, categories=[], REQUEST=None): def edit(self, categories=[]):
"""Dialog to edit semestre preferences in given categories""" """Dialog to edit semestre preferences in given categories"""
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre
@ -2198,7 +2198,7 @@ function set_global_pref(el, pref_name) {
form.append(("formsemestre_id", {"input_type": "hidden"})) form.append(("formsemestre_id", {"input_type": "hidden"}))
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
initvalues=self, initvalues=self,
cssclass="sco_pref", cssclass="sco_pref",

View File

@ -48,7 +48,7 @@ from app.scodoc import sco_preferences
from app.scodoc.sco_excel import ScoExcelSheet 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" "Feuille excel pour preparation des jurys"
nt = sco_cache.NotesTableCache.get( nt = sco_cache.NotesTableCache.get(
formsemestre_id formsemestre_id

View File

@ -495,7 +495,7 @@ def pvjury_table(
return lines, titles, columns_ids 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 """Page récapitulant les décisions de jury
dpv: result of dict_pvjury 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 """Generation PV jury en PDF: saisie des paramètres
Si etudid, PV pour un seul etudiant. Sinon, tout les inscrits au groupe indiqué. 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 menu_choix_groupe = "" # un seul etudiant à editer
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="get", 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" "Lettres avis jury en PDF"
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not group_ids: if not group_ids:
@ -824,7 +824,7 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[], REQUEST=No
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
cancelbutton="Annuler", cancelbutton="Annuler",
method="POST", method="POST",

View File

@ -33,6 +33,7 @@ import time
from xml.etree import ElementTree from xml.etree import ElementTree
from flask import request from flask import request
from flask import make_response
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app import log from app import log
@ -68,7 +69,6 @@ def formsemestre_recapcomplet(
rank_partition_id=None, # si None, calcul rang global rank_partition_id=None, # si None, calcul rang global
pref_override=True, # si vrai, les prefs ont la priorite sur le param hidebac 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 force_publishing=True, # publie les XML/JSON meme si bulletins non publiés
REQUEST=None,
): ):
"""Page récapitulant les notes d'un semestre. """Page récapitulant les notes d'un semestre.
Grand tableau récapitulatif avec toutes les notes de modules 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"], javascripts=["libjs/sorttable.js", "js/etud_info.js"],
), ),
sco_formsemestre_status.formsemestre_status_head( sco_formsemestre_status.formsemestre_status_head(
formsemestre_id=formsemestre_id, REQUEST=REQUEST formsemestre_id=formsemestre_id
), ),
'<form name="f" method="get" action="%s">' % request.base_url, '<form name="f" method="get" action="%s">' % request.base_url,
'<input type="hidden" name="formsemestre_id" value="%s"></input>' '<input type="hidden" name="formsemestre_id" value="%s"></input>'
@ -147,11 +147,7 @@ def formsemestre_recapcomplet(
if hidebac: if hidebac:
H.append("checked") H.append("checked")
H.append(""" >cacher bac</input>""") H.append(""" >cacher bac</input>""")
if tabformat == "xml": data = do_formsemestre_recapcomplet(
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
H.append(
do_formsemestre_recapcomplet(
REQUEST,
formsemestre_id, formsemestre_id,
format=tabformat, format=tabformat,
hidemodules=hidemodules, hidemodules=hidemodules,
@ -162,7 +158,11 @@ def formsemestre_recapcomplet(
rank_partition_id=rank_partition_id, rank_partition_id=rank_partition_id,
force_publishing=force_publishing, force_publishing=force_publishing,
) )
) if tabformat == "xml":
response = make_response(data)
response.headers["Content-Type"] = scu.XML_MIMETYPE
return response
H.append(data)
if not isFile: if not isFile:
H.append("</form>") H.append("</form>")
@ -200,7 +200,6 @@ def formsemestre_recapcomplet(
def do_formsemestre_recapcomplet( def do_formsemestre_recapcomplet(
REQUEST=None,
formsemestre_id=None, formsemestre_id=None,
format="html", # html, xml, xls, xlsall, json format="html", # html, xml, xls, xlsall, json
hidemodules=False, # ne pas montrer les modules (ignoré en XML) hidemodules=False, # ne pas montrer les modules (ignoré en XML)
@ -959,7 +958,7 @@ def _formsemestre_recapcomplet_json(
return J, "", "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. """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 :param annee_scolaire(int): année de début de l'année scoalaire
:returns: JSON :returns: JSON

View File

@ -210,7 +210,6 @@ def _results_by_category(
def formsemestre_report( def formsemestre_report(
formsemestre_id, formsemestre_id,
etuds, etuds,
REQUEST=None,
category="bac", category="bac",
result="codedecision", result="codedecision",
category_name="", category_name="",
@ -253,26 +252,25 @@ def formsemestre_report(
return tab 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 # Tableau sur résultats par type de bac
# """ # """
# sem = sco_formsemestre.get_formsemestre( formsemestre_id) # sem = sco_formsemestre.get_formsemestre( formsemestre_id)
# title = 'Statistiques bacs ' + sem['titreannee'] # title = 'Statistiques bacs ' + sem['titreannee']
# etuds = formsemestre_etuds_stats(sem) # etuds = formsemestre_etuds_stats(sem)
# tab = formsemestre_report(formsemestre_id, etuds, REQUEST=REQUEST, # tab = formsemestre_report(formsemestre_id, etuds,
# category='bac', result='codedecision', # category='bac', result='codedecision',
# category_name='Bac', # category_name='Bac',
# title=title) # title=title)
# return tab.make_page( # return tab.make_page(
# title = """<h2>Résultats de <a href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titreannee)s</a></h2>""" % sem, # title = """<h2>Résultats de <a href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titreannee)s</a></h2>""" % sem,
# format=format, page_title = title, REQUEST=REQUEST ) # format=format, page_title = title)
def formsemestre_report_counts( def formsemestre_report_counts(
formsemestre_id, formsemestre_id,
format="html", format="html",
REQUEST=None,
category="bac", category="bac",
result="codedecision", result="codedecision",
allkeys=False, allkeys=False,
@ -288,7 +286,6 @@ def formsemestre_report_counts(
tab = formsemestre_report( tab = formsemestre_report(
formsemestre_id, formsemestre_id,
etuds, etuds,
REQUEST=REQUEST,
category=category, category=category,
result=result, result=result,
category_name=category_name, category_name=category_name,
@ -692,7 +689,6 @@ def formsemestre_suivi_cohorte(
civilite=None, civilite=None,
statut="", statut="",
only_primo=False, only_primo=False,
REQUEST=None,
): ):
"""Affiche suivi cohortes par numero de semestre""" """Affiche suivi cohortes par numero de semestre"""
annee_bac = str(annee_bac) annee_bac = str(annee_bac)
@ -755,7 +751,6 @@ def formsemestre_suivi_cohorte(
"""<h2 class="formsemestre">Suivi cohorte: devenir des étudiants de ce semestre</h2>""", """<h2 class="formsemestre">Suivi cohorte: devenir des étudiants de ce semestre</h2>""",
_gen_form_selectetuds( _gen_form_selectetuds(
formsemestre_id, formsemestre_id,
REQUEST=REQUEST,
only_primo=only_primo, only_primo=only_primo,
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,
@ -779,7 +774,6 @@ def formsemestre_suivi_cohorte(
def _gen_form_selectetuds( def _gen_form_selectetuds(
formsemestre_id, formsemestre_id,
REQUEST=None,
percent=None, percent=None,
only_primo=None, only_primo=None,
bac=None, bac=None,
@ -1164,7 +1158,7 @@ def table_suivi_parcours(formsemestre_id, only_primo=False, grouped_parcours=Tru
return tab 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""" """Element de formulaire pour choisir si restriction aux primos entrants et groupement par lycees"""
F = ["""<form name="f" method="get" action="%s">""" % request.base_url] F = ["""<form name="f" method="get" action="%s">""" % request.base_url]
if only_primo: if only_primo:
@ -1196,7 +1190,6 @@ def formsemestre_suivi_parcours(
format="html", format="html",
only_primo=False, only_primo=False,
no_grouping=False, no_grouping=False,
REQUEST=None,
): ):
"""Effectifs dans les differents parcours possibles.""" """Effectifs dans les differents parcours possibles."""
tab = table_suivi_parcours( tab = table_suivi_parcours(
@ -1212,9 +1205,7 @@ def formsemestre_suivi_parcours(
t = tab.make_page(format=format, with_html_headers=False) t = tab.make_page(format=format, with_html_headers=False)
if format != "html": if format != "html":
return t return t
F = [ F = [tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, format)]
tsp_form_primo_group(REQUEST, only_primo, no_grouping, formsemestre_id, format)
]
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
@ -1465,7 +1456,6 @@ def formsemestre_graph_parcours(
civilite="", civilite="",
statut="", statut="",
allkeys=False, # unused allkeys=False, # unused
REQUEST=None,
): ):
"""Graphe suivi cohortes""" """Graphe suivi cohortes"""
annee_bac = str(annee_bac) annee_bac = str(annee_bac)
@ -1512,12 +1502,13 @@ def formsemestre_graph_parcours(
civilite=civilite, civilite=civilite,
statut=statut, statut=statut,
) )
filename = scu.make_filename("flux " + sem["titreannee"]) return scu.send_file(
REQUEST.RESPONSE.setHeader( doc,
"content-disposition", 'attachment; filename="%s"' % filename filename="flux " + sem["titreannee"],
suffix=".png",
attached=True,
mime="image/png",
) )
REQUEST.RESPONSE.setHeader("content-type", "image/png")
return doc
elif format == "html": elif format == "html":
url_kw = { url_kw = {
"scodoc_dept": g.scodoc_dept, "scodoc_dept": g.scodoc_dept,
@ -1557,7 +1548,6 @@ def formsemestre_graph_parcours(
"<p>%d étudiants sélectionnés</p>" % len(etuds), "<p>%d étudiants sélectionnés</p>" % len(etuds),
_gen_form_selectetuds( _gen_form_selectetuds(
formsemestre_id, formsemestre_id,
REQUEST=REQUEST,
only_primo=only_primo, only_primo=only_primo,
bac=bac, bac=bac,
bacspecialite=bacspecialite, bacspecialite=bacspecialite,

View File

@ -164,13 +164,14 @@ def _check_notes(notes, evaluation, mod):
return L, invalids, withoutnotes, absents, tosuppress return L, invalids, withoutnotes, absents, tosuppress
def do_evaluation_upload_xls(REQUEST): def do_evaluation_upload_xls():
""" """
Soumission d'un fichier XLS (evaluation_id, notefile) Soumission d'un fichier XLS (evaluation_id, notefile)
""" """
authuser = current_user authuser = current_user
evaluation_id = int(REQUEST.form["evaluation_id"]) vals = request.form if request.method == "POST" else request.args
comment = REQUEST.form["comment"] evaluation_id = int(vals["evaluation_id"])
comment = vals["comment"]
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[ M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[
0 0
@ -181,7 +182,7 @@ def do_evaluation_upload_xls(REQUEST):
# XXX imaginer un redirect + msg erreur # XXX imaginer un redirect + msg erreur
raise AccessDenied("Modification des notes impossible pour %s" % authuser) raise AccessDenied("Modification des notes impossible pour %s" % authuser)
# #
diag, lines = sco_excel.excel_file_to_list(REQUEST.form["notefile"]) diag, lines = sco_excel.excel_file_to_list(vals["notefile"])
try: try:
if not lines: if not lines:
raise InvalidNoteValue() raise InvalidNoteValue()
@ -287,7 +288,6 @@ def do_evaluation_upload_xls(REQUEST):
def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False): def do_evaluation_set_missing(evaluation_id, value, dialog_confirmed=False):
"""Initialisation des notes manquantes""" """Initialisation des notes manquantes"""
# ? evaluation_id = REQUEST.form["evaluation_id"]
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[ M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[
0 0
@ -588,7 +588,7 @@ def _notes_add(user, evaluation_id: int, notes: list, comment=None, do_it=True):
return nb_changed, nb_suppress, existing_decisions return nb_changed, nb_suppress, existing_decisions
def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None): def saisie_notes_tableur(evaluation_id, group_ids=[]):
"""Saisie des notes via un fichier Excel""" """Saisie des notes via un fichier Excel"""
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
if not evals: if not evals:
@ -658,7 +658,7 @@ def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None):
nf = TrivialFormulator( nf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}), ("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),
( (
@ -687,7 +687,7 @@ def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None):
elif nf[0] == -1: elif nf[0] == -1:
H.append("<p>Annulation</p>") H.append("<p>Annulation</p>")
elif nf[0] == 1: elif nf[0] == 1:
updiag = do_evaluation_upload_xls(REQUEST) updiag = do_evaluation_upload_xls()
if updiag[0]: if updiag[0]:
H.append(updiag[1]) H.append(updiag[1])
H.append( H.append(
@ -759,7 +759,7 @@ def saisie_notes_tableur(evaluation_id, group_ids=[], REQUEST=None):
return "\n".join(H) return "\n".join(H)
def feuille_saisie_notes(evaluation_id, group_ids=[], REQUEST=None): def feuille_saisie_notes(evaluation_id, group_ids=[]):
"""Document Excel pour saisie notes dans l'évaluation et les groupes indiqués""" """Document Excel pour saisie notes dans l'évaluation et les groupes indiqués"""
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
if not evals: if not evals:
@ -830,7 +830,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[], REQUEST=None):
filename = "notes_%s_%s.xlsx" % (evalname, gr_title_filename) filename = "notes_%s_%s.xlsx" % (evalname, gr_title_filename)
xls = sco_excel.excel_feuille_saisie(E, sem["titreannee"], description, lines=L) xls = sco_excel.excel_feuille_saisie(E, sem["titreannee"], description, lines=L)
return scu.send_file(xls, filename, scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE) return scu.send_file(xls, filename, scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE)
# return sco_excel.send_excel_file(REQUEST, xls, filename) # return sco_excel.send_excel_file(xls, filename)
def has_existing_decision(M, E, etudid): def has_existing_decision(M, E, etudid):
@ -857,7 +857,7 @@ def has_existing_decision(M, E, etudid):
# Nouveau formulaire saisie notes (2016) # Nouveau formulaire saisie notes (2016)
def saisie_notes(evaluation_id, group_ids=[], REQUEST=None): def saisie_notes(evaluation_id, group_ids=[]):
"""Formulaire saisie notes d'une évaluation pour un groupe""" """Formulaire saisie notes d'une évaluation pour un groupe"""
group_ids = [int(group_id) for group_id in group_ids] group_ids = [int(group_id) for group_id in group_ids]
evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
@ -946,9 +946,7 @@ def saisie_notes(evaluation_id, group_ids=[], REQUEST=None):
moduleimpl_id=E["moduleimpl_id"], moduleimpl_id=E["moduleimpl_id"],
) )
form = _form_saisie_notes( form = _form_saisie_notes(E, M, groups_infos.group_ids, destination=destination)
E, M, groups_infos.group_ids, destination=destination, REQUEST=REQUEST
)
if form is None: if form is None:
log(f"redirecting to {destination}") log(f"redirecting to {destination}")
return flask.redirect(destination) return flask.redirect(destination)
@ -1039,7 +1037,7 @@ def _get_sorted_etuds(E, etudids, formsemestre_id):
return etuds return etuds
def _form_saisie_notes(E, M, group_ids, destination="", REQUEST=None): def _form_saisie_notes(E, M, group_ids, destination=""):
"""Formulaire HTML saisie des notes dans l'évaluation E du moduleimpl M """Formulaire HTML saisie des notes dans l'évaluation E du moduleimpl M
pour les groupes indiqués. pour les groupes indiqués.
@ -1181,7 +1179,7 @@ def _form_saisie_notes(E, M, group_ids, destination="", REQUEST=None):
tf = TF( tf = TF(
destination, destination,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
initvalues=initvalues, initvalues=initvalues,
submitbutton=False, submitbutton=False,
@ -1220,7 +1218,7 @@ def _form_saisie_notes(E, M, group_ids, destination="", REQUEST=None):
return None return None
def save_note(etudid=None, evaluation_id=None, value=None, comment="", REQUEST=None): def save_note(etudid=None, evaluation_id=None, value=None, comment=""):
"""Enregistre une note (ajax)""" """Enregistre une note (ajax)"""
authuser = current_user authuser = current_user
log( log(

View File

@ -199,7 +199,7 @@ class ModuleTag(ScoTag):
# API # API
def module_tag_search(term, REQUEST=None): def module_tag_search(term):
"""List all used tag names (for auto-completion)""" """List all used tag names (for auto-completion)"""
# restrict charset to avoid injections # restrict charset to avoid injections
if not scu.ALPHANUM_EXP.match(term): if not scu.ALPHANUM_EXP.match(term):

View File

@ -66,7 +66,6 @@ from app.scodoc import sco_etud
def trombino( def trombino(
REQUEST=None,
group_ids=[], # liste des groupes à afficher group_ids=[], # liste des groupes à afficher
formsemestre_id=None, # utilisé si pas de groupes selectionné formsemestre_id=None, # utilisé si pas de groupes selectionné
etat=None, etat=None,
@ -83,21 +82,19 @@ def trombino(
# #
if format != "html" and not dialog_confirmed: if format != "html" and not dialog_confirmed:
ok, dialog = check_local_photos_availability( ok, dialog = check_local_photos_availability(groups_infos, format=format)
groups_infos, REQUEST, format=format
)
if not ok: if not ok:
return dialog return dialog
if format == "zip": if format == "zip":
return _trombino_zip(groups_infos) return _trombino_zip(groups_infos)
elif format == "pdf": elif format == "pdf":
return _trombino_pdf(groups_infos, REQUEST) return _trombino_pdf(groups_infos)
elif format == "pdflist": elif format == "pdflist":
return _listeappel_photos_pdf(groups_infos, REQUEST) return _listeappel_photos_pdf(groups_infos)
else: else:
raise Exception("invalid format") raise Exception("invalid format")
# return _trombino_html_header() + trombino_html( group, members, REQUEST=REQUEST) + html_sco_header.sco_footer( REQUEST) # return _trombino_html_header() + trombino_html( group, members) + html_sco_header.sco_footer()
def _trombino_html_header(): def _trombino_html_header():
@ -183,7 +180,7 @@ def trombino_html(groups_infos):
return "\n".join(H) return "\n".join(H)
def check_local_photos_availability(groups_infos, REQUEST, format=""): def check_local_photos_availability(groups_infos, format=""):
"""Verifie que toutes les photos (des gropupes indiqués) sont copiées localement """Verifie que toutes les photos (des gropupes indiqués) sont copiées localement
dans ScoDoc (seules les photos dont nous disposons localement peuvent être exportées dans ScoDoc (seules les photos dont nous disposons localement peuvent être exportées
en pdf ou en zip). en pdf ou en zip).
@ -245,7 +242,7 @@ def _trombino_zip(groups_infos):
# Copy photos from portal to ScoDoc # Copy photos from portal to ScoDoc
def trombino_copy_photos(group_ids=[], REQUEST=None, dialog_confirmed=False): def trombino_copy_photos(group_ids=[], dialog_confirmed=False):
"Copy photos from portal to ScoDoc (overwriting local copy)" "Copy photos from portal to ScoDoc (overwriting local copy)"
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids) groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args
@ -316,7 +313,7 @@ def _get_etud_platypus_image(t, image_width=2 * cm):
raise raise
def _trombino_pdf(groups_infos, REQUEST): def _trombino_pdf(groups_infos):
"Send photos as pdf page" "Send photos as pdf page"
# Generate PDF page # Generate PDF page
filename = "trombino_%s" % groups_infos.groups_filename + ".pdf" filename = "trombino_%s" % groups_infos.groups_filename + ".pdf"
@ -394,7 +391,7 @@ def _trombino_pdf(groups_infos, REQUEST):
# --------------------- Sur une idée de l'IUT d'Orléans: # --------------------- Sur une idée de l'IUT d'Orléans:
def _listeappel_photos_pdf(groups_infos, REQUEST): def _listeappel_photos_pdf(groups_infos):
"Doc pdf pour liste d'appel avec photos" "Doc pdf pour liste d'appel avec photos"
filename = "trombino_%s" % groups_infos.groups_filename + ".pdf" filename = "trombino_%s" % groups_infos.groups_filename + ".pdf"
sem = groups_infos.formsemestre # suppose 1 seul semestre sem = groups_infos.formsemestre # suppose 1 seul semestre
@ -470,7 +467,7 @@ def _listeappel_photos_pdf(groups_infos, REQUEST):
# --------------------- Upload des photos de tout un groupe # --------------------- Upload des photos de tout un groupe
def photos_generate_excel_sample(group_ids=[], REQUEST=None): def photos_generate_excel_sample(group_ids=[]):
"""Feuille excel pour import fichiers photos""" """Feuille excel pour import fichiers photos"""
fmt = sco_import_etuds.sco_import_format() fmt = sco_import_etuds.sco_import_format()
data = sco_import_etuds.sco_import_generate_excel_sample( data = sco_import_etuds.sco_import_generate_excel_sample(
@ -489,10 +486,10 @@ def photos_generate_excel_sample(group_ids=[], REQUEST=None):
return scu.send_file( return scu.send_file(
data, "ImportPhotos", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True data, "ImportPhotos", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True
) )
# return sco_excel.send_excel_file(REQUEST, data, "ImportPhotos" + scu.XLSX_SUFFIX) # return sco_excel.send_excel_file(data, "ImportPhotos" + scu.XLSX_SUFFIX)
def photos_import_files_form(group_ids=[], REQUEST=None): def photos_import_files_form(group_ids=[]):
"""Formulaire pour importation photos""" """Formulaire pour importation photos"""
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids) groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args
@ -517,10 +514,11 @@ def photos_import_files_form(group_ids=[], REQUEST=None):
% groups_infos.groups_query_args, % groups_infos.groups_query_args,
] ]
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
REQUEST.form["group_ids"] = groups_infos.group_ids vals = request.form if request.method == "POST" else request.args
vals["group_ids"] = groups_infos.group_ids
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, vals,
( (
("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}), ("xlsfile", {"title": "Fichier Excel:", "input_type": "file", "size": 40}),
("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}), ("zipfile", {"title": "Fichier zip:", "input_type": "file", "size": 40}),
@ -537,11 +535,10 @@ def photos_import_files_form(group_ids=[], REQUEST=None):
group_ids=tf[2]["group_ids"], group_ids=tf[2]["group_ids"],
xlsfile=tf[2]["xlsfile"], xlsfile=tf[2]["xlsfile"],
zipfile=tf[2]["zipfile"], zipfile=tf[2]["zipfile"],
REQUEST=REQUEST,
) )
def photos_import_files(group_ids=[], xlsfile=None, zipfile=None, REQUEST=None): def photos_import_files(group_ids=[], xlsfile=None, zipfile=None):
"""Importation des photos""" """Importation des photos"""
groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids) groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids)
back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args back_url = "groups_view?%s&curtab=tab-photos" % groups_infos.groups_query_args

View File

@ -56,7 +56,6 @@ N_PER_ROW = 5
def pdf_trombino_tours( def pdf_trombino_tours(
group_ids=[], # liste des groupes à afficher group_ids=[], # liste des groupes à afficher
formsemestre_id=None, # utilisé si pas de groupes selectionné formsemestre_id=None, # utilisé si pas de groupes selectionné
REQUEST=None,
): ):
"""Generation du trombinoscope en fichier PDF""" """Generation du trombinoscope en fichier PDF"""
# Informations sur les groupes à afficher: # Informations sur les groupes à afficher:
@ -281,7 +280,6 @@ def pdf_trombino_tours(
def pdf_feuille_releve_absences( def pdf_feuille_releve_absences(
group_ids=[], # liste des groupes à afficher group_ids=[], # liste des groupes à afficher
formsemestre_id=None, # utilisé si pas de groupes selectionné formsemestre_id=None, # utilisé si pas de groupes selectionné
REQUEST=None,
): ):
"""Generation de la feuille d'absence en fichier PDF, avec photos""" """Generation de la feuille d'absence en fichier PDF, avec photos"""

View File

@ -135,9 +135,7 @@ def external_ue_create(
return moduleimpl_id return moduleimpl_id
def external_ue_inscrit_et_note( def external_ue_inscrit_et_note(moduleimpl_id, formsemestre_id, notes_etuds):
moduleimpl_id, formsemestre_id, notes_etuds, REQUEST=None
):
log( log(
"external_ue_inscrit_et_note(moduleimpl_id=%s, notes_etuds=%s)" "external_ue_inscrit_et_note(moduleimpl_id=%s, notes_etuds=%s)"
% (moduleimpl_id, notes_etuds) % (moduleimpl_id, notes_etuds)
@ -147,7 +145,6 @@ def external_ue_inscrit_et_note(
moduleimpl_id, moduleimpl_id,
formsemestre_id, formsemestre_id,
list(notes_etuds.keys()), list(notes_etuds.keys()),
REQUEST=REQUEST,
) )
# Création d'une évaluation si il n'y en a pas déjà: # Création d'une évaluation si il n'y en a pas déjà:
@ -158,7 +155,6 @@ def external_ue_inscrit_et_note(
else: else:
# crée une évaluation: # crée une évaluation:
evaluation_id = sco_evaluations.do_evaluation_create( evaluation_id = sco_evaluations.do_evaluation_create(
REQUEST=REQUEST,
moduleimpl_id=moduleimpl_id, moduleimpl_id=moduleimpl_id,
note_max=20.0, note_max=20.0,
coefficient=1.0, coefficient=1.0,
@ -201,7 +197,7 @@ def get_external_moduleimpl_id(formsemestre_id, ue_id):
# Web function # Web function
def external_ue_create_form(formsemestre_id, etudid, REQUEST=None): def external_ue_create_form(formsemestre_id, etudid):
"""Formulaire création UE externe + inscription étudiant et saisie note """Formulaire création UE externe + inscription étudiant et saisie note
- Demande UE: peut-être existante (liste les UE externes de cette formation), - Demande UE: peut-être existante (liste les UE externes de cette formation),
ou sinon spécifier titre, acronyme, type, ECTS ou sinon spécifier titre, acronyme, type, ECTS
@ -249,7 +245,7 @@ def external_ue_create_form(formsemestre_id, etudid, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("formsemestre_id", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}),
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
@ -365,6 +361,5 @@ def external_ue_create_form(formsemestre_id, etudid, REQUEST=None):
moduleimpl_id, moduleimpl_id,
formsemestre_id, formsemestre_id,
{etudid: note_value}, {etudid: note_value},
REQUEST=REQUEST,
) )
return flask.redirect(bull_url + "&head_message=Ajout%20effectué") return flask.redirect(bull_url + "&head_message=Ajout%20effectué")

View File

@ -146,7 +146,7 @@ def list_operations(evaluation_id):
return Ops return Ops
def evaluation_list_operations(evaluation_id, REQUEST=None): def evaluation_list_operations(evaluation_id):
"""Page listing operations on evaluation""" """Page listing operations on evaluation"""
E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0]
M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
@ -172,7 +172,7 @@ def evaluation_list_operations(evaluation_id, REQUEST=None):
return tab.make_page() return tab.make_page()
def formsemestre_list_saisies_notes(formsemestre_id, format="html", REQUEST=None): def formsemestre_list_saisies_notes(formsemestre_id, format="html"):
"""Table listant toutes les opérations de saisies de notes, dans toutes """Table listant toutes les opérations de saisies de notes, dans toutes
les évaluations du semestre. les évaluations du semestre.
""" """
@ -227,7 +227,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html", REQUEST=None
return tab.make_page(format=format) return tab.make_page(format=format)
def get_note_history(evaluation_id, etudid, REQUEST=None, fmt=""): def get_note_history(evaluation_id, etudid, fmt=""):
"""Historique d'une note """Historique d'une note
= liste chronologique d'opérations, la plus récente d'abord = liste chronologique d'opérations, la plus récente d'abord
[ { 'value', 'date', 'comment', 'uid' } ] [ { 'value', 'date', 'comment', 'uid' } ]

View File

@ -77,7 +77,7 @@ def is_valid_password(cleartxt):
# --------------- # ---------------
def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"): def index_html(all_depts=False, with_inactives=False, format="html"):
"gestion utilisateurs..." "gestion utilisateurs..."
all_depts = int(all_depts) all_depts = int(all_depts)
with_inactives = int(with_inactives) with_inactives = int(with_inactives)
@ -121,7 +121,6 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"):
all_depts=all_depts, all_depts=all_depts,
with_inactives=with_inactives, with_inactives=with_inactives,
format=format, format=format,
REQUEST=REQUEST,
with_links=current_user.has_permission(Permission.ScoUsersAdmin, g.scodoc_dept), with_links=current_user.has_permission(Permission.ScoUsersAdmin, g.scodoc_dept),
) )
if format != "html": if format != "html":
@ -138,7 +137,6 @@ def list_users(
with_inactives=False, # inclut les anciens utilisateurs (status "old") with_inactives=False, # inclut les anciens utilisateurs (status "old")
format="html", format="html",
with_links=True, with_links=True,
REQUEST=None,
): ):
"List users, returns a table in the specified format" "List users, returns a table in the specified format"
from app.scodoc.sco_permissions_check import can_handle_passwd from app.scodoc.sco_permissions_check import can_handle_passwd

View File

@ -50,7 +50,6 @@ from flask import g, current_app
from PIL import Image as PILImage from PIL import Image as PILImage
from flask import g, url_for, request, make_response from flask import g, url_for, request, make_response
from werkzeug.wrappers import response
from config import Config from config import Config
from app import log from app import log
@ -549,22 +548,12 @@ def bul_filename(sem, etud, format):
return filename return filename
def sendCSVFile(REQUEST, data, filename): # DEPRECATED ne plus utiliser def sendCSVFile(data, filename): # DEPRECATED utiliser send_file
"""publication fichier. """publication fichier CSV."""
(on ne doit rien avoir émis avant, car ici sont générés les entetes) return send_file(data, filename=filename, mime=CSV_MIMETYPE, attached=True)
"""
filename = (
unescape_html(suppress_accents(filename)).replace("&", "").replace(" ", "_")
)
REQUEST.RESPONSE.setHeader("content-type", CSV_MIMETYPE)
REQUEST.RESPONSE.setHeader(
"content-disposition", 'attachment; filename="%s"' % filename
)
return data
def sendPDFFile(data, filename): def sendPDFFile(data, filename): # DEPRECATED utiliser send_file
filename = make_filename(filename)
return send_file(data, filename=filename, mime=PDF_MIMETYPE, attached=True) return send_file(data, filename=filename, mime=PDF_MIMETYPE, attached=True)
@ -613,7 +602,7 @@ def sendResult(data, name=None, format=None, force_outer_xml_tag=True, attached=
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 """Build Flask Response for file download of given type
By default (attached is None), json and xml are inlined and otrher types are atteched. By default (attached is None), json and xml are inlined and otrher types are attached.
""" """
if attached is None: if attached is None:
if mime == XML_MIMETYPE or mime == JSON_MIMETYPE: if mime == XML_MIMETYPE or mime == JSON_MIMETYPE:
@ -834,16 +823,6 @@ def AnneeScolaire(sco_year=None):
return year return year
def return_text_if_published(val, REQUEST):
"""Pour les méthodes publiées qui ramènent soit du texte (HTML) soit du JSON
sauf quand elles sont appellées depuis python.
La présence de l'argument REQUEST indique la publication.
"""
if REQUEST and not isinstance(val, str):
return sendJSON(val)
return val
def confirm_dialog( def confirm_dialog(
message="<p>Confirmer ?</p>", message="<p>Confirmer ?</p>",
OK="OK", OK="OK",

View File

@ -1104,7 +1104,7 @@ def AddBilletAbsence(
@scodoc @scodoc
@permission_required(Permission.ScoAbsAddBillet) @permission_required(Permission.ScoAbsAddBillet)
@scodoc7func @scodoc7func
def AddBilletAbsenceForm(etudid, REQUEST=None): def AddBilletAbsenceForm(etudid):
"""Formulaire ajout billet (pour tests seulement, le vrai formulaire accessible aux etudiants """Formulaire ajout billet (pour tests seulement, le vrai formulaire accessible aux etudiants
étant sur le portail étudiant). étant sur le portail étudiant).
""" """
@ -1116,7 +1116,7 @@ def AddBilletAbsenceForm(etudid, REQUEST=None):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
("begin", {"input_type": "date"}), ("begin", {"input_type": "date"}),
@ -1250,7 +1250,7 @@ def XMLgetBilletsEtud(etudid=False):
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func @scodoc7func
def listeBillets(REQUEST=None): def listeBillets():
"""Page liste des billets non traités et formulaire recherche d'un billet""" """Page liste des billets non traités et formulaire recherche d'un billet"""
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"etat": False}) billets = sco_abs.billet_absence_list(cnx, {"etat": False})
@ -1263,7 +1263,7 @@ def listeBillets(REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("billet_id", {"input_type": "text", "title": "Numéro du billet"}),), (("billet_id", {"input_type": "text", "title": "Numéro du billet"}),),
submitbutton=False, submitbutton=False,
) )
@ -1366,7 +1366,7 @@ def _ProcessBilletAbsence(billet, estjust, description):
@scodoc @scodoc
@permission_required(Permission.ScoAbsChange) @permission_required(Permission.ScoAbsChange)
@scodoc7func @scodoc7func
def ProcessBilletAbsenceForm(billet_id, REQUEST=None): def ProcessBilletAbsenceForm(billet_id):
"""Formulaire traitement d'un billet""" """Formulaire traitement d'un billet"""
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id}) billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
@ -1392,7 +1392,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("billet_id", {"input_type": "hidden"}), ("billet_id", {"input_type": "hidden"}),
( (

View File

@ -56,20 +56,20 @@ from flask_login import current_user
# import sco_entreprises # import sco_entreprises
def entreprise_header(REQUEST=None, page_title=""): def entreprise_header(page_title=""):
"common header for all Entreprises pages" "common header for all Entreprises pages"
return html_sco_header.sco_header(page_title=page_title) return html_sco_header.sco_header(page_title=page_title)
def entreprise_footer(REQUEST): def entreprise_footer():
"common entreprise footer" "common entreprise footer"
return html_sco_header.sco_footer(REQUEST) return html_sco_header.sco_footer()
security.declareProtected(ScoEntrepriseView, "sidebar") security.declareProtected(ScoEntrepriseView, "sidebar")
def sidebar(REQUEST): def sidebar():
"barre gauche (overide std sco sidebar)" "barre gauche (overide std sco sidebar)"
# rewritten from legacy DTML code # rewritten from legacy DTML code
# XXX rare cas restant d'utilisation de l'acquisition Zope2: à revoir # XXX rare cas restant d'utilisation de l'acquisition Zope2: à revoir
@ -94,8 +94,9 @@ def sidebar(REQUEST):
) )
# --- entreprise selectionnée: # --- entreprise selectionnée:
if "entreprise_id" in REQUEST.form: vals = request.form if request.method == "POST" else request.args
entreprise_id = REQUEST.form["entreprise_id"] if "entreprise_id" in vals:
entreprise_id = vals["entreprise_id"]
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id}) E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})
if E: if E:
E = E[0] E = E[0]
@ -106,7 +107,7 @@ def sidebar(REQUEST):
<ul class="insidebar"> <ul class="insidebar">
<li class="insidebar"><a href="%(ScoURL)s/Entreprises/entreprise_correspondant_list?entreprise_id=%(entreprise_id)s" class="sidebar">Corresp.</a></li>""" <li class="insidebar"><a href="%(ScoURL)s/Entreprises/entreprise_correspondant_list?entreprise_id=%(entreprise_id)s" class="sidebar">Corresp.</a></li>"""
% params % params
) # """ )
if current_user.has_permission(Permission.ScoEntrepriseChange): if current_user.has_permission(Permission.ScoEntrepriseChange):
H.append( H.append(
"""<li class="insidebar"><a href="%(ScoURL)s/Entreprises/entreprise_correspondant_create?entreprise_id=%(entreprise_id)s" class="sidebar">Nouveau Corresp.</a></li>""" """<li class="insidebar"><a href="%(ScoURL)s/Entreprises/entreprise_correspondant_create?entreprise_id=%(entreprise_id)s" class="sidebar">Nouveau Corresp.</a></li>"""
@ -139,22 +140,22 @@ def sidebar(REQUEST):
security.declareProtected(ScoEntrepriseView, "index_html") security.declareProtected(ScoEntrepriseView, "index_html")
def index_html(REQUEST=None, etud_nom=None, limit=50, offset="", format="html"): def index_html(etud_nom=None, limit=50, offset="", format="html"):
"""Accueil module entreprises""" """Accueil module entreprises"""
# Traduit du DTML - utilise table standard # Traduit du DTML - utilise table standard
if limit: if limit:
limit = int(limit) limit = int(limit)
if offset: if offset:
offset = int(offset or 0) offset = int(offset or 0)
vals = request.form if request.method == "POST" else request.args
if etud_nom: if etud_nom:
entreprises = sco_entreprises.do_entreprise_list_by_etud( entreprises = sco_entreprises.do_entreprise_list_by_etud(
args=REQUEST.form, sort_on_contact=True args=vals, sort_on_contact=True
) )
table_navigation = "" table_navigation = ""
else: else:
entreprises = sco_entreprises.do_entreprise_list( entreprises = sco_entreprises.do_entreprise_list(
args=REQUEST.form, args=vals,
test="~*", test="~*",
sort_on_contact=True, sort_on_contact=True,
limit=limit, limit=limit,
@ -226,12 +227,12 @@ def index_html(REQUEST=None, etud_nom=None, limit=50, offset="", format="html"):
return tab.make_page(format=format) return tab.make_page(format=format)
else: else:
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2>Suivi relations entreprises</h2>""", """<h2>Suivi relations entreprises</h2>""",
"""<div class="entreprise_list_table">""", """<div class="entreprise_list_table">""",
tab.html(), tab.html(),
"""</div>""", """</div>""",
entreprise_footer(REQUEST), entreprise_footer(),
] ]
return "\n".join(H) return "\n".join(H)
@ -239,9 +240,9 @@ def index_html(REQUEST=None, etud_nom=None, limit=50, offset="", format="html"):
security.declareProtected(ScoEntrepriseView, "entreprise_contact_list") security.declareProtected(ScoEntrepriseView, "entreprise_contact_list")
def entreprise_contact_list(entreprise_id=None, format="html", REQUEST=None): def entreprise_contact_list(entreprise_id=None, format="html"):
"""Liste des contacts de l'entreprise""" """Liste des contacts de l'entreprise"""
H = [entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises")] H = [entreprise_header(page_title="Suivi entreprises")]
if entreprise_id: if entreprise_id:
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
C = sco_entreprises.do_entreprise_contact_list( C = sco_entreprises.do_entreprise_contact_list(
@ -308,7 +309,7 @@ def entreprise_contact_list(entreprise_id=None, format="html", REQUEST=None):
% E % E
) )
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
@ -318,12 +319,11 @@ security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_list")
def entreprise_correspondant_list( def entreprise_correspondant_list(
entreprise_id=None, entreprise_id=None,
format="html", format="html",
REQUEST=None,
): ):
"""Liste des correspondants de l'entreprise""" """Liste des correspondants de l'entreprise"""
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
""" """
<h2>Listes des correspondants dans l'entreprise %(nom)s</h2> <h2>Listes des correspondants dans l'entreprise %(nom)s</h2>
""" """
@ -413,14 +413,14 @@ def entreprise_correspondant_list(
% E % E
) )
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseView, "entreprise_contact_edit") security.declareProtected(ScoEntrepriseView, "entreprise_contact_edit")
def entreprise_contact_edit(entreprise_contact_id, REQUEST=None): def entreprise_contact_edit(entreprise_contact_id):
"""Form edit contact""" """Form edit contact"""
c = sco_entreprises.do_entreprise_contact_list( c = sco_entreprises.do_entreprise_contact_list(
args={"entreprise_contact_id": entreprise_contact_id} args={"entreprise_contact_id": entreprise_contact_id}
@ -437,14 +437,14 @@ def entreprise_contact_edit(entreprise_contact_id, REQUEST=None):
) + [("inconnu", "")] ) + [("inconnu", "")]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2 class="entreprise_contact">Suivi entreprises</h2> """<h2 class="entreprise_contact">Suivi entreprises</h2>
<h3>Contact avec entreprise %(nom)s</h3>""" <h3>Contact avec entreprise %(nom)s</h3>"""
% E, % E,
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"entreprise_contact_id", "entreprise_contact_id",
@ -540,25 +540,25 @@ def entreprise_contact_edit(entreprise_contact_id, REQUEST=None):
+ "/entreprise_contact_list?entreprise_id=" + "/entreprise_contact_list?entreprise_id="
+ str(c["entreprise_id"]) + str(c["entreprise_id"])
) )
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_edit") security.declareProtected(ScoEntrepriseView, "entreprise_correspondant_edit")
def entreprise_correspondant_edit(entreprise_corresp_id, REQUEST=None): def entreprise_correspondant_edit(entreprise_corresp_id):
"""Form édition d'un correspondant""" """Form édition d'un correspondant"""
c = sco_entreprises.do_entreprise_correspondant_list( c = sco_entreprises.do_entreprise_correspondant_list(
args={"entreprise_corresp_id": entreprise_corresp_id} args={"entreprise_corresp_id": entreprise_corresp_id}
)[0] )[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2 class="entreprise_correspondant">Édition contact entreprise</h2>""", """<h2 class="entreprise_correspondant">Édition contact entreprise</h2>""",
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"entreprise_corresp_id", "entreprise_corresp_id",
@ -653,14 +653,14 @@ def entreprise_correspondant_edit(entreprise_corresp_id, REQUEST=None):
"%s/entreprise_correspondant_list?entreprise_id=%s" "%s/entreprise_correspondant_list?entreprise_id=%s"
% (scu.EntreprisesURL(), c["entreprise_id"]) % (scu.EntreprisesURL(), c["entreprise_id"])
) )
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_create") security.declareProtected(ScoEntrepriseChange, "entreprise_contact_create")
def entreprise_contact_create(entreprise_id, REQUEST=None): def entreprise_contact_create(entreprise_id):
"""Form création contact""" """Form création contact"""
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
correspondants = sco_entreprises.do_entreprise_correspondant_listnames( correspondants = sco_entreprises.do_entreprise_correspondant_listnames(
@ -674,13 +674,13 @@ def entreprise_contact_create(entreprise_id, REQUEST=None):
% (scu.EntreprisesURL(), entreprise_id) % (scu.EntreprisesURL(), entreprise_id)
) )
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2 class="entreprise_contact">Nouveau "contact" avec l'entreprise %(nom)s</h2>""" """<h2 class="entreprise_contact">Nouveau "contact" avec l'entreprise %(nom)s</h2>"""
% E, % E,
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
( (
@ -759,25 +759,25 @@ def entreprise_contact_create(entreprise_id, REQUEST=None):
tf[2].update({"etudid": etudok[1]}) tf[2].update({"etudid": etudok[1]})
sco_entreprises.do_entreprise_contact_create(tf[2]) sco_entreprises.do_entreprise_contact_create(tf[2])
return flask.redirect(scu.EntreprisesURL()) return flask.redirect(scu.EntreprisesURL())
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseChange, "entreprise_contact_delete") security.declareProtected(ScoEntrepriseChange, "entreprise_contact_delete")
def entreprise_contact_delete(entreprise_contact_id, REQUEST=None): def entreprise_contact_delete(entreprise_contact_id):
"""Form delete contact""" """Form delete contact"""
c = sco_entreprises.do_entreprise_contact_list( c = sco_entreprises.do_entreprise_contact_list(
args={"entreprise_contact_id": entreprise_contact_id} args={"entreprise_contact_id": entreprise_contact_id}
)[0] )[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2>Suppression du contact</h2>""", """<h2>Suppression du contact</h2>""",
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("entreprise_contact_id", {"input_type": "hidden"}),), (("entreprise_contact_id", {"input_type": "hidden"}),),
initvalues=c, initvalues=c,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -791,24 +791,24 @@ def entreprise_contact_delete(entreprise_contact_id, REQUEST=None):
else: else:
sco_entreprises.do_entreprise_contact_delete(c["entreprise_contact_id"]) sco_entreprises.do_entreprise_contact_delete(c["entreprise_contact_id"])
return flask.redirect(scu.EntreprisesURL(context)) return flask.redirect(scu.EntreprisesURL(context))
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_create") security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_create")
def entreprise_correspondant_create(entreprise_id, REQUEST=None): def entreprise_correspondant_create(entreprise_id):
"""Form création correspondant""" """Form création correspondant"""
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2 class="entreprise_contact">Nouveau correspondant l'entreprise %(nom)s</h2>""" """<h2 class="entreprise_contact">Nouveau correspondant l'entreprise %(nom)s</h2>"""
% E, % E,
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("entreprise_id", {"input_type": "hidden", "default": entreprise_id}), ("entreprise_id", {"input_type": "hidden", "default": entreprise_id}),
( (
@ -894,25 +894,25 @@ def entreprise_correspondant_create(entreprise_id, REQUEST=None):
else: else:
sco_entreprises.do_entreprise_correspondant_create(tf[2]) sco_entreprises.do_entreprise_correspondant_create(tf[2])
return flask.redirect(scu.EntreprisesURL(context)) return flask.redirect(scu.EntreprisesURL(context))
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_delete") security.declareProtected(ScoEntrepriseChange, "entreprise_correspondant_delete")
def entreprise_correspondant_delete(entreprise_corresp_id, REQUEST=None): def entreprise_correspondant_delete(entreprise_corresp_id):
"""Form delete correspondant""" """Form delete correspondant"""
c = sco_entreprises.do_entreprise_correspondant_list( c = sco_entreprises.do_entreprise_correspondant_list(
args={"entreprise_corresp_id": entreprise_corresp_id} args={"entreprise_corresp_id": entreprise_corresp_id}
)[0] )[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2>Suppression du correspondant %(nom)s %(prenom)s</h2>""" % c, """<h2>Suppression du correspondant %(nom)s %(prenom)s</h2>""" % c,
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("entreprise_corresp_id", {"input_type": "hidden"}),), (("entreprise_corresp_id", {"input_type": "hidden"}),),
initvalues=c, initvalues=c,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -926,18 +926,18 @@ def entreprise_correspondant_delete(entreprise_corresp_id, REQUEST=None):
else: else:
sco_entreprises.do_entreprise_correspondant_delete(c["entreprise_corresp_id"]) sco_entreprises.do_entreprise_correspondant_delete(c["entreprise_corresp_id"])
return flask.redirect(scu.EntreprisesURL()) return flask.redirect(scu.EntreprisesURL())
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
security.declareProtected(ScoEntrepriseChange, "entreprise_delete") security.declareProtected(ScoEntrepriseChange, "entreprise_delete")
def entreprise_delete(entreprise_id, REQUEST=None): def entreprise_delete(entreprise_id):
"""Form delete entreprise""" """Form delete entreprise"""
E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] E = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
H = [ H = [
entreprise_header(REQUEST=REQUEST, page_title="Suivi entreprises"), entreprise_header(page_title="Suivi entreprises"),
"""<h2>Suppression de l'entreprise %(nom)s</h2> """<h2>Suppression de l'entreprise %(nom)s</h2>
<p class="entreprise_warning">Attention: supression définitive de l'entreprise, de ses correspondants et contacts. <p class="entreprise_warning">Attention: supression définitive de l'entreprise, de ses correspondants et contacts.
</p>""" </p>"""
@ -966,7 +966,7 @@ def entreprise_delete(entreprise_id, REQUEST=None):
H.append("""</ul>""") H.append("""</ul>""")
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("entreprise_id", {"input_type": "hidden"}),), (("entreprise_id", {"input_type": "hidden"}),),
initvalues=E, initvalues=E,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -980,7 +980,7 @@ def entreprise_delete(entreprise_id, REQUEST=None):
else: else:
sco_entreprises.do_entreprise_delete(E["entreprise_id"]) sco_entreprises.do_entreprise_delete(E["entreprise_id"])
return flask.redirect(scu.EntreprisesURL()) return flask.redirect(scu.EntreprisesURL())
H.append(entreprise_footer(REQUEST)) H.append(entreprise_footer())
return "\n".join(H) return "\n".join(H)
@ -988,15 +988,15 @@ def entreprise_delete(entreprise_id, REQUEST=None):
security.declareProtected(ScoEntrepriseChange, "entreprise_create") security.declareProtected(ScoEntrepriseChange, "entreprise_create")
def entreprise_create(REQUEST=None): def entreprise_create():
"""Form. création entreprise""" """Form. création entreprise"""
H = [ H = [
entreprise_header(REQUEST, page_title="Création d'une entreprise"), entreprise_header(page_title="Création d'une entreprise"),
"""<h2 class="entreprise_new">Création d'une entreprise</h2>""", """<h2 class="entreprise_new">Création d'une entreprise</h2>""",
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("nom", {"size": 25, "title": "Nom de l'entreprise"}), ("nom", {"size": 25, "title": "Nom de l'entreprise"}),
( (
@ -1069,7 +1069,7 @@ def entreprise_create(REQUEST=None):
readonly=not current_user.has_permission(Permission.ScoEntrepriseChange), readonly=not current_user.has_permission(Permission.ScoEntrepriseChange),
) )
if tf[0] == 0: if tf[0] == 0:
return "\n".join(H) + tf[1] + entreprise_footer(REQUEST) return "\n".join(H) + tf[1] + entreprise_footer()
elif tf[0] == -1: elif tf[0] == -1:
return flask.redirect(scu.EntreprisesURL()) return flask.redirect(scu.EntreprisesURL())
else: else:
@ -1080,18 +1080,18 @@ def entreprise_create(REQUEST=None):
security.declareProtected(ScoEntrepriseView, "entreprise_edit") security.declareProtected(ScoEntrepriseView, "entreprise_edit")
def entreprise_edit(entreprise_id, REQUEST=None, start=1): def entreprise_edit(entreprise_id, start=1):
"""Form. edit entreprise""" """Form. edit entreprise"""
authuser = current_user authuser = current_user
readonly = not authuser.has_permission(Permission.ScoEntrepriseChange) readonly = not authuser.has_permission(Permission.ScoEntrepriseChange)
F = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0] F = sco_entreprises.do_entreprise_list(args={"entreprise_id": entreprise_id})[0]
H = [ H = [
entreprise_header(REQUEST, page_title="Entreprise"), entreprise_header(page_title="Entreprise"),
"""<h2 class="entreprise">%(nom)s</h2>""" % F, """<h2 class="entreprise">%(nom)s</h2>""" % F,
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("entreprise_id", {"default": entreprise_id, "input_type": "hidden"}), ("entreprise_id", {"default": entreprise_id, "input_type": "hidden"}),
("start", {"default": 1, "input_type": "hidden"}), ("start", {"default": 1, "input_type": "hidden"}),
@ -1242,7 +1242,7 @@ def entreprise_edit(entreprise_id, REQUEST=None, start=1):
H.append("(%s)" % c["description"]) H.append("(%s)" % c["description"])
H.append("</li>") H.append("</li>")
H.append("</ul>") H.append("</ul>")
return "\n".join(H) + entreprise_footer(REQUEST) return "\n".join(H) + entreprise_footer()
elif tf[0] == -1: elif tf[0] == -1:
return flask.redirect(scu.EntreprisesURL() + "?start=" + start) return flask.redirect(scu.EntreprisesURL() + "?start=" + start)
else: else:

View File

@ -147,12 +147,12 @@ def sco_publish(route, function, permission, methods=["GET"]):
# @scodoc # @scodoc
# @permission_required(Permission.ScoView) # @permission_required(Permission.ScoView)
# @scodoc7func # @scodoc7func
# def essai(REQUEST=None): # def essai():
# return essai_(REQUEST) # return essai_()
# def essai_(REQUEST): # def essai_():
# return "<html><body><h2>essai !</h2><p>%s</p></body></html>" % (REQUEST,) # return "<html><body><h2>essai !</h2><p>%s</p></body></html>" % ()
# def essai2(): # def essai2():
@ -262,7 +262,7 @@ sco_publish(
@bp.route( @bp.route(
"formsemestre_bulletinetud", methods=["GET", "POST"] "formsemestre_bulletinetud", methods=["GET", "POST"]
) # pour compat anciens clients PHP ) # POST pour compat anciens clients PHP (deprecated)
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func @scodoc7func
@ -274,7 +274,6 @@ def formsemestre_bulletinetud(
xml_with_decisions=False, xml_with_decisions=False,
force_publishing=False, force_publishing=False,
prefer_mail_perso=False, prefer_mail_perso=False,
REQUEST=None,
): ):
return sco_bulletins.formsemestre_bulletinetud( return sco_bulletins.formsemestre_bulletinetud(
etudid=etudid, etudid=etudid,
@ -284,7 +283,6 @@ def formsemestre_bulletinetud(
xml_with_decisions=xml_with_decisions, xml_with_decisions=xml_with_decisions,
force_publishing=force_publishing, force_publishing=force_publishing,
prefer_mail_perso=prefer_mail_perso, prefer_mail_perso=prefer_mail_perso,
REQUEST=REQUEST,
) )
@ -408,7 +406,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def index_html(REQUEST=None): def index_html():
"Page accueil formations" "Page accueil formations"
editable = current_user.has_permission(Permission.ScoChangeFormation) editable = current_user.has_permission(Permission.ScoChangeFormation)
@ -495,7 +493,7 @@ def formation_import_xml(file):
@scodoc @scodoc
@permission_required(Permission.ScoChangeFormation) @permission_required(Permission.ScoChangeFormation)
@scodoc7func @scodoc7func
def formation_import_xml_form(REQUEST): def formation_import_xml_form():
"form import d'une formation en XML" "form import d'une formation en XML"
H = [ H = [
html_sco_header.sco_header(page_title="Import d'une formation"), html_sco_header.sco_header(page_title="Import d'une formation"),
@ -507,7 +505,7 @@ def formation_import_xml_form(REQUEST):
footer = html_sco_header.sco_footer() footer = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("xmlfile", {"input_type": "file", "title": "Fichier XML", "size": 30}),), (("xmlfile", {"input_type": "file", "title": "Fichier XML", "size": 30}),),
submitlabel="Importer", submitlabel="Importer",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -618,7 +616,7 @@ def formsemestre_list(
): ):
"""List formsemestres in given format. """List formsemestres in given format.
kw can specify some conditions: examples: kw can specify some conditions: examples:
formsemestre_list( format='json', formation_id='F777', REQUEST=REQUEST) formsemestre_list( format='json', formation_id='F777')
""" """
# XAPI: new json api # XAPI: new json api
args = {} args = {}
@ -637,7 +635,7 @@ def formsemestre_list(
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func @scodoc7func
def XMLgetFormsemestres(etape_apo=None, formsemestre_id=None, REQUEST=None): def XMLgetFormsemestres(etape_apo=None, formsemestre_id=None):
"""List all formsemestres matching etape, XML format """List all formsemestres matching etape, XML format
DEPRECATED: use formsemestre_list() DEPRECATED: use formsemestre_list()
""" """
@ -647,8 +645,7 @@ def XMLgetFormsemestres(etape_apo=None, formsemestre_id=None, REQUEST=None):
args["etape_apo"] = etape_apo args["etape_apo"] = etape_apo
if formsemestre_id: if formsemestre_id:
args["formsemestre_id"] = formsemestre_id args["formsemestre_id"] = formsemestre_id
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = ElementTree.Element("formsemestrelist") doc = ElementTree.Element("formsemestrelist")
for sem in sco_formsemestre.do_formsemestre_list(args=args): for sem in sco_formsemestre.do_formsemestre_list(args=args):
for k in sem: for k in sem:
@ -657,7 +654,8 @@ def XMLgetFormsemestres(etape_apo=None, formsemestre_id=None, REQUEST=None):
sem_elt = ElementTree.Element("formsemestre", **sem) sem_elt = ElementTree.Element("formsemestre", **sem)
doc.append(sem_elt) doc.append(sem_elt)
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING) data = sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
return scu.send_file(data, mime=scu.XML_MIMETYPE)
sco_publish( sco_publish(
@ -671,12 +669,25 @@ sco_publish(
Permission.ScoView, Permission.ScoView,
methods=["GET", "POST"], methods=["GET", "POST"],
) )
sco_publish(
"/formsemestre_change_lock",
sco_formsemestre_edit.formsemestre_change_lock, @bp.route("/formsemestre_change_lock", methods=["GET", "POST"])
Permission.ScoView, @scodoc
methods=["GET", "POST"], @permission_required(Permission.ScoView) # acces vérifié dans la fonction
) @scodoc7func
def formsemestre_change_lock(formsemestre_id, dialog_confirmed=False):
sco_formsemestre_edit.formsemestre_change_lock(
formsemestre_id, dialog_confirmed=dialog_confirmed
)
return flask.redirect(
url_for(
"notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)
)
sco_publish( sco_publish(
"/formsemestre_change_publication_bul", "/formsemestre_change_publication_bul",
sco_formsemestre_edit.formsemestre_change_publication_bul, sco_formsemestre_edit.formsemestre_change_publication_bul,
@ -694,12 +705,10 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_custommenu_edit(REQUEST, formsemestre_id): def formsemestre_custommenu_edit(formsemestre_id):
"Dialogue modif menu" "Dialogue modif menu"
# accessible à tous ! # accessible à tous !
return sco_formsemestre_custommenu.formsemestre_custommenu_edit( return sco_formsemestre_custommenu.formsemestre_custommenu_edit(formsemestre_id)
formsemestre_id, REQUEST=REQUEST
)
# --- dialogue modif enseignants/moduleimpl # --- dialogue modif enseignants/moduleimpl
@ -707,7 +716,7 @@ def formsemestre_custommenu_edit(REQUEST, formsemestre_id):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def edit_enseignants_form(REQUEST, moduleimpl_id): def edit_enseignants_form(moduleimpl_id):
"modif liste enseignants/moduleimpl" "modif liste enseignants/moduleimpl"
M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id) M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id)
# -- # --
@ -782,7 +791,7 @@ def edit_enseignants_form(REQUEST, moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
modform, modform,
submitlabel="Ajouter enseignant", submitlabel="Ajouter enseignant",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -826,11 +835,11 @@ def edit_enseignants_form(REQUEST, moduleimpl_id):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def edit_moduleimpl_resp(REQUEST, moduleimpl_id): def edit_moduleimpl_resp(moduleimpl_id):
"""Changement d'un enseignant responsable de module """Changement d'un enseignant responsable de module
Accessible par Admin et dir des etud si flag resp_can_change_ens Accessible par Admin et dir des etud si flag resp_can_change_ens
""" """
M, sem = sco_moduleimpl.can_change_module_resp(REQUEST, moduleimpl_id) M, sem = sco_moduleimpl.can_change_module_resp(moduleimpl_id)
H = [ H = [
html_sco_header.html_sem_header( html_sco_header.html_sem_header(
'Modification du responsable du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>' 'Modification du responsable du <a href="moduleimpl_status?moduleimpl_id=%s">module %s</a>'
@ -878,7 +887,7 @@ def edit_moduleimpl_resp(REQUEST, moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
submitlabel="Changer responsable", submitlabel="Changer responsable",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -947,7 +956,7 @@ _EXPR_HELP = """<p class="help">Expérimental: formule de calcul de la moyenne %
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def edit_moduleimpl_expr(REQUEST, moduleimpl_id): def edit_moduleimpl_expr(moduleimpl_id):
"""Edition formule calcul moyenne module """Edition formule calcul moyenne module
Accessible par Admin, dir des etud et responsable module Accessible par Admin, dir des etud et responsable module
""" """
@ -981,7 +990,7 @@ def edit_moduleimpl_expr(REQUEST, moduleimpl_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
submitlabel="Modifier formule de calcul", submitlabel="Modifier formule de calcul",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1022,7 +1031,7 @@ def edit_moduleimpl_expr(REQUEST, moduleimpl_id):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def view_module_abs(REQUEST, moduleimpl_id, format="html"): def view_module_abs(moduleimpl_id, format="html"):
"""Visualisation des absences a un module""" """Visualisation des absences a un module"""
M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0] M = sco_moduleimpl.do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
@ -1099,10 +1108,10 @@ def view_module_abs(REQUEST, moduleimpl_id, format="html"):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def edit_ue_expr(REQUEST, formsemestre_id, ue_id): def edit_ue_expr(formsemestre_id, ue_id):
"""Edition formule calcul moyenne UE""" """Edition formule calcul moyenne UE"""
# Check access # Check access
sem = sco_formsemestre_edit.can_edit_sem(REQUEST, formsemestre_id) sem = sco_formsemestre_edit.can_edit_sem(formsemestre_id)
if not sem: if not sem:
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération") raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération")
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -1139,7 +1148,7 @@ def edit_ue_expr(REQUEST, formsemestre_id, ue_id):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
form, form,
submitlabel="Modifier formule de calcul", submitlabel="Modifier formule de calcul",
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1172,7 +1181,7 @@ def edit_ue_expr(REQUEST, formsemestre_id, ue_id):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_enseignants_list(REQUEST, formsemestre_id, format="html"): def formsemestre_enseignants_list(formsemestre_id, format="html"):
"""Liste les enseignants intervenants dans le semestre (resp. modules et chargés de TD) """Liste les enseignants intervenants dans le semestre (resp. modules et chargés de TD)
et indique les absences saisies par chacun. et indique les absences saisies par chacun.
""" """
@ -1312,9 +1321,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def do_formsemestre_inscription_listinscrits( def do_formsemestre_inscription_listinscrits(formsemestre_id, format=None):
formsemestre_id, format=None, REQUEST=None
):
"""Liste les inscrits (état I) à ce semestre et cache le résultat""" """Liste les inscrits (état I) à ce semestre et cache le résultat"""
r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits( r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
formsemestre_id formsemestre_id
@ -1326,9 +1333,7 @@ def do_formsemestre_inscription_listinscrits(
@scodoc @scodoc
@permission_required(Permission.ScoImplement) @permission_required(Permission.ScoImplement)
@scodoc7func @scodoc7func
def formsemestre_desinscription( def formsemestre_desinscription(etudid, formsemestre_id, dialog_confirmed=False):
etudid, formsemestre_id, REQUEST=None, dialog_confirmed=False
):
"""desinscrit l'etudiant de ce semestre (et donc de tous les modules). """desinscrit l'etudiant de ce semestre (et donc de tous les modules).
A n'utiliser qu'en cas d'erreur de saisie. A n'utiliser qu'en cas d'erreur de saisie.
S'il s'agit d'un semestre extérieur et qu'il n'y a plus d'inscrit, S'il s'agit d'un semestre extérieur et qu'il n'y a plus d'inscrit,
@ -1414,11 +1419,9 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None): def etud_desinscrit_ue(etudid, formsemestre_id, ue_id):
"""Desinscrit l'etudiant de tous les modules de cette UE dans ce semestre.""" """Desinscrit l'etudiant de tous les modules de cette UE dans ce semestre."""
sco_moduleimpl_inscriptions.do_etud_desinscrit_ue( sco_moduleimpl_inscriptions.do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id)
etudid, formsemestre_id, ue_id, REQUEST=REQUEST
)
return flask.redirect( return flask.redirect(
scu.ScoURL() scu.ScoURL()
+ "/Notes/moduleimpl_inscriptions_stats?formsemestre_id=" + "/Notes/moduleimpl_inscriptions_stats?formsemestre_id="
@ -1430,11 +1433,9 @@ def etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def etud_inscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None): def etud_inscrit_ue(etudid, formsemestre_id, ue_id):
"""Inscrit l'etudiant de tous les modules de cette UE dans ce semestre.""" """Inscrit l'etudiant de tous les modules de cette UE dans ce semestre."""
sco_moduleimpl_inscriptions.do_etud_inscrit_ue( sco_moduleimpl_inscriptions.do_etud_inscrit_ue(etudid, formsemestre_id, ue_id)
etudid, formsemestre_id, ue_id, REQUEST=REQUEST
)
return flask.redirect( return flask.redirect(
scu.ScoURL() scu.ScoURL()
+ "/Notes/moduleimpl_inscriptions_stats?formsemestre_id=" + "/Notes/moduleimpl_inscriptions_stats?formsemestre_id="
@ -1494,7 +1495,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoEnsView) @permission_required(Permission.ScoEnsView)
@scodoc7func @scodoc7func
def evaluation_delete(REQUEST, evaluation_id): def evaluation_delete(evaluation_id):
"""Form delete evaluation""" """Form delete evaluation"""
El = sco_evaluations.do_evaluation_list(args={"evaluation_id": evaluation_id}) El = sco_evaluations.do_evaluation_list(args={"evaluation_id": evaluation_id})
if not El: if not El:
@ -1538,7 +1539,7 @@ def evaluation_delete(REQUEST, evaluation_id):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
(("evaluation_id", {"input_type": "hidden"}),), (("evaluation_id", {"input_type": "hidden"}),),
initvalues=E, initvalues=E,
submitlabel="Confirmer la suppression", submitlabel="Confirmer la suppression",
@ -1578,10 +1579,10 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoEnsView) @permission_required(Permission.ScoEnsView)
@scodoc7func @scodoc7func
def evaluation_edit(evaluation_id, REQUEST): def evaluation_edit(evaluation_id):
"form edit evaluation" "form edit evaluation"
return sco_evaluations.evaluation_create_form( return sco_evaluations.evaluation_create_form(
evaluation_id=evaluation_id, REQUEST=REQUEST, edit=True evaluation_id=evaluation_id, edit=True
) )
@ -1589,10 +1590,10 @@ def evaluation_edit(evaluation_id, REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoEnsView) @permission_required(Permission.ScoEnsView)
@scodoc7func @scodoc7func
def evaluation_create(moduleimpl_id, REQUEST): def evaluation_create(moduleimpl_id):
"form create evaluation" "form create evaluation"
return sco_evaluations.evaluation_create_form( return sco_evaluations.evaluation_create_form(
moduleimpl_id=moduleimpl_id, REQUEST=REQUEST, edit=False moduleimpl_id=moduleimpl_id, edit=False
) )
@ -1600,9 +1601,9 @@ def evaluation_create(moduleimpl_id, REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def evaluation_listenotes(REQUEST=None): def evaluation_listenotes():
"""Affichage des notes d'une évaluation""" """Affichage des notes d'une évaluation"""
if REQUEST.form.get("format", "html") == "html": if request.args.get("format", "html") == "html":
H = html_sco_header.sco_header( H = html_sco_header.sco_header(
cssstyles=["css/verticalhisto.css"], cssstyles=["css/verticalhisto.css"],
javascripts=["js/etud_info.js"], javascripts=["js/etud_info.js"],
@ -1611,7 +1612,7 @@ def evaluation_listenotes(REQUEST=None):
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
else: else:
H, F = "", "" H, F = "", ""
B = sco_liste_notes.do_evaluation_listenotes(REQUEST) B = sco_liste_notes.do_evaluation_listenotes()
if H: if H:
return H + B + F return H + B + F
else: else:
@ -1685,10 +1686,10 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_bulletins_pdf(formsemestre_id, REQUEST, version="selectedevals"): def formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"):
"Publie les bulletins dans un classeur PDF" "Publie les bulletins dans un classeur PDF"
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, version=version
) )
return scu.sendPDFFile(pdfdoc, filename) return scu.sendPDFFile(pdfdoc, filename)
@ -1700,15 +1701,14 @@ _EXPL_BULL = """Versions des bulletins:<ul><li><bf>courte</bf>: moyennes des mod
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_bulletins_pdf_choice(REQUEST, formsemestre_id, version=None): def formsemestre_bulletins_pdf_choice(formsemestre_id, version=None):
"""Choix version puis envois classeur bulletins pdf""" """Choix version puis envois classeur bulletins pdf"""
if version: if version:
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, version=version
) )
return scu.sendPDFFile(pdfdoc, filename) return scu.sendPDFFile(pdfdoc, filename)
return formsemestre_bulletins_choice( return formsemestre_bulletins_choice(
REQUEST,
formsemestre_id, formsemestre_id,
title="Choisir la version des bulletins à générer", title="Choisir la version des bulletins à générer",
explanation=_EXPL_BULL, explanation=_EXPL_BULL,
@ -1719,11 +1719,9 @@ def formsemestre_bulletins_pdf_choice(REQUEST, formsemestre_id, version=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"): def etud_bulletins_pdf(etudid, version="selectedevals"):
"Publie tous les bulletins d'un etudiants dans un classeur PDF" "Publie tous les bulletins d'un etudiants dans un classeur PDF"
pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf( pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf(etudid, version=version)
etudid, REQUEST, version=version
)
return scu.sendPDFFile(pdfdoc, filename) return scu.sendPDFFile(pdfdoc, filename)
@ -1732,7 +1730,6 @@ def etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"):
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_bulletins_mailetuds_choice( def formsemestre_bulletins_mailetuds_choice(
REQUEST,
formsemestre_id, formsemestre_id,
version=None, version=None,
dialog_confirmed=False, dialog_confirmed=False,
@ -1754,7 +1751,6 @@ def formsemestre_bulletins_mailetuds_choice(
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>"""
return formsemestre_bulletins_choice( return formsemestre_bulletins_choice(
REQUEST,
formsemestre_id, formsemestre_id,
title="Choisir la version des bulletins à envoyer par mail", title="Choisir la version des bulletins à envoyer par mail",
explanation="Chaque étudiant ayant une adresse mail connue de ScoDoc recevra une copie PDF de son bulletin de notes, dans la version choisie.</p><p>" explanation="Chaque étudiant ayant une adresse mail connue de ScoDoc recevra une copie PDF de son bulletin de notes, dans la version choisie.</p><p>"
@ -1765,7 +1761,7 @@ def formsemestre_bulletins_mailetuds_choice(
# not published # not published
def formsemestre_bulletins_choice( def formsemestre_bulletins_choice(
REQUEST, formsemestre_id, title="", explanation="", choose_mail=False formsemestre_id, title="", explanation="", choose_mail=False
): ):
"""Choix d'une version de bulletin""" """Choix d'une version de bulletin"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
@ -1802,7 +1798,6 @@ def formsemestre_bulletins_choice(
@scodoc7func @scodoc7func
def formsemestre_bulletins_mailetuds( def formsemestre_bulletins_mailetuds(
formsemestre_id, formsemestre_id,
REQUEST,
version="long", version="long",
dialog_confirmed=False, dialog_confirmed=False,
prefer_mail_perso=0, prefer_mail_perso=0,
@ -1837,7 +1832,6 @@ def formsemestre_bulletins_mailetuds(
prefer_mail_perso=prefer_mail_perso, prefer_mail_perso=prefer_mail_perso,
format="pdfmail", format="pdfmail",
nohtml=True, nohtml=True,
REQUEST=REQUEST,
) )
if h: if h:
nb_send += 1 nb_send += 1
@ -1867,7 +1861,6 @@ def appreciation_add_form(
formsemestre_id=None, formsemestre_id=None,
id=None, # si id, edit id=None, # si id, edit
suppress=False, # si true, supress id suppress=False, # si true, supress id
REQUEST=None,
): ):
"form ajout ou edition d'une appreciation" "form ajout ou edition d'une appreciation"
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -1878,8 +1871,9 @@ def appreciation_add_form(
app = apps[0] app = apps[0]
formsemestre_id = app["formsemestre_id"] formsemestre_id = app["formsemestre_id"]
etudid = app["etudid"] etudid = app["etudid"]
if "edit" in REQUEST.form: vals = request.form if request.method == "POST" else request.args
edit = int(REQUEST.form["edit"]) if "edit" in vals:
edit = int(vals["edit"])
elif id: elif id:
edit = 1 edit = 1
else: else:
@ -1928,7 +1922,7 @@ def appreciation_add_form(
initvalues = {} initvalues = {}
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
initvalues=initvalues, initvalues=initvalues,
cancelbutton="Annuler", cancelbutton="Annuler",
@ -1978,7 +1972,6 @@ def formsemestre_validation_etud_form(
check=0, check=0,
desturl="", desturl="",
sortcol=None, sortcol=None,
REQUEST=None,
): ):
"Formulaire choix jury pour un étudiant" "Formulaire choix jury pour un étudiant"
readonly = not sco_permissions_check.can_validate_sem(formsemestre_id) readonly = not sco_permissions_check.can_validate_sem(formsemestre_id)
@ -1990,7 +1983,6 @@ def formsemestre_validation_etud_form(
readonly=readonly, readonly=readonly,
desturl=desturl, desturl=desturl,
sortcol=sortcol, sortcol=sortcol,
REQUEST=REQUEST,
) )
@ -2004,7 +1996,6 @@ def formsemestre_validation_etud(
codechoice=None, codechoice=None,
desturl="", desturl="",
sortcol=None, sortcol=None,
REQUEST=None,
): ):
"Enregistre choix jury pour un étudiant" "Enregistre choix jury pour un étudiant"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
@ -2019,7 +2010,6 @@ def formsemestre_validation_etud(
codechoice=codechoice, codechoice=codechoice,
desturl=desturl, desturl=desturl,
sortcol=sortcol, sortcol=sortcol,
REQUEST=REQUEST,
) )
@ -2036,7 +2026,6 @@ def formsemestre_validation_etud_manu(
assidu=False, assidu=False,
desturl="", desturl="",
sortcol=None, sortcol=None,
REQUEST=None,
): ):
"Enregistre choix jury pour un étudiant" "Enregistre choix jury pour un étudiant"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
@ -2054,7 +2043,6 @@ def formsemestre_validation_etud_manu(
assidu=assidu, assidu=assidu,
desturl=desturl, desturl=desturl,
sortcol=sortcol, sortcol=sortcol,
REQUEST=REQUEST,
) )
@ -2062,7 +2050,7 @@ def formsemestre_validation_etud_manu(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_validate_previous_ue(formsemestre_id, etudid=None, REQUEST=None): def formsemestre_validate_previous_ue(formsemestre_id, etudid=None):
"Form. saisie UE validée hors ScoDoc" "Form. saisie UE validée hors ScoDoc"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
return scu.confirm_dialog( return scu.confirm_dialog(
@ -2070,7 +2058,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid=None, REQUEST=None
dest_url=scu.ScoURL(), dest_url=scu.ScoURL(),
) )
return sco_formsemestre_validation.formsemestre_validate_previous_ue( return sco_formsemestre_validation.formsemestre_validate_previous_ue(
formsemestre_id, etudid, REQUEST=REQUEST formsemestre_id, etudid
) )
@ -2086,7 +2074,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid=None, REQUEST=None): def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid=None):
"Form. edition UE semestre extérieur" "Form. edition UE semestre extérieur"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
return scu.confirm_dialog( return scu.confirm_dialog(
@ -2094,7 +2082,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid=None, REQUEST=N
dest_url=scu.ScoURL(), dest_url=scu.ScoURL(),
) )
return sco_formsemestre_exterieurs.formsemestre_ext_edit_ue_validations( return sco_formsemestre_exterieurs.formsemestre_ext_edit_ue_validations(
formsemestre_id, etudid, REQUEST=REQUEST formsemestre_id, etudid
) )
@ -2109,7 +2097,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id, REQUEST=None): def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id):
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre""" """Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
return scu.confirm_dialog( return scu.confirm_dialog(
@ -2117,7 +2105,7 @@ def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id, REQUEST=None):
dest_url=scu.ScoURL(), dest_url=scu.ScoURL(),
) )
return sco_formsemestre_validation.etud_ue_suppress_validation( return sco_formsemestre_validation.etud_ue_suppress_validation(
etudid, formsemestre_id, ue_id, REQUEST=REQUEST etudid, formsemestre_id, ue_id
) )
@ -2125,7 +2113,7 @@ def etud_ue_suppress_validation(etudid, formsemestre_id, ue_id, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_validation_auto(formsemestre_id, REQUEST): def formsemestre_validation_auto(formsemestre_id):
"Formulaire saisie automatisee des decisions d'un semestre" "Formulaire saisie automatisee des decisions d'un semestre"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
return scu.confirm_dialog( return scu.confirm_dialog(
@ -2133,16 +2121,14 @@ def formsemestre_validation_auto(formsemestre_id, REQUEST):
dest_url=scu.ScoURL(), dest_url=scu.ScoURL(),
) )
return sco_formsemestre_validation.formsemestre_validation_auto( return sco_formsemestre_validation.formsemestre_validation_auto(formsemestre_id)
formsemestre_id, REQUEST
)
@bp.route("/do_formsemestre_validation_auto") @bp.route("/do_formsemestre_validation_auto")
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def do_formsemestre_validation_auto(formsemestre_id, REQUEST): def do_formsemestre_validation_auto(formsemestre_id):
"Formulaire saisie automatisee des decisions d'un semestre" "Formulaire saisie automatisee des decisions d'un semestre"
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
return scu.confirm_dialog( return scu.confirm_dialog(
@ -2150,9 +2136,7 @@ def do_formsemestre_validation_auto(formsemestre_id, REQUEST):
dest_url=scu.ScoURL(), dest_url=scu.ScoURL(),
) )
return sco_formsemestre_validation.do_formsemestre_validation_auto( return sco_formsemestre_validation.do_formsemestre_validation_auto(formsemestre_id)
formsemestre_id, REQUEST
)
@bp.route("/formsemestre_validation_suppress_etud", methods=["GET", "POST"]) @bp.route("/formsemestre_validation_suppress_etud", methods=["GET", "POST"])
@ -2160,7 +2144,7 @@ def do_formsemestre_validation_auto(formsemestre_id, REQUEST):
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_validation_suppress_etud( def formsemestre_validation_suppress_etud(
formsemestre_id, etudid, REQUEST=None, dialog_confirmed=False formsemestre_id, etudid, dialog_confirmed=False
): ):
"""Suppression des decisions de jury pour un etudiant.""" """Suppression des decisions de jury pour un etudiant."""
if not sco_permissions_check.can_validate_sem(formsemestre_id): if not sco_permissions_check.can_validate_sem(formsemestre_id):
@ -2407,7 +2391,7 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoImplement) @permission_required(Permission.ScoImplement)
@scodoc7func @scodoc7func
def check_sem_integrity(formsemestre_id, REQUEST, fix=False): def check_sem_integrity(formsemestre_id, fix=False):
"""Debug. """Debug.
Check that ue and module formations are consistents Check that ue and module formations are consistents
""" """
@ -2476,7 +2460,7 @@ def check_sem_integrity(formsemestre_id, REQUEST, fix=False):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def check_form_integrity(formation_id, fix=False, REQUEST=None): def check_form_integrity(formation_id, fix=False):
"debug" "debug"
log("check_form_integrity: formation_id=%s fix=%s" % (formation_id, fix)) log("check_form_integrity: formation_id=%s fix=%s" % (formation_id, fix))
ues = sco_edit_ue.do_ue_list(args={"formation_id": formation_id}) ues = sco_edit_ue.do_ue_list(args={"formation_id": formation_id})
@ -2514,7 +2498,7 @@ def check_form_integrity(formation_id, fix=False, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def check_formsemestre_integrity(formsemestre_id, REQUEST=None): def check_formsemestre_integrity(formsemestre_id):
"debug" "debug"
log("check_formsemestre_integrity: formsemestre_id=%s" % (formsemestre_id)) log("check_formsemestre_integrity: formsemestre_id=%s" % (formsemestre_id))
# verifie que tous les moduleimpl d'un formsemestre # verifie que tous les moduleimpl d'un formsemestre
@ -2564,14 +2548,14 @@ def check_formsemestre_integrity(formsemestre_id, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def check_integrity_all(REQUEST=None): def check_integrity_all():
"debug: verifie tous les semestres et tt les formations" "debug: verifie tous les semestres et tt les formations"
# formations # formations
for F in sco_formations.formation_list(): for F in sco_formations.formation_list():
check_form_integrity(F["formation_id"], REQUEST=REQUEST) check_form_integrity(F["formation_id"])
# semestres # semestres
for sem in sco_formsemestre.do_formsemestre_list(): for sem in sco_formsemestre.do_formsemestre_list():
check_formsemestre_integrity(sem["formsemestre_id"], REQUEST=REQUEST) check_formsemestre_integrity(sem["formsemestre_id"])
return ( return (
html_sco_header.sco_header() html_sco_header.sco_header()
+ "<p>empty page: see logs and mails</p>" + "<p>empty page: see logs and mails</p>"
@ -2582,11 +2566,32 @@ def check_integrity_all(REQUEST=None):
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Support for legacy ScoDoc 7 API # Support for legacy ScoDoc 7 API
# -------------------------------------------------------------------- # --------------------------------------------------------------------
sco_publish( @bp.route("/do_moduleimpl_list")
"/do_moduleimpl_list", sco_moduleimpl.do_moduleimpl_list, Permission.ScoView @scodoc
) @permission_required(Permission.ScoView)
sco_publish( @scodoc7func
"/do_moduleimpl_withmodule_list", def do_moduleimpl_list(
sco_moduleimpl.do_moduleimpl_withmodule_list, moduleimpl_id=None, formsemestre_id=None, module_id=None, format="json"
Permission.ScoView, ):
) data = sco_moduleimpl.do_moduleimpl_list(
moduleimpl_id=moduleimpl_id,
formsemestre_id=formsemestre_id,
module_id=module_id,
)
return scu.sendResult(data, format=format)
@bp.route("/do_moduleimpl_withmodule_list")
@scodoc
@permission_required(Permission.ScoView)
@scodoc7func
def do_moduleimpl_withmodule_list(
moduleimpl_id=None, formsemestre_id=None, module_id=None
):
"""API ScoDoc 7"""
data = sco_moduleimpl.do_moduleimpl_withmodule_list(
moduleimpl_id=moduleimpl_id,
formsemestre_id=formsemestre_id,
module_id=module_id,
)
return scu.sendResult(data, format=format)

View File

@ -139,9 +139,7 @@ def get_etud_dept():
) # pour compat anciens clients PHP ) # pour compat anciens clients PHP
@scodoc @scodoc
@scodoc7func @scodoc7func
def search_inscr_etud_by_nip( def search_inscr_etud_by_nip(code_nip, format="json", __ac_name="", __ac_password=""):
code_nip, REQUEST=None, format="json", __ac_name="", __ac_password=""
):
auth_ok = False auth_ok = False
user_name = __ac_name user_name = __ac_name
user_password = __ac_password user_password = __ac_password
@ -153,9 +151,7 @@ def search_inscr_etud_by_nip(
if not auth_ok: if not auth_ok:
abort(403) abort(403)
else: else:
return sco_find_etud.search_inscr_etud_by_nip( return sco_find_etud.search_inscr_etud_by_nip(code_nip=code_nip, format=format)
code_nip=code_nip, REQUEST=REQUEST, format=format
)
@bp.route("/ScoDoc/about") @bp.route("/ScoDoc/about")

View File

@ -31,23 +31,16 @@ issu de ScoDoc7 / ZScolar.py
Emmanuel Viennet, 2021 Emmanuel Viennet, 2021
""" """
import os import os
import sys
import time import time
from io import StringIO
from zipfile import ZipFile
import psycopg2
import flask import flask
from flask import jsonify, url_for, flash, redirect, render_template from flask import jsonify, url_for, flash, redirect, render_template, make_response
from flask import current_app, g, request from flask import current_app, g, request
from flask_login import current_user from flask_login import current_user
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed from flask_wtf.file import FileField, FileAllowed
from wtforms import SubmitField from wtforms import SubmitField
from config import Config
from app.decorators import ( from app.decorators import (
scodoc, scodoc,
scodoc7func, scodoc7func,
@ -137,16 +130,16 @@ def sco_publish(route, function, permission, methods=["GET"]):
@scodoc @scodoc
@permission_required(Permission.ScoChangePreferences) @permission_required(Permission.ScoChangePreferences)
@scodoc7func @scodoc7func
def edit_preferences(REQUEST): def edit_preferences():
"""Edit global preferences (lien "Paramétrage" département)""" """Edit global preferences (lien "Paramétrage" département)"""
return sco_preferences.get_base_preferences().edit(REQUEST=REQUEST) return sco_preferences.get_base_preferences().edit()
@bp.route("/formsemestre_edit_preferences", methods=["GET", "POST"]) @bp.route("/formsemestre_edit_preferences", methods=["GET", "POST"])
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def formsemestre_edit_preferences(formsemestre_id, REQUEST): def formsemestre_edit_preferences(formsemestre_id):
"""Edit preferences for a semestre""" """Edit preferences for a semestre"""
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
ok = ( ok = (
@ -154,9 +147,7 @@ def formsemestre_edit_preferences(formsemestre_id, REQUEST):
or ((current_user.id in sem["responsables"]) and sem["resp_can_edit"]) or ((current_user.id in sem["responsables"]) and sem["resp_can_edit"])
) and (sem["etat"]) ) and (sem["etat"])
if ok: if ok:
return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit( return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit()
REQUEST=REQUEST
)
else: else:
raise AccessDenied( raise AccessDenied(
"Modification impossible pour %s" % current_user.get_nomplogin() "Modification impossible pour %s" % current_user.get_nomplogin()
@ -167,10 +158,11 @@ def formsemestre_edit_preferences(formsemestre_id, REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def doc_preferences(REQUEST): def doc_preferences():
"""List preferences for wiki documentation""" """List preferences for wiki documentation"""
REQUEST.RESPONSE.setHeader("content-type", "text/plain") response = make_response(sco_preferences.doc_preferences())
return sco_preferences.doc_preferences() response.headers["Content-Type"] = "text/plain"
return response
class DeptLogosConfigurationForm(FlaskForm): class DeptLogosConfigurationForm(FlaskForm):
@ -244,7 +236,7 @@ def config_logos(scodoc_dept):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def showEtudLog(etudid, format="html", REQUEST=None): def showEtudLog(etudid, format="html"):
"""Display log of operations on this student""" """Display log of operations on this student"""
etud = sco_etud.get_etud_info(filled=True)[0] etud = sco_etud.get_etud_info(filled=True)[0]
@ -285,10 +277,8 @@ def showEtudLog(etudid, format="html", REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def index_html(REQUEST=None, showcodes=0, showsemtable=0): def index_html(showcodes=0, showsemtable=0):
return sco_dept.index_html( return sco_dept.index_html(showcodes=showcodes, showsemtable=showsemtable)
REQUEST=REQUEST, showcodes=showcodes, showsemtable=showsemtable
)
sco_publish( sco_publish(
@ -326,10 +316,10 @@ sco_publish(
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def getEtudInfo(etudid=False, code_nip=False, filled=False, REQUEST=None, format=None): def getEtudInfo(etudid=False, code_nip=False, filled=False, format=None):
"""infos sur un etudiant (API) """infos sur un etudiant (API)
On peut specifier etudid ou code_nip On peut specifier etudid ou code_nip
ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine ou bien cherche dans les arguments de la requête: etudid, code_nip, code_ine
(dans cet ordre). (dans cet ordre).
""" """
etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled) etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled)
@ -371,7 +361,7 @@ def search_etud_by_name():
@scodoc @scodoc
@permission_required_compat_scodoc7(Permission.ScoView) @permission_required_compat_scodoc7(Permission.ScoView)
@scodoc7func @scodoc7func
def etud_info(etudid=None, format="xml", REQUEST=None): def etud_info(etudid=None, format="xml"):
"Donne les informations sur un etudiant" "Donne les informations sur un etudiant"
t0 = time.time() t0 = time.time()
args = sco_etud.make_etud_args(etudid=etudid) args = sco_etud.make_etud_args(etudid=etudid)
@ -564,7 +554,7 @@ def doAddAnnotation(etudid, comment):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def doSuppressAnnotation(etudid, annotation_id, REQUEST): def doSuppressAnnotation(etudid, annotation_id):
"""Suppression annotation.""" """Suppression annotation."""
if not sco_permissions_check.can_suppress_annotation(annotation_id): if not sco_permissions_check.can_suppress_annotation(annotation_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -592,7 +582,7 @@ def doSuppressAnnotation(etudid, annotation_id, REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoEtudChangeAdr) @permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func @scodoc7func
def formChangeCoordonnees(etudid, REQUEST): def formChangeCoordonnees(etudid):
"edit coordonnees etudiant" "edit coordonnees etudiant"
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
@ -611,7 +601,7 @@ def formChangeCoordonnees(etudid, REQUEST):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("adresse_id", {"input_type": "hidden"}), ("adresse_id", {"input_type": "hidden"}),
("etudid", {"input_type": "hidden"}), ("etudid", {"input_type": "hidden"}),
@ -778,7 +768,7 @@ sco_publish("/etud_photo_html", sco_photos.etud_photo_html, Permission.ScoView)
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def etud_photo_orig_page(etudid=None, REQUEST=None): def etud_photo_orig_page(etudid=None):
"Page with photo in orig. size" "Page with photo in orig. size"
etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0]
H = [ H = [
@ -797,7 +787,7 @@ def etud_photo_orig_page(etudid=None, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudChangeAdr) @permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func @scodoc7func
def formChangePhoto(etudid=None, REQUEST=None): def formChangePhoto(etudid=None):
"""Formulaire changement photo étudiant""" """Formulaire changement photo étudiant"""
etud = sco_etud.get_etud_info(filled=True)[0] etud = sco_etud.get_etud_info(filled=True)[0]
if sco_photos.etud_photo_is_local(etud): if sco_photos.etud_photo_is_local(etud):
@ -817,7 +807,7 @@ def formChangePhoto(etudid=None, REQUEST=None):
] ]
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
("etudid", {"default": etudid, "input_type": "hidden"}), ("etudid", {"default": etudid, "input_type": "hidden"}),
( (
@ -855,7 +845,7 @@ def formChangePhoto(etudid=None, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudChangeAdr) @permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func @scodoc7func
def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False): def formSuppressPhoto(etudid=None, dialog_confirmed=False):
"""Formulaire suppression photo étudiant""" """Formulaire suppression photo étudiant"""
etud = sco_etud.get_etud_info(filled=True)[0] etud = sco_etud.get_etud_info(filled=True)[0]
if not dialog_confirmed: if not dialog_confirmed:
@ -868,7 +858,7 @@ def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False):
parameters={"etudid": etudid}, parameters={"etudid": etudid},
) )
sco_photos.suppress_photo(etud, REQUEST=REQUEST) sco_photos.suppress_photo(etud)
return flask.redirect( return flask.redirect(
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
@ -880,12 +870,11 @@ def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def formDem(etudid, formsemestre_id, REQUEST): def formDem(etudid, formsemestre_id):
"Formulaire Démission Etudiant" "Formulaire Démission Etudiant"
return _formDem_of_Def( return _formDem_of_Def(
etudid, etudid,
formsemestre_id, formsemestre_id,
REQUEST=REQUEST,
operation_name="Démission", operation_name="Démission",
operation_method="doDemEtudiant", operation_method="doDemEtudiant",
) )
@ -895,12 +884,11 @@ def formDem(etudid, formsemestre_id, REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def formDef(etudid, formsemestre_id, REQUEST): def formDef(etudid, formsemestre_id):
"Formulaire Défaillance Etudiant" "Formulaire Défaillance Etudiant"
return _formDem_of_Def( return _formDem_of_Def(
etudid, etudid,
formsemestre_id, formsemestre_id,
REQUEST=REQUEST,
operation_name="Défaillance", operation_name="Défaillance",
operation_method="doDefEtudiant", operation_method="doDefEtudiant",
) )
@ -909,7 +897,6 @@ def formDef(etudid, formsemestre_id, REQUEST):
def _formDem_of_Def( def _formDem_of_Def(
etudid, etudid,
formsemestre_id, formsemestre_id,
REQUEST=None,
operation_name="", operation_name="",
operation_method="", operation_method="",
): ):
@ -955,7 +942,7 @@ def _formDem_of_Def(
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def doDemEtudiant(etudid, formsemestre_id, event_date=None, REQUEST=None): def doDemEtudiant(etudid, formsemestre_id, event_date=None):
"Déclare la démission d'un etudiant dans le semestre" "Déclare la démission d'un etudiant dans le semestre"
return _do_dem_or_def_etud( return _do_dem_or_def_etud(
etudid, etudid,
@ -964,7 +951,6 @@ def doDemEtudiant(etudid, formsemestre_id, event_date=None, REQUEST=None):
etat_new="D", etat_new="D",
operation_method="demEtudiant", operation_method="demEtudiant",
event_type="DEMISSION", event_type="DEMISSION",
REQUEST=REQUEST,
) )
@ -972,7 +958,7 @@ def doDemEtudiant(etudid, formsemestre_id, event_date=None, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def doDefEtudiant(etudid, formsemestre_id, event_date=None, REQUEST=None): def doDefEtudiant(etudid, formsemestre_id, event_date=None):
"Déclare la défaillance d'un etudiant dans le semestre" "Déclare la défaillance d'un etudiant dans le semestre"
return _do_dem_or_def_etud( return _do_dem_or_def_etud(
etudid, etudid,
@ -981,7 +967,6 @@ def doDefEtudiant(etudid, formsemestre_id, event_date=None, REQUEST=None):
etat_new=sco_codes_parcours.DEF, etat_new=sco_codes_parcours.DEF,
operation_method="defailleEtudiant", operation_method="defailleEtudiant",
event_type="DEFAILLANCE", event_type="DEFAILLANCE",
REQUEST=REQUEST,
) )
@ -992,7 +977,7 @@ def _do_dem_or_def_etud(
etat_new="D", # 'D' or DEF etat_new="D", # 'D' or DEF
operation_method="demEtudiant", operation_method="demEtudiant",
event_type="DEMISSION", event_type="DEMISSION",
REQUEST=None, redirect=True,
): ):
"Démission ou défaillance d'un étudiant" "Démission ou défaillance d'un étudiant"
# marque 'D' ou DEF dans l'inscription au semestre et ajoute # marque 'D' ou DEF dans l'inscription au semestre et ajoute
@ -1022,7 +1007,7 @@ def _do_dem_or_def_etud(
"event_type": event_type, "event_type": event_type,
}, },
) )
if REQUEST: if redirect:
return flask.redirect( return flask.redirect(
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
) )
@ -1032,9 +1017,7 @@ def _do_dem_or_def_etud(
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def doCancelDem( def doCancelDem(etudid, formsemestre_id, dialog_confirmed=False, args=None):
etudid, formsemestre_id, dialog_confirmed=False, args=None, REQUEST=None
):
"Annule une démission" "Annule une démission"
return _do_cancel_dem_or_def( return _do_cancel_dem_or_def(
etudid, etudid,
@ -1046,7 +1029,6 @@ def doCancelDem(
etat_new="I", etat_new="I",
operation_method="cancelDem", operation_method="cancelDem",
event_type="DEMISSION", event_type="DEMISSION",
REQUEST=REQUEST,
) )
@ -1054,9 +1036,7 @@ def doCancelDem(
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def doCancelDef( def doCancelDef(etudid, formsemestre_id, dialog_confirmed=False, args=None):
etudid, formsemestre_id, dialog_confirmed=False, args=None, REQUEST=None
):
"Annule la défaillance de l'étudiant" "Annule la défaillance de l'étudiant"
return _do_cancel_dem_or_def( return _do_cancel_dem_or_def(
etudid, etudid,
@ -1068,7 +1048,6 @@ def doCancelDef(
etat_new="I", etat_new="I",
operation_method="cancelDef", operation_method="cancelDef",
event_type="DEFAILLANCE", event_type="DEFAILLANCE",
REQUEST=REQUEST,
) )
@ -1082,7 +1061,6 @@ def _do_cancel_dem_or_def(
etat_new="I", etat_new="I",
operation_method="cancelDem", operation_method="cancelDem",
event_type="DEMISSION", event_type="DEMISSION",
REQUEST=None,
): ):
"Annule une demission ou une défaillance" "Annule une demission ou une défaillance"
# check lock # check lock
@ -1138,25 +1116,26 @@ def _do_cancel_dem_or_def(
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def etudident_create_form(REQUEST=None): def etudident_create_form():
"formulaire creation individuelle etudiant" "formulaire creation individuelle etudiant"
return _etudident_create_or_edit_form(REQUEST, edit=False) return _etudident_create_or_edit_form(edit=False)
@bp.route("/etudident_edit_form", methods=["GET", "POST"]) @bp.route("/etudident_edit_form", methods=["GET", "POST"])
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def etudident_edit_form(REQUEST=None): def etudident_edit_form():
"formulaire edition individuelle etudiant" "formulaire edition individuelle etudiant"
return _etudident_create_or_edit_form(REQUEST, edit=True) return _etudident_create_or_edit_form(edit=True)
def _etudident_create_or_edit_form(REQUEST, edit): def _etudident_create_or_edit_form(edit):
"Le formulaire HTML" "Le formulaire HTML"
H = [html_sco_header.sco_header(init_jquery_ui=True)] H = [html_sco_header.sco_header(init_jquery_ui=True)]
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
etudid = REQUEST.form.get("etudid", None) vals = request.form if request.method == "POST" else request.args
etudid = vals.get("etudid", None)
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
descr = [] descr = []
if not edit: if not edit:
@ -1198,14 +1177,15 @@ def _etudident_create_or_edit_form(REQUEST, edit):
# except ValueError: # except ValueError:
# infos = None # infos = None
# pass # XXX a terminer # pass # XXX a terminer
nom = REQUEST.form.get("nom", None) vals = request.form if request.method == "POST" else request.args
nom = vals.get("nom", None)
if nom is None: if nom is None:
nom = initvalues.get("nom", None) nom = initvalues.get("nom", None)
if nom is None: if nom is None:
infos = [] infos = []
else: else:
prenom = REQUEST.form.get("prenom", "") prenom = vals.get("prenom", "")
if REQUEST.form.get("tf_submitted", False) and not prenom: if vals.get("tf_submitted", False) and not prenom:
prenom = initvalues.get("prenom", "") prenom = initvalues.get("prenom", "")
infos = sco_portal_apogee.get_infos_apogee(nom, prenom) infos = sco_portal_apogee.get_infos_apogee(nom, prenom)
@ -1490,7 +1470,7 @@ def _etudident_create_or_edit_form(REQUEST, edit):
initvalues["dont_check_homonyms"] = False initvalues["dont_check_homonyms"] = False
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
descr, descr,
submitlabel=submitlabel, submitlabel=submitlabel,
cancelbutton="Re-interroger Apogee", cancelbutton="Re-interroger Apogee",
@ -1533,11 +1513,11 @@ def _etudident_create_or_edit_form(REQUEST, edit):
) )
if not edit: if not edit:
etud = sco_etud.create_etud(cnx, args=tf[2], REQUEST=REQUEST) etud = sco_etud.create_etud(cnx, args=tf[2])
etudid = etud["etudid"] etudid = etud["etudid"]
else: else:
# modif d'un etudiant # modif d'un etudiant
sco_etud.etudident_edit(cnx, tf[2], REQUEST=REQUEST) sco_etud.etudident_edit(cnx, tf[2])
etud = sco_etud.etudident_list(cnx, {"etudid": etudid})[0] etud = sco_etud.etudident_list(cnx, {"etudid": etudid})[0]
sco_etud.fill_etuds_info([etud]) sco_etud.fill_etuds_info([etud])
# Inval semesters with this student: # Inval semesters with this student:
@ -1554,7 +1534,7 @@ def _etudident_create_or_edit_form(REQUEST, edit):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def etudident_delete(etudid, dialog_confirmed=False, REQUEST=None): def etudident_delete(etudid, dialog_confirmed=False):
"Delete a student" "Delete a student"
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
etuds = sco_etud.etudident_list(cnx, {"etudid": etudid}) etuds = sco_etud.etudident_list(cnx, {"etudid": etudid})
@ -1627,7 +1607,7 @@ def etudident_delete(etudid, dialog_confirmed=False, REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def check_group_apogee(group_id, REQUEST=None, etat=None, fix=False, fixmail=False): def check_group_apogee(group_id, etat=None, fix=False, fixmail=False):
"""Verification des codes Apogee et mail de tout un groupe. """Verification des codes Apogee et mail de tout un groupe.
Si fix == True, change les codes avec Apogée. Si fix == True, change les codes avec Apogée.
@ -1774,7 +1754,7 @@ def check_group_apogee(group_id, REQUEST=None, etat=None, fix=False, fixmail=Fal
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def form_students_import_excel(REQUEST, formsemestre_id=None): def form_students_import_excel(formsemestre_id=None):
"formulaire import xls" "formulaire import xls"
if formsemestre_id: if formsemestre_id:
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
@ -1849,7 +1829,7 @@ def form_students_import_excel(REQUEST, formsemestre_id=None):
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"csvfile", "csvfile",
@ -1908,7 +1888,6 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés
else: else:
return sco_import_etuds.students_import_excel( return sco_import_etuds.students_import_excel(
tf[2]["csvfile"], tf[2]["csvfile"],
REQUEST=REQUEST,
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
check_homonyms=tf[2]["check_homonyms"], check_homonyms=tf[2]["check_homonyms"],
require_ine=tf[2]["require_ine"], require_ine=tf[2]["require_ine"],
@ -1919,7 +1898,7 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés
@scodoc @scodoc
@permission_required(Permission.ScoEtudInscrit) @permission_required(Permission.ScoEtudInscrit)
@scodoc7func @scodoc7func
def import_generate_excel_sample(REQUEST, with_codesemestre="1"): def import_generate_excel_sample(with_codesemestre="1"):
"une feuille excel pour importation etudiants" "une feuille excel pour importation etudiants"
if with_codesemestre: if with_codesemestre:
with_codesemestre = int(with_codesemestre) with_codesemestre = int(with_codesemestre)
@ -1932,7 +1911,7 @@ def import_generate_excel_sample(REQUEST, with_codesemestre="1"):
return scu.send_file( return scu.send_file(
data, "ImportEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE data, "ImportEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE
) )
# return sco_excel.send_excel_file(REQUEST, data, "ImportEtudiants" + scu.XLSX_SUFFIX) # return sco_excel.send_excel_file(data, "ImportEtudiants" + scu.XLSX_SUFFIX)
# --- Données admission # --- Données admission
@ -1940,7 +1919,7 @@ def import_generate_excel_sample(REQUEST, with_codesemestre="1"):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def import_generate_admission_sample(REQUEST, formsemestre_id): def import_generate_admission_sample(formsemestre_id):
"une feuille excel pour importation données admissions" "une feuille excel pour importation données admissions"
group = sco_groups.get_group(sco_groups.get_default_group(formsemestre_id)) group = sco_groups.get_group(sco_groups.get_default_group(formsemestre_id))
fmt = sco_import_etuds.sco_import_format() fmt = sco_import_etuds.sco_import_format()
@ -1953,7 +1932,7 @@ def import_generate_admission_sample(REQUEST, formsemestre_id):
return scu.send_file( return scu.send_file(
data, "AdmissionEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE data, "AdmissionEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE
) )
# return sco_excel.send_excel_file(REQUEST, data, "AdmissionEtudiants" + scu.XLSX_SUFFIX) # return sco_excel.send_excel_file(data, "AdmissionEtudiants" + scu.XLSX_SUFFIX)
# --- Données admission depuis fichier excel (version nov 2016) # --- Données admission depuis fichier excel (version nov 2016)
@ -1961,7 +1940,7 @@ def import_generate_admission_sample(REQUEST, formsemestre_id):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def form_students_import_infos_admissions(REQUEST, formsemestre_id=None): def form_students_import_infos_admissions(formsemestre_id=None):
"formulaire import xls" "formulaire import xls"
authuser = current_user authuser = current_user
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
@ -2018,7 +1997,7 @@ def form_students_import_infos_admissions(REQUEST, formsemestre_id=None):
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"csvfile", "csvfile",
@ -2059,7 +2038,6 @@ def form_students_import_infos_admissions(REQUEST, formsemestre_id=None):
return sco_import_etuds.students_import_admission( return sco_import_etuds.students_import_admission(
tf[2]["csvfile"], tf[2]["csvfile"],
type_admission=tf[2]["type_admission"], type_admission=tf[2]["type_admission"],
REQUEST=REQUEST,
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
) )
@ -2068,9 +2046,7 @@ def form_students_import_infos_admissions(REQUEST, formsemestre_id=None):
@scodoc @scodoc
@permission_required(Permission.ScoEtudChangeAdr) @permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func @scodoc7func
def formsemestre_import_etud_admission( def formsemestre_import_etud_admission(formsemestre_id, import_email=True):
formsemestre_id, import_email=True, REQUEST=None
):
"""Reimporte donnees admissions par synchro Portail Apogée""" """Reimporte donnees admissions par synchro Portail Apogée"""
( (
no_nip, no_nip,

View File

@ -73,9 +73,8 @@ from app.views import users_bp as bp
@scodoc @scodoc
@permission_required(Permission.ScoUsersView) @permission_required(Permission.ScoUsersView)
@scodoc7func @scodoc7func
def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"): def index_html(all_depts=False, with_inactives=False, format="html"):
return sco_users.index_html( return sco_users.index_html(
REQUEST=REQUEST,
all_depts=all_depts, all_depts=all_depts,
with_inactives=with_inactives, with_inactives=with_inactives,
format=format, format=format,
@ -86,7 +85,7 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"):
@scodoc @scodoc
@permission_required(Permission.ScoUsersView) @permission_required(Permission.ScoUsersView)
@scodoc7func @scodoc7func
def user_info(user_name, format="json", REQUEST=None): def user_info(user_name, format="json"):
info = sco_users.user_info(user_name) info = sco_users.user_info(user_name)
return scu.sendResult(info, name="user", format=format) return scu.sendResult(info, name="user", format=format)
@ -95,7 +94,7 @@ def user_info(user_name, format="json", REQUEST=None):
@scodoc @scodoc
@permission_required(Permission.ScoUsersAdmin) @permission_required(Permission.ScoUsersAdmin)
@scodoc7func @scodoc7func
def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1): def create_user_form(user_name=None, edit=0, all_roles=1):
"form. création ou edition utilisateur" "form. création ou edition utilisateur"
auth_dept = current_user.dept auth_dept = current_user.dept
initvalues = {} initvalues = {}
@ -331,19 +330,18 @@ def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1):
}, },
), ),
] ]
if "tf_submitted" in REQUEST.form and not "roles" in REQUEST.form: vals = request.form if request.method == "POST" else request.args
REQUEST.form["roles"] = [] if "tf_submitted" in vals and not "roles" in vals:
if "tf_submitted" in REQUEST.form: vals["roles"] = []
if "tf_submitted" in vals:
# Ajoute roles existants mais non modifiables (disabled dans le form) # Ajoute roles existants mais non modifiables (disabled dans le form)
REQUEST.form["roles"] = list( vals["roles"] = list(
set(REQUEST.form["roles"]).union( set(vals["roles"]).union(orig_roles_strings - editable_roles_strings)
orig_roles_strings - editable_roles_strings
)
) )
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, vals,
descr, descr,
initvalues=initvalues, initvalues=initvalues,
submitlabel=submitlabel, submitlabel=submitlabel,
@ -356,8 +354,8 @@ def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1):
else: else:
vals = tf[2] vals = tf[2]
roles = set(vals["roles"]).intersection(editable_roles_strings) roles = set(vals["roles"]).intersection(editable_roles_strings)
if "edit" in REQUEST.form: if "edit" in vals:
edit = int(REQUEST.form["edit"]) edit = int(vals["edit"])
else: else:
edit = 0 edit = 0
try: try:
@ -485,7 +483,7 @@ def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1):
@scodoc @scodoc
@permission_required(Permission.ScoUsersAdmin) @permission_required(Permission.ScoUsersAdmin)
@scodoc7func @scodoc7func
def import_users_generate_excel_sample(REQUEST): def import_users_generate_excel_sample():
"une feuille excel pour importation utilisateurs" "une feuille excel pour importation utilisateurs"
data = sco_import_users.generate_excel_sample() data = sco_import_users.generate_excel_sample()
return scu.send_file(data, "ImportUtilisateurs", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) return scu.send_file(data, "ImportUtilisateurs", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE)
@ -495,7 +493,7 @@ def import_users_generate_excel_sample(REQUEST):
@scodoc @scodoc
@permission_required(Permission.ScoUsersAdmin) @permission_required(Permission.ScoUsersAdmin)
@scodoc7func @scodoc7func
def import_users_form(REQUEST=None): def import_users_form():
"""Import utilisateurs depuis feuille Excel""" """Import utilisateurs depuis feuille Excel"""
head = html_sco_header.sco_header(page_title="Import utilisateurs") head = html_sco_header.sco_header(page_title="Import utilisateurs")
H = [ H = [
@ -529,7 +527,7 @@ def import_users_form(REQUEST=None):
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
tf = TrivialFormulator( tf = TrivialFormulator(
request.base_url, request.base_url,
REQUEST.form, request.form if request.method == "POST" else request.args,
( (
( (
"xlsfile", "xlsfile",
@ -574,7 +572,7 @@ def user_info_page(user_name):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def get_user_list_xml(dept=None, start="", limit=25, REQUEST=None): def get_user_list_xml(dept=None, start="", limit=25):
"""Returns XML list of users with name (nomplogin) starting with start. """Returns XML list of users with name (nomplogin) starting with start.
Used for forms auto-completion. Used for forms auto-completion.
""" """
@ -588,21 +586,21 @@ def get_user_list_xml(dept=None, start="", limit=25, REQUEST=None):
for user in userlist for user in userlist
if scu.suppress_accents((user.nom or "").lower()).startswith(start) if scu.suppress_accents((user.nom or "").lower()).startswith(start)
] ]
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = ElementTree.Element("results") doc = ElementTree.Element("results")
for user in userlist[:limit]: for user in userlist[:limit]:
x_rs = ElementTree.Element("rs", id=str(user.id), info="") x_rs = ElementTree.Element("rs", id=str(user.id), info="")
x_rs.text = user.get_nomplogin() x_rs.text = user.get_nomplogin()
doc.append(x_rs) doc.append(x_rs)
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
data = sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
return scu.send_file(data, mime=scu.XML_MIMETYPE)
@bp.route("/form_change_password") @bp.route("/form_change_password")
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def form_change_password(REQUEST, user_name=None): def form_change_password(user_name=None):
"""Formulaire de changement mot de passe de l'utilisateur user_name. """Formulaire de changement mot de passe de l'utilisateur user_name.
Un utilisateur peut toujours changer son propre mot de passe. Un utilisateur peut toujours changer son propre mot de passe.
""" """
@ -643,7 +641,7 @@ def form_change_password(REQUEST, user_name=None):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def change_password(user_name, password, password2, REQUEST): def change_password(user_name, password, password2):
"Change the password for user given by user_name" "Change the password for user given by user_name"
u = User.query.filter_by(user_name=user_name).first() u = User.query.filter_by(user_name=user_name).first()
# Check access permission # Check access permission

View File

@ -281,8 +281,8 @@ def test_formations(test_client):
# on doit d'abbord supprimer le semestre # on doit d'abbord supprimer le semestre
# sco_formsemestre_edit.formsemestre_delete( formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST) # sco_formsemestre_edit.formsemestre_delete( formsemestre_id=sem2["formsemestre_id"])
# sco_formsemestre_edit.formsemestre_createwithmodules( formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST) # sco_formsemestre_edit.formsemestre_createwithmodules( formsemestre_id=sem2["formsemestre_id"])
# RIEN NE SE PASSE AVEC CES FONCTIONS # RIEN NE SE PASSE AVEC CES FONCTIONS
@ -290,9 +290,9 @@ def test_formations(test_client):
formsemestre_id=sem2["formsemestre_id"] formsemestre_id=sem2["formsemestre_id"]
) )
# sco_edit_module.module_delete( module_id=modt["module_id"], REQUEST=REQUEST) # sco_edit_module.module_delete( module_id=modt["module_id"])
# sco_edit_matiere.matiere_delete( matiere_id=matt["matiere_id"], REQUEST=REQUEST) # sco_edit_matiere.matiere_delete( matiere_id=matt["matiere_id"])
# sco_edit_ue.ue_delete( ue_id=uet["ue_id"], REQUEST=REQUEST) # sco_edit_ue.ue_delete( ue_id=uet["ue_id"])
# RIEN NE SE PASSE AVEC CES FONCTIONS # RIEN NE SE PASSE AVEC CES FONCTIONS