diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 375ffdef9..8ae84c1fb --- a/README.md +++ b/README.md @@ -240,6 +240,9 @@ Puis dérouler les tests unitaires: pytest tests/unit +Ou avec couverture (`pip install pytest-cov`) + + pytest --cov=app --cov-report=term-missing --cov-branch tests/unit/* ## TODO diff --git a/app/decorators.py b/app/decorators.py index 412b59405..161ab8b55 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -164,8 +164,7 @@ def scodoc7func(context): req_args = REQUEST.form # args from query string (get) or form (post) # --- Add positional arguments pos_arg_values = [] - # PY3 à remplacer par inspect.getfullargspec en py3: TODO - argspec = inspect.getargspec(func) + argspec = inspect.getfullargspec(func) # current_app.logger.info("argspec=%s" % str(argspec)) nb_default_args = len(argspec.defaults) if argspec.defaults else 0 if nb_default_args: diff --git a/app/scodoc/notes_log.py b/app/scodoc/notes_log.py index 7b0b7288e..ba52d4946 100644 --- a/app/scodoc/notes_log.py +++ b/app/scodoc/notes_log.py @@ -2,14 +2,13 @@ # -*- coding: utf-8 -*- import os -import re -import inspect import time import traceback from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.header import Header -from flask import current_app + +from flask import g, current_app """Simple & stupid file logguer, used only to debug (logging to SQL is done in scolog) @@ -18,7 +17,7 @@ from flask import current_app LOG_FILENAME = "notes.log" # empty to disable logging DEFAULT_LOG_DIR = "/tmp" # clients should call set_log_directory to change this -ALARM_DESTINATION = "emmanuel.viennet@univ-paris13.fr" # XXX a mettre en preference +ALARM_DESTINATION = "emmanuel.viennet@gmail.com" # XXX a mettre en preference class _logguer(object): @@ -46,7 +45,11 @@ class _logguer(object): if not self.file: self._open() if self.file: - dept = retreive_dept() + try: + dept = getattr(g, "scodoc_dept", "") + except RuntimeError: + # Flask Working outside of application context. + dept = "" if dept: dept = " (%s)" % dept msg = dept + " " + msg @@ -60,42 +63,6 @@ class _logguer(object): log = _logguer() -def retreive_request(skip=0): - """Try to retreive a REQUEST variable in caller stack. - This is a hack, used only in log functions. - """ - - def search(frame): - if "REQUEST" in frame.f_locals: - return frame.f_locals["REQUEST"] - if frame.f_back: - return search(frame.f_back) - else: - return None - - frame = inspect.currentframe() - if frame: # not supported by all pythons - startframe = frame - while skip and startframe.f_back: - startframe = startframe.f_back - return search(startframe) - else: - return None - - -def retreive_dept(): - """Try to retreive departement (from REQUEST URL)""" - REQUEST = retreive_request() - if not REQUEST: - return "" - try: - url = REQUEST.URL - m = re.match(r"^.*ScoDoc/(\w+).*$", url) - return m.group(1) - except: - return "" - - # Alarms by email: def sendAlarm(context, subj, txt): from . import sco_utils diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 34116e136..ee3455e41 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -617,7 +617,6 @@ def add_absence( vars(), ) logdb( - REQUEST, cnx, "AddAbsence", etudid=etudid, @@ -642,7 +641,6 @@ def add_justif(context, etudid, jour, matin, REQUEST, description=None): vars(), ) logdb( - REQUEST, cnx, "AddJustif", etudid=etudid, @@ -679,7 +677,6 @@ def annule_absence(context, etudid, jour, matin, moduleimpl_id=None, REQUEST=Non req += " and moduleimpl_id=%(moduleimpl_id)s" cursor.execute(req, vars()) logdb( - REQUEST, cnx, "AnnuleAbsence", etudid=etudid, @@ -704,7 +701,6 @@ def annule_justif(context, etudid, jour, matin, REQUEST=None): vars(), ) logdb( - REQUEST, cnx, "AnnuleJustif", etudid=etudid, diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 80693c8b4..06ea8e9d7 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -652,7 +652,6 @@ def AnnuleAbsencesDatesNoJust(context, etudid, dates, moduleimpl_id=None, REQUES else: date1 = None logdb( - REQUEST, cnx, "AnnuleAbsencesDatesNoJust", etudid=etudid, diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index a6a37d43d..3d80b46a4 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -488,7 +488,7 @@ enregistrés et non modifiables, on peut les retrouver ultérieurement. msg = "Nouvelle%20archive%20créée" # submitted or cancelled: - return REQUEST.RESPONSE.redirect( + return flask.redirect( "formsemestre_list_archives?formsemestre_id=%s&head_message=%s" % (formsemestre_id, msg) ) @@ -566,12 +566,10 @@ def formsemestre_delete_archive( if not dialog_confirmed: return scu.confirm_dialog( - context, """

Confirmer la suppression de l'archive du %s ?

La suppression sera définitive.

""" % PVArchive.get_archive_date(archive_id).strftime("%d/%m/%Y %H:%M"), dest_url="", - REQUEST=REQUEST, cancel_url=dest_url, parameters={ "formsemestre_id": formsemestre_id, @@ -580,4 +578,4 @@ def formsemestre_delete_archive( ) PVArchive.delete_archive(archive_id) - return REQUEST.RESPONSE.redirect(dest_url + "&head_message=Archive%20supprimée") + return flask.redirect(dest_url + "&head_message=Archive%20supprimée") diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 195396570..94aad219f 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -29,6 +29,7 @@ Il s'agit de fichiers quelconques, généralement utilisés pour conserver les dossiers d'admission et autres pièces utiles. """ +import flask from flask import url_for, g import app.scodoc.sco_utils as scu @@ -164,7 +165,7 @@ def etud_upload_file_form(context, REQUEST, etudid): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect( + return flask.redirect( url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) ) else: @@ -174,7 +175,7 @@ def etud_upload_file_form(context, REQUEST, etudid): _store_etud_file_to_new_archive( context, REQUEST, etudid, data, filename, description=descr ) - return REQUEST.RESPONSE.redirect( + return flask.redirect( url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) ) @@ -201,7 +202,6 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed archive_id = EtudsArchive.get_id_from_name(context, etudid, archive_name) if not dialog_confirmed: return scu.confirm_dialog( - context, """

Confirmer la suppression des fichiers ?

Fichier associé le %s à l'étudiant %s

La suppression sera définitive.

""" @@ -210,7 +210,6 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed etud["nomprenom"], ), dest_url="", - REQUEST=REQUEST, cancel_url=url_for( "scolar.ficheEtud", scodoc_dept=g.scodoc_dept, @@ -221,7 +220,7 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed ) EtudsArchive.delete_archive(archive_id) - return REQUEST.RESPONSE.redirect( + return flask.redirect( url_for( "scolar.ficheEtud", scodoc_dept=g.scodoc_dept, @@ -311,9 +310,13 @@ def etudarchive_import_files_form(context, group_id, REQUEST=None): return "\n".join(H) + tf[1] + "" + F elif tf[0] == -1: # retrouve le semestre à partir du groupe: - g = sco_groups.get_group(context, group_id) - return REQUEST.RESPONSE.redirect( - "formsemestre_status?formsemestre_id=" + g["formsemestre_id"] + group = sco_groups.get_group(context, group_id) + return flask.redirect( + url_for( + "notes.formsemestre_status", + scodoc_dept=g.scodoc_dept, + formsemestre_id=group["formsemestre_id"], + ) ) else: return etudarchive_import_files( diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py index 6c7cf7a66..fba445ec5 100644 --- a/app/scodoc/sco_debouche.py +++ b/app/scodoc/sco_debouche.py @@ -256,7 +256,7 @@ def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None): item = itemsuivi_get(cnx, itemsuivi_id, ignore_errors=True) if item: _itemsuivi_delete(cnx, itemsuivi_id) - logdb(REQUEST, cnx, method="itemsuivi_suppress", etudid=item["etudid"]) + logdb(cnx, method="itemsuivi_suppress", etudid=item["etudid"]) log("suppressed itemsuivi %s" % (itemsuivi_id,)) @@ -270,7 +270,7 @@ def itemsuivi_create( itemsuivi_id = _itemsuivi_create( cnx, args={"etudid": etudid, "item_date": item_date, "situation": situation} ) - logdb(REQUEST, cnx, method="itemsuivi_create", etudid=etudid) + logdb(cnx, method="itemsuivi_create", etudid=etudid) log("created itemsuivi %s for %s" % (itemsuivi_id, etudid)) item = itemsuivi_get(cnx, itemsuivi_id) if format == "json": diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 7edc901d3..0f7c13af2 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -73,19 +73,17 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST else: if not dialog_confirmed: return scu.confirm_dialog( - context, """

Confirmer la suppression de la formation %(titre)s (%(acronyme)s) ?

Attention: la suppression d'une formation est irréversible et implique la supression de toutes les UE, matières et modules de la formation !

""" % F, - REQUEST=REQUEST, OK="Supprimer cette formation", cancel_url=scu.NotesURL(), parameters={"formation_id": formation_id}, ) else: - do_formation_delete(context, F["formation_id"], REQUEST) + do_formation_delete(context, F["formation_id"]) H.append( """

OK, formation supprimée.

continuer

""" @@ -96,7 +94,7 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST return "\n".join(H) -def do_formation_delete(context, oid, REQUEST): +def do_formation_delete(context, oid): """delete a formation (and all its UE, matieres, modules) XXX delete all ues, will break if there are validations ! USE WITH CARE ! """ @@ -107,7 +105,7 @@ def do_formation_delete(context, oid, REQUEST): # delete all UE in this formation ues = sco_edit_ue.do_ue_list(context, {"formation_id": oid}) for ue in ues: - sco_edit_ue.do_ue_delete(context, ue["ue_id"], REQUEST=REQUEST, force=True) + sco_edit_ue.do_ue_delete(context, ue["ue_id"], force=True) sco_formations._formationEditor.delete(cnx, oid) @@ -222,7 +220,7 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(scu.NotesURL()) + return flask.redirect(scu.NotesURL()) else: # check unicity : constraint UNIQUE(acronyme,titre,version) if create: @@ -247,13 +245,13 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None): ) # if create: - formation_id = do_formation_create(context, tf[2], REQUEST) + formation_id = do_formation_create(context, tf[2]) else: do_formation_edit(context, tf[2]) - return REQUEST.RESPONSE.redirect("ue_list?formation_id=%s" % formation_id) + return flask.redirect("ue_list?formation_id=%s" % formation_id) -def do_formation_create(context, args, REQUEST): +def do_formation_create(context, args): "create a formation" cnx = ndb.GetDBConnexion() # check unique acronyme/titre/version @@ -338,7 +336,7 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1): # redirect to ue_list page: if redirect: - return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id) + return flask.redirect("ue_list?formation_id=" + formation_id) def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1): @@ -369,4 +367,4 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1): sco_edit_ue._ueEditor.edit(cnx, neigh) # redirect to ue_list page if redirect: - return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + o["formation_id"]) \ No newline at end of file + return flask.redirect("ue_list?formation_id=" + o["formation_id"]) \ No newline at end of file diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index 8693ccbb8..bb337e5b0 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -68,7 +68,7 @@ def do_matiere_edit(context, *args, **kw): sco_edit_formation.invalidate_sems_in_formation(formation_id) -def do_matiere_create(context, args, REQUEST): +def do_matiere_create(context, args): "create a matiere" from app.scodoc import sco_edit_ue from app.scodoc import sco_formations @@ -138,7 +138,7 @@ associé. if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) else: # check unicity mats = do_matiere_list(context, args={"ue_id": ue_id, "titre": tf[2]["titre"]}) @@ -149,11 +149,11 @@ associé. + tf[1] + html_sco_header.sco_footer() ) - _ = do_matiere_create(context, tf[2], REQUEST) - return REQUEST.RESPONSE.redirect(dest_url) + _ = do_matiere_create(context, tf[2]) + return flask.redirect(dest_url) -def do_matiere_delete(context, oid, REQUEST): +def do_matiere_delete(context, oid): "delete matiere and attached modules" from app.scodoc import sco_formations from app.scodoc import sco_edit_ue @@ -174,7 +174,7 @@ def do_matiere_delete(context, oid, REQUEST): # delete all modules in this matiere mods = sco_edit_module.do_module_list(context, {"matiere_id": oid}) for mod in mods: - sco_edit_module.do_module_delete(context, mod["module_id"], REQUEST) + sco_edit_module.do_module_delete(context, mod["module_id"]) _matiereEditor.delete(cnx, oid) # news @@ -211,10 +211,10 @@ def matiere_delete(context, matiere_id=None, REQUEST=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) else: - do_matiere_delete(context, matiere_id, REQUEST) - return REQUEST.RESPONSE.redirect(dest_url) + do_matiere_delete(context, matiere_id) + return flask.redirect(dest_url) def matiere_edit(context, matiere_id=None, REQUEST=None): @@ -284,7 +284,7 @@ associé. if tf[0] == 0: return "\n".join(H) + tf[1] + help + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) else: # check unicity mats = do_matiere_list( @@ -308,7 +308,7 @@ associé. do_matiere_edit(context, tf[2]) - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) def matiere_is_locked(context, matiere_id): diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 7e840abcd..f98beb494 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -28,6 +28,9 @@ """Ajout/Modification/Suppression modules (portage from DTML) """ +import flask +from flask import url_for, g + import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu from app.scodoc.notes_log import log @@ -96,7 +99,7 @@ def do_module_list(context, *args, **kw): return _moduleEditor.list(cnx, *args, **kw) -def do_module_create(context, args, REQUEST): +def do_module_create(context, args): "create a module" # create from app.scodoc import sco_formations @@ -237,13 +240,17 @@ def module_create(context, matiere_id=None, REQUEST=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() else: - do_module_create(context, tf[2], REQUEST) - return REQUEST.RESPONSE.redirect( - scu.NotesURL() + "/ue_list?formation_id=" + UE["formation_id"] + do_module_create(context, tf[2]) + return flask.redirect( + url_for( + "notes.ue_list", + scodoc_dept=g.scodoc_dept, + formation_id=UE["formation_id"], + ) ) -def do_module_delete(context, oid, REQUEST): +def do_module_delete(context, oid): "delete module" from app.scodoc import sco_formations @@ -255,12 +262,10 @@ def do_module_delete(context, oid, REQUEST): mods = sco_moduleimpl.do_moduleimpl_list(context, module_id=oid) if mods: err_page = scu.confirm_dialog( - context, message="""

Destruction du module impossible car il est utilisé dans des semestres existants !

""", helpmsg="""Il faut d'abord supprimer le semestre. Mais il est peut être préférable de laisser ce programme intact et d'en créer une nouvelle version pour la modifier.""", dest_url="ue_list", parameters={"formation_id": mod["formation_id"]}, - REQUEST=REQUEST, ) raise ScoGenError(err_page) # delete @@ -303,10 +308,10 @@ def module_delete(context, module_id=None, REQUEST=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) else: - do_module_delete(context, module_id, REQUEST) - return REQUEST.RESPONSE.redirect(dest_url) + do_module_delete(context, module_id) + return flask.redirect(dest_url) def do_module_edit(context, val): @@ -498,14 +503,14 @@ def module_edit(context, module_id=None, REQUEST=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() elif tf[0] == -1: - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) else: # l'UE peut changer tf[2]["ue_id"], tf[2]["matiere_id"] = tf[2]["ue_matiere_id"].split("!") # Check unicité code module dans la formation do_module_edit(context, tf[2]) - return REQUEST.RESPONSE.redirect(dest_url) + return flask.redirect(dest_url) # Edition en ligne du code Apogee @@ -594,7 +599,7 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None) ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST) if REQUEST: - return REQUEST.RESPONSE.redirect("ue_list?formation_id=" + formation_id) + return flask.redirect("ue_list?formation_id=" + formation_id) def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None): @@ -623,7 +628,7 @@ def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None): Matlist = sco_edit_matiere.do_matiere_list(context, args={"ue_id": ue_id}) numero = max([mat["numero"] for mat in Matlist]) + 10 matiere_id = sco_edit_matiere.do_matiere_create( - context, {"ue_id": ue_id, "titre": "Malus", "numero": numero}, REQUEST + context, {"ue_id": ue_id, "titre": "Malus", "numero": numero} ) module_id = do_module_create( @@ -638,7 +643,6 @@ def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None): "semestre_id": semestre_id, "module_type": scu.MODULE_MALUS, }, - REQUEST, ) return module_id diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index e7c8bc543..4a517d598 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -28,6 +28,10 @@ """Ajout/Modification/Suppression UE """ +import flask +from flask import g, url_for +from flask_login import current_user + import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu from app.scodoc.notes_log import log @@ -83,7 +87,7 @@ def do_ue_list(context, *args, **kw): return _ueEditor.list(cnx, *args, **kw) -def do_ue_create(context, args, REQUEST): +def do_ue_create(context, args): "create an ue" from app.scodoc import sco_formations @@ -130,11 +134,9 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F ) if validations and not delete_validations and not force: return scu.confirm_dialog( - context, "

%d étudiants ont validé l'UE %s (%s)

Si vous supprimez cette UE, ces validations vont être supprimées !

" % (len(validations), ue["acronyme"], ue["titre"]), dest_url="", - REQUEST=REQUEST, target_variable="delete_validations", cancel_url="ue_list?formation_id=%s" % ue["formation_id"], parameters={"ue_id": ue_id, "dialog_confirmed": 1}, @@ -149,7 +151,7 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F # delete all matiere in this UE mats = sco_edit_matiere.do_matiere_list(context, {"ue_id": ue_id}) for mat in mats: - sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"], REQUEST) + sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"]) # delete uecoef and events ndb.SimpleQuery( "DELETE FROM notes_formsemestre_uecoef WHERE ue_id=%(ue_id)s", @@ -171,8 +173,12 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F ) # if not force: - return REQUEST.RESPONSE.redirect( - scu.NotesURL() + "/ue_list?formation_id=" + str(ue["formation_id"]) + return flask.redirect( + url_for( + "notes.ue_list", + scodoc_dept=g.scodoc_dept, + formation_id=ue["formation_id"], + ) ) else: return None @@ -337,12 +343,11 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None): context, formation_id, int(tf[2]["semestre_id"] or 0) ) - ue_id = do_ue_create(context, tf[2], REQUEST) + ue_id = do_ue_create(context, tf[2]) if parcours.UE_IS_MODULE or tf[2]["create_matiere"]: matiere_id = sco_edit_matiere.do_matiere_create( context, {"ue_id": ue_id, "titre": tf[2]["titre"], "numero": 1}, - REQUEST, ) if parcours.UE_IS_MODULE: # dans ce mode, crée un (unique) module dans l'UE: @@ -357,12 +362,13 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None): "formation_id": formation_id, "semestre_id": tf[2]["semestre_id"], }, - REQUEST, ) else: do_ue_edit(context, tf[2]) - return REQUEST.RESPONSE.redirect( - scu.NotesURL() + "/ue_list?formation_id=" + formation_id + return flask.redirect( + url_for( + "notes.ue_list", scodoc_dept=g.scodoc_dept, formation_id=formation_id + ) ) @@ -409,10 +415,8 @@ def ue_delete( if not dialog_confirmed: return scu.confirm_dialog( - context, "

Suppression de l'UE %(titre)s (%(acronyme)s))

" % ue, dest_url="", - REQUEST=REQUEST, parameters={"ue_id": ue_id}, cancel_url="ue_list?formation_id=%s" % ue["formation_id"], ) @@ -429,8 +433,6 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None): from app.scodoc import sco_formations from app.scodoc import sco_formsemestre_validation - authuser = REQUEST.AUTHENTICATED_USER - F = sco_formations.formation_list(context, args={"formation_id": formation_id}) if not F: raise ScoValueError("invalid formation_id") @@ -444,7 +446,7 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None): ue_list.sort(key=lambda u: (u["semestre_id"], u["numero"])) has_duplicate_ue_codes = len(set([ue["ue_code"] for ue in ue_list])) != len(ue_list) - perm_change = authuser.has_permission(Permission.ScoChangeFormation) + perm_change = current_user.has_permission(Permission.ScoChangeFormation) # editable = (not locked) and perm_change # On autorise maintanant la modification des formations qui ont des semestres verrouillés, # sauf si cela affect les notes passées (verrouillées): @@ -452,14 +454,14 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None): # - pas de changement des codes d'UE utilisés dans des semestres verrouillés editable = perm_change tag_editable = ( - authuser.has_permission(Permission.ScoEditFormationTags) or perm_change + current_user.has_permission(Permission.ScoEditFormationTags) or perm_change ) if locked: lockicon = scu.icontag("lock32_img", title="verrouillé") else: lockicon = "" - arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST) + arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags() delete_icon = scu.icontag( "delete_small_img", title="Supprimer (module inutilisé)", alt="supprimer" ) @@ -802,7 +804,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module H.append("") H.append("") - if authuser.has_permission(Permission.ScoImplement): + if current_user.has_permission(Permission.ScoImplement): H.append( """