From d8dfa0201eebbcaa6b4ba20ba620e454eda7844d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 22 Aug 2021 13:24:36 +0200 Subject: [PATCH] gestion responsables de semestres --- app/scodoc/html_sidebar.py | 2 +- app/scodoc/sco_abs_notification.py | 2 +- app/scodoc/sco_abs_views.py | 24 +++++++-------- app/scodoc/sco_archives_etud.py | 4 +-- app/scodoc/sco_bulletins.py | 20 ++++++------ app/scodoc/sco_bulletins_json.py | 2 +- app/scodoc/sco_bulletins_legacy.py | 2 +- app/scodoc/sco_bulletins_pdf.py | 2 +- app/scodoc/sco_bulletins_standard.py | 2 +- app/scodoc/sco_bulletins_xml.py | 2 +- app/scodoc/sco_compute_moy.py | 2 +- app/scodoc/sco_debouche.py | 2 +- app/scodoc/sco_etud.py | 30 ++++++++++-------- app/scodoc/sco_find_etud.py | 16 ++++++---- app/scodoc/sco_formsemestre.py | 4 +-- app/scodoc/sco_formsemestre_exterieurs.py | 7 +++-- app/scodoc/sco_formsemestre_inscriptions.py | 13 ++++---- app/scodoc/sco_formsemestre_status.py | 20 +++--------- app/scodoc/sco_groups.py | 2 +- app/scodoc/sco_liste_notes.py | 2 +- app/scodoc/sco_moduleimpl.py | 23 ++++++-------- app/scodoc/sco_moduleimpl_status.py | 6 ++-- app/scodoc/sco_news.py | 5 ++- app/scodoc/sco_page_etud.py | 7 ++--- app/scodoc/sco_permissions_check.py | 34 ++++++++++----------- app/scodoc/sco_photos.py | 4 +-- app/scodoc/sco_pvjury.py | 2 +- app/scodoc/sco_pvpdf.py | 2 ++ app/scodoc/sco_synchro_etuds.py | 4 +-- app/scodoc/sco_ue_external.py | 9 ++---- app/scodoc/sco_users.py | 11 ++++--- app/views/absences.py | 14 ++++----- app/views/notes.py | 14 ++++----- app/views/scolar.py | 30 +++++++++--------- app/views/users.py | 2 +- 35 files changed, 158 insertions(+), 169 deletions(-) diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index 43e2e6eaf..3f71ad57c 100644 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -107,7 +107,7 @@ def sidebar(): etudid = request.form.get("etudid", None) if etudid: - etud = sco_etud.get_etud_info(filled=1, etudid=etudid)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] params.update(etud) params["fiche_url"] = url_for( "scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py index 6f7c0dfcc..c397c73f0 100644 --- a/app/scodoc/sco_abs_notification.py +++ b/app/scodoc/sco_abs_notification.py @@ -147,7 +147,7 @@ def abs_notify_get_destinations(sem, prefs, etudid, date, nbabs, nbabsjust): if prefs["abs_notify_email"]: destinations.append(prefs["abs_notify_email"]) if prefs["abs_notify_etud"]: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] if etud["email_default"]: destinations.append(etud["email_default"]) diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 59b59e359..66bdcbac5 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -71,7 +71,7 @@ def doSignaleAbsence( description: str etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form """ - etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etudid = etud["etudid"] if not moduleimpl_id: moduleimpl_id = None @@ -151,7 +151,7 @@ def doSignaleAbsence(
""" % etud ) - H.append(sco_find_etud.form_search_etud(REQUEST)) + H.append(sco_find_etud.form_search_etud()) H.append(html_sco_header.sco_footer()) return "\n".join(H) @@ -159,7 +159,7 @@ def doSignaleAbsence( def SignaleAbsenceEtud(REQUEST=None): # etudid implied """Formulaire individuel simple de signalement d'une absence""" # brute-force portage from very old dtml code ... - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] etudid = etud["etudid"] disabled = False if not etud["cursem"]: @@ -293,7 +293,7 @@ def doJustifAbsence( description: str etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form """ - etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etudid = etud["etudid"] description_abs = description dates = sco_abs.DateRangeISO(datedebut, datefin) @@ -352,7 +352,7 @@ def doJustifAbsence(
""" % etud ) - H.append(sco_find_etud.form_search_etud(REQUEST)) + H.append(sco_find_etud.form_search_etud()) H.append(html_sco_header.sco_footer()) return "\n".join(H) @@ -360,7 +360,7 @@ def doJustifAbsence( def JustifAbsenceEtud(REQUEST=None): # etudid implied """Formulaire individuel simple de justification d'une absence""" # brute-force portage from very old dtml code ... - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] etudid = etud["etudid"] H = [ html_sco_header.sco_header( @@ -416,7 +416,7 @@ def doAnnuleAbsence( datedebut, datefin, demijournee, etudid=False, REQUEST=None ): # etudid implied """Annulation des absences pour une demi journée""" - etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etudid = etud["etudid"] dates = sco_abs.DateRangeISO(datedebut, datefin) @@ -457,7 +457,7 @@ autre absence pour %(nomprenom)s
""" % etud ) - H.append(sco_find_etud.form_search_etud(REQUEST)) + H.append(sco_find_etud.form_search_etud()) H.append(html_sco_header.sco_footer()) return "\n".join(H) @@ -465,7 +465,7 @@ autre absence pour %(nomprenom)s def AnnuleAbsenceEtud(REQUEST=None): # etudid implied """Formulaire individuel simple d'annulation d'une absence""" # brute-force portage from very old dtml code ... - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] etudid = etud["etudid"] H = [ @@ -550,7 +550,7 @@ def AnnuleAbsenceEtud(REQUEST=None): # etudid implied def doAnnuleJustif(datedebut0, datefin0, demijournee, REQUEST=None): # etudid implied """Annulation d'une justification""" - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] etudid = etud["etudid"] dates = sco_abs.DateRangeISO(datedebut0, datefin0) nbadded = 0 @@ -591,7 +591,7 @@ autre absence pour %(nomprenom)s
""" % etud ) - H.append(sco_find_etud.form_search_etud(REQUEST)) + H.append(sco_find_etud.form_search_etud()) H.append(html_sco_header.sco_footer()) return "\n".join(H) @@ -713,7 +713,7 @@ def CalAbs(etudid, sco_year=None): """Calendrier des absences d'un etudiant""" # crude portage from 1999 DTML REQUEST = None # XXX - etud = sco_etud.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] etudid = etud["etudid"] anneescolaire = int(scu.AnneeScolaire(sco_year)) datedebut = str(anneescolaire) + "-08-01" diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index d14ca48ab..c1327c8a9 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -131,7 +131,7 @@ def etud_upload_file_form(REQUEST, etudid): raise AccessDenied( "opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER) ) - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] H = [ html_sco_header.sco_header( page_title="Chargement d'un document associé à %(nomprenom)s" % etud, @@ -194,7 +194,7 @@ def etud_delete_archive(REQUEST, etudid, archive_name, dialog_confirmed=False): raise AccessDenied( "opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER) ) - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] archive_id = EtudsArchive.get_id_from_name(etudid, archive_name) if not dialog_confirmed: return scu.confirm_dialog( diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 09b426f88..9cbff1558 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -87,7 +87,7 @@ def make_context_dict(sem, etud): C = sem.copy() C["responsable"] = " ,".join( [ - sco_users.user_info(user_name=responsable_id)["prenomnom"] + sco_users.user_info(responsable_id)["prenomnom"] for responsable_id in sem["responsables"] ] ) @@ -156,7 +156,7 @@ def formsemestre_bulletinetud_dict( I["formation"]["type_parcours"] ) # Infos sur l'etudiant - I["etud"] = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + I["etud"] = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] I["descr_situation"] = I["etud"]["inscriptionstr"] if I["etud"]["inscription_formsemestre_id"]: I[ @@ -772,7 +772,7 @@ def formsemestre_bulletinetud( ): "page bulletin de notes" try: - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] etudid = etud["etudid"] except: return scu.log_unknown_etud(REQUEST, format=format) @@ -842,7 +842,7 @@ def can_send_bulletin_by_mail(formsemestre_id): return ( sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id) or current_user.has_permission(Permission.ScoImplement) - or current_user.user_name in sem["responsables"] + or current_user.id in sem["responsables"] ) @@ -1016,8 +1016,6 @@ def _formsemestre_bulletinetud_header_html( version=None, REQUEST=None, ): - authuser = REQUEST.AUTHENTICATED_USER - uid = str(authuser) H = [ html_sco_header.sco_header( page_title="Bulletin de %(nomprenom)s" % etud, @@ -1077,8 +1075,8 @@ def _formsemestre_bulletinetud_header_html( "title": "Réglages bulletins", "endpoint": "notes.formsemestre_edit_options", "args": {"formsemestre_id": formsemestre_id, "target_url": qurl}, - "enabled": (uid in sem["responsables"]) - or authuser.has_permission(Permission.ScoImplement), + "enabled": (current_user.id in sem["responsables"]) + or current_user.has_permission(Permission.ScoImplement), }, { "title": 'Version papier (pdf, format "%s")' @@ -1137,8 +1135,8 @@ def _formsemestre_bulletinetud_header_html( "etudid": etudid, }, "enabled": ( - (authuser in sem["responsables"]) - or (authuser.has_permission(Permission.ScoEtudInscrit)) + (current_user.id in sem["responsables"]) + or (current_user.has_permission(Permission.ScoEtudInscrit)) ), }, { @@ -1148,7 +1146,7 @@ def _formsemestre_bulletinetud_header_html( "formsemestre_id": formsemestre_id, "etudid": etudid, }, - "enabled": authuser.has_permission(Permission.ScoImplement), + "enabled": current_user.has_permission(Permission.ScoImplement), }, { "title": "Enregistrer une validation d'UE antérieure", diff --git a/app/scodoc/sco_bulletins_json.py b/app/scodoc/sco_bulletins_json.py index b209abd03..5acfb5995 100644 --- a/app/scodoc/sco_bulletins_json.py +++ b/app/scodoc/sco_bulletins_json.py @@ -117,7 +117,7 @@ def formsemestre_bulletinetud_published_dict( d.update(**el) # Infos sur l'etudiant - etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] d["etudiant"] = dict( etudid=etudid, diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index 2efa86bf1..01acbbcf9 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -314,7 +314,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): # --- Appreciations # le dir. des etud peut ajouter des appreciations, # mais aussi le chef (perm. ScoEtudInscrit) - can_edit_app = (str(authuser) in self.infos["responsables"]) or ( + can_edit_app = (authuser.id in self.infos["responsables"]) or ( authuser.has_permission(Permission.ScoEtudInscrit) ) H.append('
') diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index b24484d55..a655b7cf9 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -224,7 +224,7 @@ def get_etud_bulletins_pdf(etudid, REQUEST, version="selectedevals"): "Bulletins pdf de tous les semestres de l'étudiant, et filename" from app.scodoc import sco_bulletins - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] fragments = [] bookmarks = {} filigrannes = {} diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index 3397139f2..a8f88b793 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -144,7 +144,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): # ---- APPRECIATIONS # le dir. des etud peut ajouter des appreciations, # mais aussi le chef (perm. ScoEtudInscrit) - can_edit_app = (str(self.authuser) in self.infos["responsables"]) or ( + can_edit_app = (self.authuser.id in self.infos["responsables"]) or ( self.authuser.has_permission(Permission.ScoEtudInscrit) ) H.append('
') diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 49db50805..7b456e4f8 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -111,7 +111,7 @@ def make_xml_formsemestre_bulletinetud( is_appending = False doc = x # Infos sur l'etudiant - etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] doc.append( Element( "etudiant", diff --git a/app/scodoc/sco_compute_moy.py b/app/scodoc/sco_compute_moy.py index 4a7eda4ec..9ae16999f 100644 --- a/app/scodoc/sco_compute_moy.py +++ b/app/scodoc/sco_compute_moy.py @@ -162,7 +162,7 @@ def compute_user_formula( if user_moy != "NA0" and user_moy != "NA": user_moy = float(user_moy) if (user_moy > 20) or (user_moy < 0): - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] raise ScoException( """valeur moyenne %s hors limite pour %s""" diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py index 45b9abdf7..6e128e23e 100644 --- a/app/scodoc/sco_debouche.py +++ b/app/scodoc/sco_debouche.py @@ -108,7 +108,7 @@ def table_debouche_etudids(etudids, keep_numeric=True): """Rapport pour ces etudiants""" L = [] for etudid in etudids: - etud = sco_etud.get_etud_info(filled=1, etudid=etudid)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] # retrouve le "dernier" semestre (au sens de la date de fin) sems = etud["sems"] es = [(s["date_fin_iso"], i) for i, s in enumerate(sems)] diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index 6736ad699..0d8682a5e 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -32,7 +32,7 @@ import os import time -from flask import url_for, g +from flask import url_for, g, request from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText @@ -630,10 +630,10 @@ etudident_edit = _etudidentEditor.edit etudident_create = _etudidentEditor.create -def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True): +def make_etud_args(etudid=None, code_nip=None, use_request=True, raise_exc=True): """forme args dict pour requete recherche etudiant On peut specifier etudid - ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine + ou bien (si use_request) cherche dans la requete http: etudid, code_nip, code_ine (dans cet ordre). """ args = None @@ -641,19 +641,25 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True): args = {"etudid": etudid} elif code_nip: args = {"code_nip": code_nip} - elif REQUEST: - if "etudid" in REQUEST.form: - args = {"etudid": int(REQUEST.form["etudid"])} - elif "code_nip" in REQUEST.form: - args = {"code_nip": REQUEST.form["code_nip"]} - elif "code_ine" in REQUEST.form: - args = {"code_ine": REQUEST.form["code_ine"]} + elif use_request: # use form from current request (Flask global) + if request.method == "POST": + vals = request.form + elif request.method == "GET": + vals = request.args + else: + vals = {} + if "etudid" in vals: + args = {"etudid": int(vals["etudid"])} + elif "code_nip" in vals: + args = {"code_nip": str(vals["code_nip"])} + elif "code_ine" in vals: + args = {"code_ine": str(vals["code_ine"])} if not args and raise_exc: raise ValueError("getEtudInfo: no parameter !") return args -def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None): +def get_etud_info(etudid=False, code_nip=False, filled=False): """infos sur un etudiant (API) On peut specifier etudid ou conde_nip ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine @@ -662,7 +668,7 @@ def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None): if etudid is None: return [] cnx = ndb.GetDBConnexion() - args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST) + args = make_etud_args(etudid=etudid, code_nip=code_nip) etud = etudident_list(cnx, args=args) if filled: diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index efdf818c2..63bb158cd 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -28,7 +28,7 @@ """Recherche d'étudiants """ import flask -from flask import url_for, g +from flask import url_for, g, request from flask_login import current_user import app @@ -44,7 +44,6 @@ from app.scodoc import sco_preferences def form_search_etud( - REQUEST=None, dest_url=None, parameters=None, parameters_keys=None, @@ -77,7 +76,13 @@ def form_search_etud( ) elif parameters_keys: for key in parameters_keys.split(","): - v = REQUEST.form.get(key, False) + if request.method == "POST": + vals = request.form + elif request.method == "GET": + vals = request.args + else: + vals = {} + v = vals.get(key, False) if v: H.append('' % (key, v)) H.append( @@ -105,13 +110,14 @@ def search_etud_in_dept(expnom="", REQUEST=None): Args: expnom: string, regexp sur le nom ou un code_nip ou un etudid """ + breakpoint() if isinstance(expnom, int) or len(expnom) > 1: try: etudid = int(expnom) except ValueError: etudid = None if etudid is not None: - etuds = sco_etud.get_etud_info(filled=1, etudid=expnom, REQUEST=REQUEST) + etuds = sco_etud.get_etud_info(filled=True, etudid=expnom) if (etudid is None) or len(etuds) != 1: if scu.is_valid_code_nip(expnom): etuds = search_etuds_infos(code_nip=expnom) @@ -141,7 +147,6 @@ def search_etud_in_dept(expnom="", REQUEST=None): dest_url=url_for( "scolar.ficheEtud", scodoc_dept=g.scodoc_dept ), # sans l'etudid, post du form - REQUEST=REQUEST, title="Autre recherche", ), ] @@ -174,7 +179,6 @@ def search_etud_in_dept(expnom="", REQUEST=None): H.append( form_search_etud( dest_url=url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept), - REQUEST=REQUEST, title="Autre recherche", ) ) diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 4a36553b0..64fd6dc61 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -267,9 +267,9 @@ def do_formsemestre_edit(sem, cnx=None, **kw): ) # > modif formsemestre -def read_formsemestre_responsables(formsemestre_id): +def read_formsemestre_responsables(formsemestre_id: int) -> list[int]: # py3.9+ syntax """recupere liste des responsables de ce semestre - :returns: liste de chaines + :returns: liste d'id """ r = ndb.SimpleDictFetch( """SELECT responsable_id diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index 29d16db0f..578e85de7 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -35,6 +35,7 @@ import time import flask from flask import url_for, g +from flask_login import current_user import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb @@ -60,12 +61,12 @@ def formsemestre_ext_create(etudid, sem_params, REQUEST=None): args={"formation_id": sem_params["formation_id"]} )[0] if etudid: - _etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + _etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] # Create formsemestre sem_params["modalite"] = "EXT" sem_params["etapes"] = None - sem_params["responsables"] = [str(REQUEST.AUTHENTICATED_USER)] + sem_params["responsables"] = [current_user.id] formsemestre_id = sco_formsemestre.do_formsemestre_create(sem_params, silent=True) # nota: le semestre est créé vide: pas de modules @@ -81,7 +82,7 @@ def formsemestre_ext_create(etudid, sem_params, REQUEST=None): def formsemestre_ext_create_form(etudid, formsemestre_id, REQUEST=None): """Formulaire creation/inscription à un semestre extérieur""" - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] H = [ html_sco_header.sco_header(), """

Enregistrement d'une inscription antérieure dans un autre établissement

diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 199a0bd7d..75b3ef31b 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -251,13 +251,12 @@ def formsemestre_inscription_with_modules_etud( """Form. inscription d'un étudiant au semestre. Si etudid n'est pas specifié, form. choix etudiant. """ - if not etudid: + if etudid is None: return sco_find_etud.form_search_etud( title="Choix de l'étudiant à inscrire dans ce semestre", add_headers=True, dest_url="formsemestre_inscription_with_modules_etud", parameters={"formsemestre_id": formsemestre_id}, - REQUEST=REQUEST, ) return formsemestre_inscription_with_modules( @@ -269,7 +268,7 @@ def formsemestre_inscription_with_modules_form(etudid, only_ext=False): """Formulaire inscription de l'etud dans l'un des semestres existants. Si only_ext, ne montre que les semestre extérieurs. """ - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] H = [ html_sco_header.sco_header(), "

Inscription de %s" % etud["nomprenom"], @@ -329,7 +328,7 @@ def formsemestre_inscription_with_modules( if multiple_ok: multiple_ok = int(multiple_ok) sem = sco_formsemestre.get_formsemestre(formsemestre_id) - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] H = [ html_sco_header.html_sem_header( REQUEST, @@ -436,7 +435,7 @@ def formsemestre_inscription_option(etudid, formsemestre_id, REQUEST=None): if not sem["etat"]: raise ScoValueError("Modification impossible: semestre verrouille") - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_ue_status F = html_sco_header.sco_footer() @@ -722,7 +721,7 @@ def est_inscrit_ailleurs(etudid, formsemestre_id): temps que celui indiqué (par formsemestre_id). Retourne la liste des semestres concernés (ou liste vide). """ - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] sem = sco_formsemestre.get_formsemestre(formsemestre_id) debut_s = sem["dateord"] fin_s = ndb.DateDMYtoISO(sem["date_fin"]) @@ -764,7 +763,7 @@ def formsemestre_inscrits_ailleurs(formsemestre_id, REQUEST=None): insd = list_inscrits_ailleurs(formsemestre_id) # liste ordonnée par nom etudlist = [ - sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + sco_etud.get_etud_info(etudid=etudid, filled=True)[0] for etudid in insd.keys() if insd[etudid] ] diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 99c8f3b11..c31d0bfc1 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -123,7 +123,6 @@ def _build_menu_stats(formsemestre_id): def formsemestre_status_menubar(sem): """HTML to render menubar""" - uid = current_user.user_name formsemestre_id = sem["formsemestre_id"] if int(sem["etat"]): change_lock_msg = "Verrouiller" @@ -156,10 +155,7 @@ def formsemestre_status_menubar(sem): }, "enabled": ( current_user.has_permission(Permission.ScoImplement) - or ( - current_user.user_name in sem["responsables"] - and sem["resp_can_edit"] - ) + or (current_user.id in sem["responsables"] and sem["resp_can_edit"]) ) and (sem["etat"]), "helpmsg": "Modifie le contenu du semestre (modules)", @@ -170,10 +166,7 @@ def formsemestre_status_menubar(sem): "args": {"formsemestre_id": formsemestre_id}, "enabled": ( current_user.has_permission(Permission.ScoImplement) - or ( - current_user.user_name in sem["responsables"] - and sem["resp_can_edit"] - ) + or (current_user.id in sem["responsables"] and sem["resp_can_edit"]) ) and (sem["etat"]), "helpmsg": "Préférences du semestre", @@ -182,7 +175,7 @@ def formsemestre_status_menubar(sem): "title": "Réglages bulletins", "endpoint": "notes.formsemestre_edit_options", "args": {"formsemestre_id": formsemestre_id}, - "enabled": (uid in sem["responsables"]) + "enabled": (current_user.id in sem["responsables"]) or current_user.has_permission(Permission.ScoImplement), "helpmsg": "Change les options", }, @@ -190,7 +183,7 @@ def formsemestre_status_menubar(sem): "title": change_lock_msg, "endpoint": "notes.formsemestre_change_lock", "args": {"formsemestre_id": formsemestre_id}, - "enabled": (uid in sem["responsables"]) + "enabled": (current_user.id in sem["responsables"]) or current_user.has_permission(Permission.ScoImplement), "helpmsg": "", }, @@ -1006,10 +999,7 @@ def formsemestre_status(formsemestre_id=None, REQUEST=None): Evaluations""" ) mails_enseignants = set( - [ - sco_users.user_info(ens_id, REQUEST)["email"] - for ens_id in sem["responsables"] - ] + [sco_users.user_info(ens_id)["email"] for ens_id in sem["responsables"]] ) # adr. mail des enseignants for M in Mlist: Mod = M["module"] diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index f84c800c7..989830e07 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -540,7 +540,7 @@ def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD ) doc.append(x_group) for etudid in etuds_set: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] x_group.append( Element( "etud", diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index ddb8a0edd..26fb6205a 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -293,7 +293,7 @@ def _make_table_notes( for etudid in etudids: css_row_class = None # infos identite etudiant - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] # infos inscription inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]} diff --git a/app/scodoc/sco_moduleimpl.py b/app/scodoc/sco_moduleimpl.py index 4bdba779c..dd4f6029b 100644 --- a/app/scodoc/sco_moduleimpl.py +++ b/app/scodoc/sco_moduleimpl.py @@ -27,7 +27,8 @@ """Fonctions sur les moduleimpl """ -# codes anciens déplacés de ZEntreprise + +from flask_login import current_user import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb @@ -321,17 +322,15 @@ def can_change_module_resp(REQUEST, moduleimpl_id): if not sem["etat"]: raise ScoValueError("Modification impossible: semestre verrouille") # -- check access - authuser = REQUEST.AUTHENTICATED_USER - uid = str(authuser) # admin ou resp. semestre avec flag resp_can_change_resp - if not authuser.has_permission(Permission.ScoImplement) and ( - (uid not in sem["responsables"]) or (not sem["resp_can_change_ens"]) + if not current_user.has_permission(Permission.ScoImplement) and ( + (current_user.id not in sem["responsables"]) or (not sem["resp_can_change_ens"]) ): - raise AccessDenied("Modification impossible pour %s" % uid) + raise AccessDenied("Modification impossible pour %s" % current_user) return M, sem -def can_change_ens(REQUEST, moduleimpl_id, raise_exc=True): +def can_change_ens(moduleimpl_id, raise_exc=True): "check if current user can modify ens list (raise exception if not)" M = do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0] # -- check lock @@ -342,16 +341,14 @@ def can_change_ens(REQUEST, moduleimpl_id, raise_exc=True): else: return False # -- check access - authuser = REQUEST.AUTHENTICATED_USER - uid = str(authuser) # admin, resp. module ou resp. semestre if ( - uid != M["responsable_id"] - and not authuser.has_permission(Permission.ScoImplement) - and (uid not in sem["responsables"]) + current_user.id != M["responsable_id"] + and not current_user.has_permission(Permission.ScoImplement) + and (current_user.id not in sem["responsables"]) ): if raise_exc: - raise AccessDenied("Modification impossible pour %s" % uid) + raise AccessDenied("Modification impossible pour %s" % current_user) else: return False return M, sem diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 0ee7bfb55..94b10ad24 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -204,7 +204,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None): ) H.append("""""") try: - sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) + sco_moduleimpl.can_change_ens(moduleimpl_id) H.append( """modifier les enseignants""" % moduleimpl_id @@ -247,7 +247,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None): 'Règle de calcul: moyenne=%s' % M["computation_expr"] ) - if sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id, raise_exc=False): + if sco_moduleimpl.can_change_ens(moduleimpl_id, raise_exc=False): H.append( 'modifier' % moduleimpl_id @@ -257,7 +257,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None): H.append( 'règle de calcul standard' ) - if sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id, raise_exc=False): + if sco_moduleimpl.can_change_ens(moduleimpl_id, raise_exc=False): H.append( ' (changer)' % moduleimpl_id diff --git a/app/scodoc/sco_news.py b/app/scodoc/sco_news.py index 0b0544ea0..a564bfd8c 100644 --- a/app/scodoc/sco_news.py +++ b/app/scodoc/sco_news.py @@ -90,7 +90,7 @@ def add(typ, object=None, text="", url=None, max_frequency=False): cnx = ndb.GetDBConnexion() args = { "authenticated_user": authuser_name, - "user_info": sco_users.user_info(user_name=authuser_name), + "user_info": sco_users.user_info(authuser_name), "type": typ, "object": object, "text": text, @@ -163,8 +163,7 @@ def scolar_news_summary(n=5): % infos ) n["text"] += ( - " par " - + sco_users.user_info(user_name=n["authenticated_user"])["nomcomplet"] + " par " + sco_users.user_info(n["authenticated_user"])["nomcomplet"] ) return news diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index 961c9d615..109c1ddf5 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -144,14 +144,13 @@ def _menuScolarite(authuser, sem, etudid): def ficheEtud(etudid=None, REQUEST=None): "fiche d'informations sur un etudiant" - log("XXX ficheEtud etudid=%s" % etudid) authuser = REQUEST.AUTHENTICATED_USER cnx = ndb.GetDBConnexion() if etudid and REQUEST: # la sidebar est differente s'il y a ou pas un etudid # voir html_sidebar.sidebar() REQUEST.form["etudid"] = etudid - args = sco_etud.make_etud_args(etudid=etudid, REQUEST=REQUEST) + args = sco_etud.make_etud_args(etudid=etudid) etuds = sco_etud.etudident_list(cnx, args) if not etuds: log("ficheEtud: etudid=%s REQUEST.form=%s" % (etudid, REQUEST.form)) @@ -494,7 +493,7 @@ def menus_etud(REQUEST=None): return "" authuser = REQUEST.AUTHENTICATED_USER - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] menuEtud = [ { @@ -539,7 +538,7 @@ def etud_info_html(etudid, with_photo="1", REQUEST=None, debug=False): """ formsemestre_id = sco_formsemestre_status.retreive_formsemestre_from_request() with_photo = int(with_photo) - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] photo_html = sco_photos.etud_photo_html( etud, title="fiche de " + etud["nom"], REQUEST=REQUEST ) diff --git a/app/scodoc/sco_permissions_check.py b/app/scodoc/sco_permissions_check.py index c062b0767..0bf77b390 100644 --- a/app/scodoc/sco_permissions_check.py +++ b/app/scodoc/sco_permissions_check.py @@ -6,6 +6,8 @@ from flask import g from flask_login import current_user +from app.auth.models import User + import app.scodoc.notesdb as ndb from app.scodoc.sco_permissions import Permission from app.scodoc import html_sco_header @@ -24,7 +26,6 @@ def can_edit_notes(authuser, moduleimpl_id, allow_ens=True): from app.scodoc import sco_formsemestre from app.scodoc import sco_parcours_dut - uid = str(authuser) M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"]) if not sem["etat"]: @@ -34,18 +35,18 @@ def can_edit_notes(authuser, moduleimpl_id, allow_ens=True): # il y a des décisions de jury dans ce semestre ! return ( authuser.has_permission(Permission.ScoEditAllNotes) - or uid in sem["responsables"] + or authuser.id in sem["responsables"] ) else: if ( (not authuser.has_permission(Permission.ScoEditAllNotes)) - and uid != M["responsable_id"] - and uid not in sem["responsables"] + and authuser.id != M["responsable_id"] + and authuser.id not in sem["responsables"] ): # enseignant (chargé de TD) ? if allow_ens: for ens in M["ens"]: - if ens["ens_id"] == uid: + if ens["ens_id"] == authuser.id: return True return False else: @@ -58,26 +59,23 @@ def can_edit_evaluation(moduleimpl_id=None): Sinon, lance une exception. (nb: n'implique pas le droit de saisir ou modifier des notes) """ - # was _evaluation_check_write_access - # AccessDenied("Modification évaluation impossible pour %s" % (uid,)) from app.scodoc import sco_formsemestre # acces pour resp. moduleimpl et resp. form semestre (dir etud) if moduleimpl_id is None: raise ValueError("no moduleimpl specified") # bug - uid = current_user.user_name M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"]) if ( current_user.has_permission(Permission.ScoEditAllEvals) - or uid == M["responsable_id"] - or uid in sem["responsables"] + or current_user.id == M["responsable_id"] + or current_user.id in sem["responsables"] ): return True elif sem["ens_can_edit_eval"]: for ens in M["ens"]: - if ens["ens_id"] == uid: + if ens["ens_id"] == current_user.id: return True return False @@ -130,7 +128,7 @@ def is_chef_or_diretud(sem): "Vrai si utilisateur est admin, chef dept ou responsable du semestre" if ( current_user.has_permission(Permission.ScoImplement) - or current_user.user_name in sem["responsables"] + or current_user.id in sem["responsables"] ): return True return False @@ -145,9 +143,9 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl sem = sco_formsemestre.get_formsemestre(formsemestre_id) header = html_sco_header.sco_header(page_title="Accès interdit") footer = html_sco_header.sco_footer() - if ( - current_user.user_name not in sem["responsables"] - ) and not current_user.has_permission(required_permission): + if (current_user.id not in sem["responsables"]) and not current_user.has_permission( + required_permission + ): return ( False, "\n".join( @@ -155,7 +153,9 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl header, "

Opération non autorisée pour %s

" % current_user, "

Responsable de ce semestre : %s

" - % ", ".join(sem["responsables"]), + % ", ".join( + [User.query.get(i).get_prenomnom() for i in sem["responsables"]] + ), footer, ] ), @@ -173,7 +173,7 @@ def can_change_groups(formsemestre_id): return False # semestre verrouillé if current_user.has_permission(Permission.ScoEtudChangeGroups): return True # admin, chef dept - if current_user.user_name in sem["responsables"]: + if current_user.id in sem["responsables"]: return True return False diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index e3f31a0bf..579ac8254 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -125,7 +125,7 @@ def get_photo_image(etudid=None, size="small", REQUEST=None): if not etudid: filename = UNKNOWN_IMAGE_PATH else: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] filename = photo_pathname(etud, size=size) if not filename: filename = UNKNOWN_IMAGE_PATH @@ -178,7 +178,7 @@ def etud_photo_html(etud=None, etudid=None, title=None, size="small", REQUEST=No """ if not etud: if etudid: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] else: raise ValueError("etud_photo_html: either etud or etudid must be specified") photo_url = etud_photo_url(etud, size=size) diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 0b15d5a1f..d7bc9c8ba 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -609,7 +609,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST= groups_infos = None if etudid: # PV pour ce seul étudiant: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etuddescr = '%s' % ( etudid, etud["nomprenom"], diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index b81c48d2b..41dce9baa 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -42,6 +42,8 @@ from reportlab.lib.pagesizes import A4, landscape from reportlab.lib import styles from reportlab.lib.colors import Color +from flask import g + import app.scodoc.sco_utils as scu from app.scodoc import sco_bulletins_pdf from app.scodoc import sco_codes_parcours diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index ee84ec57f..fceeb9def 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -194,7 +194,7 @@ def formsemestre_synchro_etuds( if a_desinscrire or a_desinscrire_without_key: H.append("

Etudiants à désinscrire :

    ") for key in a_desinscrire: - etud = sco_etud.get_etud_info(filled=1, code_nip=key)[0] + etud = sco_etud.get_etud_info(filled=True, code_nip=key)[0] H.append('
  1. %(nomprenom)s
  2. ' % etud) for etudid in a_desinscrire_without_key: etud = inscrits_without_key_all[etudid] @@ -794,7 +794,7 @@ def formsemestre_import_etud_admission( for i in ins: etudid = i["etudid"] - info = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + info = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] code_nip = info["code_nip"] if not code_nip: no_nip.append(etudid) diff --git a/app/scodoc/sco_ue_external.py b/app/scodoc/sco_ue_external.py index a2693c4d7..5c9f56261 100644 --- a/app/scodoc/sco_ue_external.py +++ b/app/scodoc/sco_ue_external.py @@ -81,7 +81,6 @@ def external_ue_create( acronyme="", ue_type=sco_codes_parcours.UE_STANDARD, ects=0.0, - REQUEST=None, ): """Crée UE/matiere/module/evaluation puis saisie les notes""" log("external_ue_create( formsemestre_id=%s, titre=%s )" % (formsemestre_id, titre)) @@ -127,9 +126,8 @@ def external_ue_create( { "module_id": module_id, "formsemestre_id": formsemestre_id, - "responsable_id": sem["responsables"][ - 0 - ], # affecte le 1er responsable du semestre comme resp. du module + # affecte le 1er responsable du semestre comme resp. du module + "responsable_id": sem["responsables"][0], }, ) @@ -217,7 +215,7 @@ def external_ue_create_form(formsemestre_id, etudid, REQUEST=None): if not sem["resp_can_edit"] or (current_user.id not in sem["responsables"]): raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération") - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] formation_id = sem["formation_id"] existing_external_ue = get_existing_external_ue(formation_id) @@ -357,7 +355,6 @@ def external_ue_create_form(formsemestre_id, etudid, REQUEST=None): ) moduleimpl_id = external_ue_create( formsemestre_id, - REQUEST=REQUEST, titre=tf[2]["titre"], acronyme=acronyme, ue_type=tf[2]["type"], # type de l'UE diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index 15935c79d..0068d14ab 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -238,17 +238,18 @@ def _user_list(user_name): return None -def user_info(user_name=None, user=None): +def user_info(user_name_or_id=None, user=None): """Dict avec infos sur l'utilisateur (qui peut ne pas etre dans notre base). Si user_name est specifie (string ou id), interroge la BD. Sinon, user doit etre une instance de User. """ - if user_name is not None: - if isinstance(user_name, int): - u = User.query.filter_by(id=user_name).first() + if user_name_or_id is not None: + if isinstance(user_name_or_id, int): + u = User.query.filter_by(id=user_name_or_id).first() else: - u = User.query.filter_by(user_name=user_name).first() + u = User.query.filter_by(user_name=user_name_or_id).first() if u: + user_name = u.user_name info = u.to_dict() else: info = None diff --git a/app/views/absences.py b/app/views/absences.py index 1b76a69e7..f7070e141 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -151,7 +151,7 @@ def index_html(REQUEST=None): H.append( """

    Pour signaler, annuler ou justifier une absence, choisissez d'abord l'étudiant concerné:

    """ ) - H.append(sco_find_etud.form_search_etud(REQUEST)) + H.append(sco_find_etud.form_search_etud()) if authuser.has_permission(Permission.ScoAbsChange): H.extend( ( @@ -1070,9 +1070,7 @@ def AddBilletAbsence( """ t0 = time.time() # check etudid - etuds = sco_etud.get_etud_info( - etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True - ) + etuds = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=True) if not etuds: return scu.log_unknown_etud(REQUEST=REQUEST) etud = etuds[0] @@ -1117,7 +1115,7 @@ def AddBilletAbsenceForm(etudid, REQUEST=None): """Formulaire ajout billet (pour tests seulement, le vrai formulaire accessible aux etudiants étant sur le portail étudiant). """ - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] H = [ html_sco_header.sco_header( page_title="Billet d'absence de %s" % etud["nomprenom"] @@ -1227,7 +1225,7 @@ def _tableBillets(billets, etud=None, title=""): @scodoc7func def listeBilletsEtud(etudid=False, REQUEST=None, format="html"): """Liste billets pour un etudiant""" - etuds = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST) + etuds = sco_etud.get_etud_info(filled=True, etudid=etudid) if not etuds: return scu.log_unknown_etud(format=format, REQUEST=REQUEST) @@ -1386,7 +1384,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None): ) billet = billets[0] etudid = billet["etudid"] - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] H = [ html_sco_header.sco_header( @@ -1470,7 +1468,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None): def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None): """returns list of absences in date interval""" t0 = time.time() - etud = sco_etud.get_etud_info(REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=False)[0] exp = re.compile(r"^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$") if not exp.match(beg_date): raise ScoValueError("invalid date: %s" % beg_date) diff --git a/app/views/notes.py b/app/views/notes.py index 0da9f18e2..307c8b69a 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -671,7 +671,7 @@ def formsemestre_custommenu_edit(REQUEST, formsemestre_id): @scodoc7func def edit_enseignants_form(REQUEST, moduleimpl_id): "modif liste enseignants/moduleimpl" - M, sem = sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) + M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id) # -- header = html_sco_header.html_sem_header( REQUEST, @@ -915,7 +915,7 @@ def edit_moduleimpl_expr(REQUEST, moduleimpl_id): """Edition formule calcul moyenne module Accessible par Admin, dir des etud et responsable module """ - M, sem = sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) + M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id) H = [ html_sco_header.html_sem_header( REQUEST, @@ -1230,12 +1230,12 @@ def formsemestre_enseignants_list(REQUEST, formsemestre_id, format="html"): @scodoc @permission_required(Permission.ScoView) @scodoc7func -def edit_enseignants_form_delete(REQUEST, moduleimpl_id, ens_id: int): +def edit_enseignants_form_delete(moduleimpl_id, ens_id: int): """remove ens from this modueimpl ens_id: user.id """ - M, _ = sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) + M, _ = sco_moduleimpl.can_change_ens(moduleimpl_id) # search ens_id ok = False for ens in M["ens"]: @@ -1319,7 +1319,7 @@ def formsemestre_desinscription( % (etudid, formsemestre_id) ) if not dialog_confirmed: - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] if sem["modalite"] != "EXT": msg_ext = """

    %s sera désinscrit de tous les modules du semestre %s (%s - %s).

    @@ -1867,7 +1867,7 @@ def appreciation_add_form( logdb(cnx, method="appreciation_suppress", etudid=etudid, msg="") return flask.redirect(bull_url) # - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] if id: a = "Edition" else: @@ -2144,7 +2144,7 @@ def formsemestre_validation_suppress_etud( ) if not dialog_confirmed: sem = sco_formsemestre.get_formsemestre(formsemestre_id) - etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] + etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_decision_sem decision_jury = nt.get_etud_decision_sem(etudid) if decision_jury: diff --git a/app/views/scolar.py b/app/views/scolar.py index 6c4aa4cca..917e65ebd 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -34,7 +34,6 @@ Emmanuel Viennet, 2021 import sys import time -# StringIO => io.StringIO or io.BytesIO for text and data respectively. #py3 from io import StringIO from zipfile import ZipFile @@ -134,7 +133,7 @@ log("ScoDoc8 restarting...") @scodoc @permission_required(Permission.ScoView) @scodoc7func -def about(REQUEST): +def about(): "version info" H = [ """

    Système de gestion scolarité

    @@ -180,18 +179,19 @@ def edit_preferences(REQUEST): @scodoc7func def formsemestre_edit_preferences(formsemestre_id, REQUEST): """Edit preferences for a semestre""" - authuser = REQUEST.AUTHENTICATED_USER sem = sco_formsemestre.get_formsemestre(formsemestre_id) ok = ( - authuser.has_permission(Permission.ScoImplement) - or ((str(authuser) in sem["responsables"]) and sem["resp_can_edit"]) + current_user.has_permission(Permission.ScoImplement) + or ((current_user.id in sem["responsables"]) and sem["resp_can_edit"]) ) and (sem["etat"]) if ok: return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit( REQUEST=REQUEST ) else: - raise AccessDenied("Modification impossible pour %s" % authuser) + raise AccessDenied( + "Modification impossible pour %s" % current_user.get_nomplogin() + ) @bp.route("/doc_preferences") @@ -217,7 +217,7 @@ def doc_preferences(REQUEST): @scodoc7func def showEtudLog(etudid, format="html", REQUEST=None): """Display log of operations on this student""" - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] ops = sco_etud.list_scolog(etudid) @@ -309,9 +309,7 @@ def getEtudInfo(etudid=False, code_nip=False, filled=False, REQUEST=None, format ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine (dans cet ordre). """ - etud = sco_etud.get_etud_info( - etudid=etudid, code_nip=code_nip, filled=filled, REQUEST=REQUEST - ) + etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled) if format is None: return etud else: @@ -339,7 +337,7 @@ sco_publish( def etud_info(etudid=None, format="xml", REQUEST=None): "Donne les informations sur un etudiant" t0 = time.time() - args = sco_etud.make_etud_args(etudid=etudid, REQUEST=REQUEST) + args = sco_etud.make_etud_args(etudid=etudid) cnx = ndb.GetDBConnexion() etuds = sco_etud.etudident_list(cnx, args) if not etuds: @@ -562,7 +560,7 @@ def doSuppressAnnotation(etudid, annotation_id, REQUEST): def formChangeCoordonnees(etudid, REQUEST): "edit coordonnees etudiant" cnx = ndb.GetDBConnexion() - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] adrs = sco_etud.adresse_list(cnx, {"etudid": etudid}) if adrs: adr = adrs[0] @@ -747,7 +745,7 @@ sco_publish("/etud_photo_html", sco_photos.etud_photo_html, Permission.ScoView) @scodoc7func def etud_photo_orig_page(etudid=None, REQUEST=None): "Page with photo in orig. size" - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] H = [ html_sco_header.sco_header(page_title=etud["nomprenom"]), "

    %s

    " % etud["nomprenom"], @@ -766,7 +764,7 @@ def etud_photo_orig_page(etudid=None, REQUEST=None): @scodoc7func def formChangePhoto(etudid=None, REQUEST=None): """Formulaire changement photo étudiant""" - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] if sco_photos.etud_photo_is_local(etud): etud["photoloc"] = "dans ScoDoc" else: @@ -824,7 +822,7 @@ def formChangePhoto(etudid=None, REQUEST=None): @scodoc7func def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False): """Formulaire suppression photo étudiant""" - etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True)[0] if not dialog_confirmed: return scu.confirm_dialog( "

    Confirmer la suppression de la photo de %(nomprenom)s ?

    " % etud, @@ -881,7 +879,7 @@ def _formDem_of_Def( operation_method="", ): "Formulaire démission ou défaillance Etudiant" - etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] + etud = sco_etud.get_etud_info(filled=True, etudid=etudid)[0] sem = sco_formsemestre.get_formsemestre(formsemestre_id) if not sem["etat"]: raise ScoValueError("Modification impossible: semestre verrouille") diff --git a/app/views/users.py b/app/views/users.py index 01c30277d..7238da64b 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -84,7 +84,7 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"): @permission_required(Permission.ScoUsersView) @scodoc7func def user_info(user_name, format="json", REQUEST=None): - info = sco_users.user_info(user_name=user_name) + info = sco_users.user_info(user_name) return scu.sendResult(REQUEST, info, name="user", format=format)