1
0
forked from ScoDoc/ScoDoc

gestion responsables de semestres

This commit is contained in:
Emmanuel Viennet 2021-08-22 13:24:36 +02:00
parent 2a38de8e89
commit d8dfa0201e
35 changed files with 158 additions and 169 deletions

View File

@ -107,7 +107,7 @@ def sidebar():
etudid = request.form.get("etudid", None) etudid = request.form.get("etudid", None)
if etudid: 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.update(etud)
params["fiche_url"] = url_for( params["fiche_url"] = url_for(
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid "scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid

View File

@ -147,7 +147,7 @@ def abs_notify_get_destinations(sem, prefs, etudid, date, nbabs, nbabsjust):
if prefs["abs_notify_email"]: if prefs["abs_notify_email"]:
destinations.append(prefs["abs_notify_email"]) destinations.append(prefs["abs_notify_email"])
if prefs["abs_notify_etud"]: 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"]: if etud["email_default"]:
destinations.append(etud["email_default"]) destinations.append(etud["email_default"])

View File

@ -71,7 +71,7 @@ def doSignaleAbsence(
description: str description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form 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"] etudid = etud["etudid"]
if not moduleimpl_id: if not moduleimpl_id:
moduleimpl_id = None moduleimpl_id = None
@ -151,7 +151,7 @@ def doSignaleAbsence(
<hr>""" <hr>"""
% etud % 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()) H.append(html_sco_header.sco_footer())
return "\n".join(H) return "\n".join(H)
@ -159,7 +159,7 @@ def doSignaleAbsence(
def SignaleAbsenceEtud(REQUEST=None): # etudid implied def SignaleAbsenceEtud(REQUEST=None): # etudid implied
"""Formulaire individuel simple de signalement d'une absence""" """Formulaire individuel simple de signalement d'une absence"""
# brute-force portage from very old dtml code ... # 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"] etudid = etud["etudid"]
disabled = False disabled = False
if not etud["cursem"]: if not etud["cursem"]:
@ -293,7 +293,7 @@ def doJustifAbsence(
description: str description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form 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"] etudid = etud["etudid"]
description_abs = description description_abs = description
dates = sco_abs.DateRangeISO(datedebut, datefin) dates = sco_abs.DateRangeISO(datedebut, datefin)
@ -352,7 +352,7 @@ def doJustifAbsence(
<hr>""" <hr>"""
% etud % 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()) H.append(html_sco_header.sco_footer())
return "\n".join(H) return "\n".join(H)
@ -360,7 +360,7 @@ def doJustifAbsence(
def JustifAbsenceEtud(REQUEST=None): # etudid implied def JustifAbsenceEtud(REQUEST=None): # etudid implied
"""Formulaire individuel simple de justification d'une absence""" """Formulaire individuel simple de justification d'une absence"""
# brute-force portage from very old dtml code ... # 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"] etudid = etud["etudid"]
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
@ -416,7 +416,7 @@ def doAnnuleAbsence(
datedebut, datefin, demijournee, etudid=False, REQUEST=None datedebut, datefin, demijournee, etudid=False, REQUEST=None
): # etudid implied ): # etudid implied
"""Annulation des absences pour une demi journée""" """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"] etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(datedebut, datefin) dates = sco_abs.DateRangeISO(datedebut, datefin)
@ -457,7 +457,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
<hr>""" <hr>"""
% etud % 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()) H.append(html_sco_header.sco_footer())
return "\n".join(H) return "\n".join(H)
@ -465,7 +465,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
def AnnuleAbsenceEtud(REQUEST=None): # etudid implied def AnnuleAbsenceEtud(REQUEST=None): # etudid implied
"""Formulaire individuel simple d'annulation d'une absence""" """Formulaire individuel simple d'annulation d'une absence"""
# brute-force portage from very old dtml code ... # 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"] etudid = etud["etudid"]
H = [ H = [
@ -550,7 +550,7 @@ def AnnuleAbsenceEtud(REQUEST=None): # etudid implied
def doAnnuleJustif(datedebut0, datefin0, demijournee, REQUEST=None): # etudid implied def doAnnuleJustif(datedebut0, datefin0, demijournee, REQUEST=None): # etudid implied
"""Annulation d'une justification""" """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"] etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(datedebut0, datefin0) dates = sco_abs.DateRangeISO(datedebut0, datefin0)
nbadded = 0 nbadded = 0
@ -591,7 +591,7 @@ autre absence pour <b>%(nomprenom)s</b></a></li>
<hr>""" <hr>"""
% etud % 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()) H.append(html_sco_header.sco_footer())
return "\n".join(H) return "\n".join(H)
@ -713,7 +713,7 @@ def CalAbs(etudid, sco_year=None):
"""Calendrier des absences d'un etudiant""" """Calendrier des absences d'un etudiant"""
# crude portage from 1999 DTML # crude portage from 1999 DTML
REQUEST = None # XXX 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"] etudid = etud["etudid"]
anneescolaire = int(scu.AnneeScolaire(sco_year)) anneescolaire = int(scu.AnneeScolaire(sco_year))
datedebut = str(anneescolaire) + "-08-01" datedebut = str(anneescolaire) + "-08-01"

View File

@ -131,7 +131,7 @@ def etud_upload_file_form(REQUEST, etudid):
raise AccessDenied( raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER) "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 = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
page_title="Chargement d'un document associé à %(nomprenom)s" % etud, 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( raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER) "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) archive_id = EtudsArchive.get_id_from_name(etudid, archive_name)
if not dialog_confirmed: if not dialog_confirmed:
return scu.confirm_dialog( return scu.confirm_dialog(

View File

@ -87,7 +87,7 @@ def make_context_dict(sem, etud):
C = sem.copy() C = sem.copy()
C["responsable"] = " ,".join( 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"] for responsable_id in sem["responsables"]
] ]
) )
@ -156,7 +156,7 @@ def formsemestre_bulletinetud_dict(
I["formation"]["type_parcours"] I["formation"]["type_parcours"]
) )
# Infos sur l'etudiant # 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"] I["descr_situation"] = I["etud"]["inscriptionstr"]
if I["etud"]["inscription_formsemestre_id"]: if I["etud"]["inscription_formsemestre_id"]:
I[ I[
@ -772,7 +772,7 @@ def formsemestre_bulletinetud(
): ):
"page bulletin de notes" "page bulletin de notes"
try: try:
etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] etud = sco_etud.get_etud_info(filled=True)[0]
etudid = etud["etudid"] etudid = etud["etudid"]
except: except:
return scu.log_unknown_etud(REQUEST, format=format) return scu.log_unknown_etud(REQUEST, format=format)
@ -842,7 +842,7 @@ def can_send_bulletin_by_mail(formsemestre_id):
return ( return (
sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id) sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id)
or current_user.has_permission(Permission.ScoImplement) 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, version=None,
REQUEST=None, REQUEST=None,
): ):
authuser = REQUEST.AUTHENTICATED_USER
uid = str(authuser)
H = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
page_title="Bulletin de %(nomprenom)s" % etud, page_title="Bulletin de %(nomprenom)s" % etud,
@ -1077,8 +1075,8 @@ def _formsemestre_bulletinetud_header_html(
"title": "Réglages bulletins", "title": "Réglages bulletins",
"endpoint": "notes.formsemestre_edit_options", "endpoint": "notes.formsemestre_edit_options",
"args": {"formsemestre_id": formsemestre_id, "target_url": qurl}, "args": {"formsemestre_id": formsemestre_id, "target_url": qurl},
"enabled": (uid in sem["responsables"]) "enabled": (current_user.id in sem["responsables"])
or authuser.has_permission(Permission.ScoImplement), or current_user.has_permission(Permission.ScoImplement),
}, },
{ {
"title": 'Version papier (pdf, format "%s")' "title": 'Version papier (pdf, format "%s")'
@ -1137,8 +1135,8 @@ def _formsemestre_bulletinetud_header_html(
"etudid": etudid, "etudid": etudid,
}, },
"enabled": ( "enabled": (
(authuser in sem["responsables"]) (current_user.id in sem["responsables"])
or (authuser.has_permission(Permission.ScoEtudInscrit)) or (current_user.has_permission(Permission.ScoEtudInscrit))
), ),
}, },
{ {
@ -1148,7 +1146,7 @@ def _formsemestre_bulletinetud_header_html(
"formsemestre_id": formsemestre_id, "formsemestre_id": formsemestre_id,
"etudid": etudid, "etudid": etudid,
}, },
"enabled": authuser.has_permission(Permission.ScoImplement), "enabled": current_user.has_permission(Permission.ScoImplement),
}, },
{ {
"title": "Enregistrer une validation d'UE antérieure", "title": "Enregistrer une validation d'UE antérieure",

View File

@ -117,7 +117,7 @@ def formsemestre_bulletinetud_published_dict(
d.update(**el) d.update(**el)
# Infos sur l'etudiant # 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( d["etudiant"] = dict(
etudid=etudid, etudid=etudid,

View File

@ -314,7 +314,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
# --- Appreciations # --- Appreciations
# le dir. des etud peut ajouter des appreciations, # le dir. des etud peut ajouter des appreciations,
# mais aussi le chef (perm. ScoEtudInscrit) # 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) authuser.has_permission(Permission.ScoEtudInscrit)
) )
H.append('<div class="bull_appreciations">') H.append('<div class="bull_appreciations">')

View File

@ -224,7 +224,7 @@ def get_etud_bulletins_pdf(etudid, REQUEST, 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
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
fragments = [] fragments = []
bookmarks = {} bookmarks = {}
filigrannes = {} filigrannes = {}

View File

@ -144,7 +144,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
# ---- APPRECIATIONS # ---- APPRECIATIONS
# le dir. des etud peut ajouter des appreciations, # le dir. des etud peut ajouter des appreciations,
# mais aussi le chef (perm. ScoEtudInscrit) # 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) self.authuser.has_permission(Permission.ScoEtudInscrit)
) )
H.append('<div class="bull_appreciations">') H.append('<div class="bull_appreciations">')

View File

@ -111,7 +111,7 @@ def make_xml_formsemestre_bulletinetud(
is_appending = False is_appending = False
doc = x doc = x
# Infos sur l'etudiant # 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( doc.append(
Element( Element(
"etudiant", "etudiant",

View File

@ -162,7 +162,7 @@ def compute_user_formula(
if user_moy != "NA0" and user_moy != "NA": if user_moy != "NA0" and user_moy != "NA":
user_moy = float(user_moy) user_moy = float(user_moy)
if (user_moy > 20) or (user_moy < 0): 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( raise ScoException(
"""valeur moyenne %s hors limite pour <a href="formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s">%s</a>""" """valeur moyenne %s hors limite pour <a href="formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s">%s</a>"""

View File

@ -108,7 +108,7 @@ def table_debouche_etudids(etudids, keep_numeric=True):
"""Rapport pour ces etudiants""" """Rapport pour ces etudiants"""
L = [] L = []
for etudid in etudids: 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) # retrouve le "dernier" semestre (au sens de la date de fin)
sems = etud["sems"] sems = etud["sems"]
es = [(s["date_fin_iso"], i) for i, s in enumerate(sems)] es = [(s["date_fin_iso"], i) for i, s in enumerate(sems)]

View File

@ -32,7 +32,7 @@
import os import os
import time import time
from flask import url_for, g from flask import url_for, g, request
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
@ -630,10 +630,10 @@ etudident_edit = _etudidentEditor.edit
etudident_create = _etudidentEditor.create 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 """forme args dict pour requete recherche etudiant
On peut specifier etudid 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). (dans cet ordre).
""" """
args = None args = None
@ -641,19 +641,25 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True):
args = {"etudid": etudid} args = {"etudid": etudid}
elif code_nip: elif code_nip:
args = {"code_nip": code_nip} args = {"code_nip": code_nip}
elif REQUEST: elif use_request: # use form from current request (Flask global)
if "etudid" in REQUEST.form: if request.method == "POST":
args = {"etudid": int(REQUEST.form["etudid"])} vals = request.form
elif "code_nip" in REQUEST.form: elif request.method == "GET":
args = {"code_nip": REQUEST.form["code_nip"]} vals = request.args
elif "code_ine" in REQUEST.form: else:
args = {"code_ine": REQUEST.form["code_ine"]} 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: if not args and raise_exc:
raise ValueError("getEtudInfo: no parameter !") raise ValueError("getEtudInfo: no parameter !")
return args 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) """infos sur un etudiant (API)
On peut specifier etudid ou conde_nip On peut specifier etudid ou conde_nip
ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine 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: if etudid is None:
return [] return []
cnx = ndb.GetDBConnexion() 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) etud = etudident_list(cnx, args=args)
if filled: if filled:

View File

@ -28,7 +28,7 @@
"""Recherche d'étudiants """Recherche d'étudiants
""" """
import flask import flask
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 import app
@ -44,7 +44,6 @@ from app.scodoc import sco_preferences
def form_search_etud( def form_search_etud(
REQUEST=None,
dest_url=None, dest_url=None,
parameters=None, parameters=None,
parameters_keys=None, parameters_keys=None,
@ -77,7 +76,13 @@ def form_search_etud(
) )
elif parameters_keys: elif parameters_keys:
for key in parameters_keys.split(","): 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: if v:
H.append('<input type="hidden" name="%s" value="%s"/>' % (key, v)) H.append('<input type="hidden" name="%s" value="%s"/>' % (key, v))
H.append( H.append(
@ -105,13 +110,14 @@ def search_etud_in_dept(expnom="", REQUEST=None):
Args: Args:
expnom: string, regexp sur le nom ou un code_nip ou un etudid expnom: string, regexp sur le nom ou un code_nip ou un etudid
""" """
breakpoint()
if isinstance(expnom, int) or len(expnom) > 1: if isinstance(expnom, int) or len(expnom) > 1:
try: try:
etudid = int(expnom) etudid = int(expnom)
except ValueError: except ValueError:
etudid = None etudid = None
if etudid is not 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 (etudid is None) or len(etuds) != 1:
if scu.is_valid_code_nip(expnom): if scu.is_valid_code_nip(expnom):
etuds = search_etuds_infos(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( dest_url=url_for(
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept "scolar.ficheEtud", scodoc_dept=g.scodoc_dept
), # sans l'etudid, post du form ), # sans l'etudid, post du form
REQUEST=REQUEST,
title="Autre recherche", title="Autre recherche",
), ),
] ]
@ -174,7 +179,6 @@ def search_etud_in_dept(expnom="", REQUEST=None):
H.append( H.append(
form_search_etud( form_search_etud(
dest_url=url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept), dest_url=url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept),
REQUEST=REQUEST,
title="Autre recherche", title="Autre recherche",
) )
) )

View File

@ -267,9 +267,9 @@ def do_formsemestre_edit(sem, cnx=None, **kw):
) # > modif formsemestre ) # > 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 """recupere liste des responsables de ce semestre
:returns: liste de chaines :returns: liste d'id
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT responsable_id """SELECT responsable_id

View File

@ -35,6 +35,7 @@ import time
import flask import flask
from flask import url_for, g from flask import url_for, g
from flask_login import current_user
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
@ -60,12 +61,12 @@ def formsemestre_ext_create(etudid, sem_params, REQUEST=None):
args={"formation_id": sem_params["formation_id"]} args={"formation_id": sem_params["formation_id"]}
)[0] )[0]
if etudid: 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 # Create formsemestre
sem_params["modalite"] = "EXT" sem_params["modalite"] = "EXT"
sem_params["etapes"] = None 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) formsemestre_id = sco_formsemestre.do_formsemestre_create(sem_params, silent=True)
# nota: le semestre est créé vide: pas de modules # 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): def formsemestre_ext_create_form(etudid, formsemestre_id, REQUEST=None):
"""Formulaire creation/inscription à un semestre extérieur""" """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 = [ H = [
html_sco_header.sco_header(), html_sco_header.sco_header(),
"""<h2>Enregistrement d'une inscription antérieure dans un autre établissement</h2> """<h2>Enregistrement d'une inscription antérieure dans un autre établissement</h2>

View File

@ -251,13 +251,12 @@ def formsemestre_inscription_with_modules_etud(
"""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.
""" """
if not etudid: if etudid is None:
return sco_find_etud.form_search_etud( return sco_find_etud.form_search_etud(
title="Choix de l'étudiant à inscrire dans ce semestre", title="Choix de l'étudiant à inscrire dans ce semestre",
add_headers=True, add_headers=True,
dest_url="formsemestre_inscription_with_modules_etud", dest_url="formsemestre_inscription_with_modules_etud",
parameters={"formsemestre_id": formsemestre_id}, parameters={"formsemestre_id": formsemestre_id},
REQUEST=REQUEST,
) )
return formsemestre_inscription_with_modules( 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. """Formulaire inscription de l'etud dans l'un des semestres existants.
Si only_ext, ne montre que les semestre extérieurs. 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 = [ H = [
html_sco_header.sco_header(), html_sco_header.sco_header(),
"<h2>Inscription de %s" % etud["nomprenom"], "<h2>Inscription de %s" % etud["nomprenom"],
@ -329,7 +328,7 @@ def formsemestre_inscription_with_modules(
if multiple_ok: if multiple_ok:
multiple_ok = int(multiple_ok) multiple_ok = int(multiple_ok)
sem = sco_formsemestre.get_formsemestre(formsemestre_id) 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 = [ H = [
html_sco_header.html_sem_header( html_sco_header.html_sem_header(
REQUEST, REQUEST,
@ -436,7 +435,7 @@ def formsemestre_inscription_option(etudid, formsemestre_id, REQUEST=None):
if not sem["etat"]: if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille") 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 nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_ue_status
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
@ -722,7 +721,7 @@ def est_inscrit_ailleurs(etudid, formsemestre_id):
temps que celui indiqué (par formsemestre_id). temps que celui indiqué (par formsemestre_id).
Retourne la liste des semestres concernés (ou liste vide). 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) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
debut_s = sem["dateord"] debut_s = sem["dateord"]
fin_s = ndb.DateDMYtoISO(sem["date_fin"]) 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) insd = list_inscrits_ailleurs(formsemestre_id)
# liste ordonnée par nom # liste ordonnée par nom
etudlist = [ 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() for etudid in insd.keys()
if insd[etudid] if insd[etudid]
] ]

View File

@ -123,7 +123,6 @@ def _build_menu_stats(formsemestre_id):
def formsemestre_status_menubar(sem): def formsemestre_status_menubar(sem):
"""HTML to render menubar""" """HTML to render menubar"""
uid = current_user.user_name
formsemestre_id = sem["formsemestre_id"] formsemestre_id = sem["formsemestre_id"]
if int(sem["etat"]): if int(sem["etat"]):
change_lock_msg = "Verrouiller" change_lock_msg = "Verrouiller"
@ -156,10 +155,7 @@ def formsemestre_status_menubar(sem):
}, },
"enabled": ( "enabled": (
current_user.has_permission(Permission.ScoImplement) current_user.has_permission(Permission.ScoImplement)
or ( or (current_user.id in sem["responsables"] and sem["resp_can_edit"])
current_user.user_name in sem["responsables"]
and sem["resp_can_edit"]
)
) )
and (sem["etat"]), and (sem["etat"]),
"helpmsg": "Modifie le contenu du semestre (modules)", "helpmsg": "Modifie le contenu du semestre (modules)",
@ -170,10 +166,7 @@ def formsemestre_status_menubar(sem):
"args": {"formsemestre_id": formsemestre_id}, "args": {"formsemestre_id": formsemestre_id},
"enabled": ( "enabled": (
current_user.has_permission(Permission.ScoImplement) current_user.has_permission(Permission.ScoImplement)
or ( or (current_user.id in sem["responsables"] and sem["resp_can_edit"])
current_user.user_name in sem["responsables"]
and sem["resp_can_edit"]
)
) )
and (sem["etat"]), and (sem["etat"]),
"helpmsg": "Préférences du semestre", "helpmsg": "Préférences du semestre",
@ -182,7 +175,7 @@ def formsemestre_status_menubar(sem):
"title": "Réglages bulletins", "title": "Réglages bulletins",
"endpoint": "notes.formsemestre_edit_options", "endpoint": "notes.formsemestre_edit_options",
"args": {"formsemestre_id": formsemestre_id}, "args": {"formsemestre_id": formsemestre_id},
"enabled": (uid in sem["responsables"]) "enabled": (current_user.id in sem["responsables"])
or current_user.has_permission(Permission.ScoImplement), or current_user.has_permission(Permission.ScoImplement),
"helpmsg": "Change les options", "helpmsg": "Change les options",
}, },
@ -190,7 +183,7 @@ def formsemestre_status_menubar(sem):
"title": change_lock_msg, "title": change_lock_msg,
"endpoint": "notes.formsemestre_change_lock", "endpoint": "notes.formsemestre_change_lock",
"args": {"formsemestre_id": formsemestre_id}, "args": {"formsemestre_id": formsemestre_id},
"enabled": (uid in sem["responsables"]) "enabled": (current_user.id in sem["responsables"])
or current_user.has_permission(Permission.ScoImplement), or current_user.has_permission(Permission.ScoImplement),
"helpmsg": "", "helpmsg": "",
}, },
@ -1006,10 +999,7 @@ def formsemestre_status(formsemestre_id=None, REQUEST=None):
<th class="evals">Evaluations</th></tr>""" <th class="evals">Evaluations</th></tr>"""
) )
mails_enseignants = set( mails_enseignants = set(
[ [sco_users.user_info(ens_id)["email"] for ens_id in sem["responsables"]]
sco_users.user_info(ens_id, REQUEST)["email"]
for ens_id in sem["responsables"]
]
) # adr. mail des enseignants ) # adr. mail des enseignants
for M in Mlist: for M in Mlist:
Mod = M["module"] Mod = M["module"]

View File

@ -540,7 +540,7 @@ def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD
) )
doc.append(x_group) doc.append(x_group)
for etudid in etuds_set: 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( x_group.append(
Element( Element(
"etud", "etud",

View File

@ -293,7 +293,7 @@ def _make_table_notes(
for etudid in etudids: for etudid in etudids:
css_row_class = None css_row_class = None
# infos identite etudiant # 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 # infos inscription
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]} {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}

View File

@ -27,7 +27,8 @@
"""Fonctions sur les moduleimpl """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.sco_utils as scu
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
@ -321,17 +322,15 @@ def can_change_module_resp(REQUEST, moduleimpl_id):
if not sem["etat"]: if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille") raise ScoValueError("Modification impossible: semestre verrouille")
# -- check access # -- check access
authuser = REQUEST.AUTHENTICATED_USER
uid = str(authuser)
# admin ou resp. semestre avec flag resp_can_change_resp # admin ou resp. semestre avec flag resp_can_change_resp
if not authuser.has_permission(Permission.ScoImplement) and ( if not current_user.has_permission(Permission.ScoImplement) and (
(uid not in sem["responsables"]) or (not sem["resp_can_change_ens"]) (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 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)" "check if current user can modify ens list (raise exception if not)"
M = do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0] M = do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
# -- check lock # -- check lock
@ -342,16 +341,14 @@ def can_change_ens(REQUEST, moduleimpl_id, raise_exc=True):
else: else:
return False return False
# -- check access # -- check access
authuser = REQUEST.AUTHENTICATED_USER
uid = str(authuser)
# admin, resp. module ou resp. semestre # admin, resp. module ou resp. semestre
if ( if (
uid != M["responsable_id"] current_user.id != M["responsable_id"]
and not authuser.has_permission(Permission.ScoImplement) and not current_user.has_permission(Permission.ScoImplement)
and (uid not in sem["responsables"]) and (current_user.id not in sem["responsables"])
): ):
if raise_exc: if raise_exc:
raise AccessDenied("Modification impossible pour %s" % uid) raise AccessDenied("Modification impossible pour %s" % current_user)
else: else:
return False return False
return M, sem return M, sem

View File

@ -204,7 +204,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None):
) )
H.append("""</td><td>""") H.append("""</td><td>""")
try: try:
sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) sco_moduleimpl.can_change_ens(moduleimpl_id)
H.append( H.append(
"""<a class="stdlink" href="edit_enseignants_form?moduleimpl_id=%s">modifier les enseignants</a>""" """<a class="stdlink" href="edit_enseignants_form?moduleimpl_id=%s">modifier les enseignants</a>"""
% moduleimpl_id % moduleimpl_id
@ -247,7 +247,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None):
'<tr><td class="fichetitre2" colspan="4">Règle de calcul: <span class="formula" title="mode de calcul de la moyenne du module">moyenne=<tt>%s</tt></span>' '<tr><td class="fichetitre2" colspan="4">Règle de calcul: <span class="formula" title="mode de calcul de la moyenne du module">moyenne=<tt>%s</tt></span>'
% M["computation_expr"] % 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( H.append(
'<span class="fl"><a class="stdlink" href="edit_moduleimpl_expr?moduleimpl_id=%s">modifier</a></span>' '<span class="fl"><a class="stdlink" href="edit_moduleimpl_expr?moduleimpl_id=%s">modifier</a></span>'
% moduleimpl_id % moduleimpl_id
@ -257,7 +257,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None, REQUEST=None):
H.append( H.append(
'<tr><td colspan="4"><em title="mode de calcul de la moyenne du module">règle de calcul standard</em>' '<tr><td colspan="4"><em title="mode de calcul de la moyenne du module">règle de calcul standard</em>'
) )
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( H.append(
' (<a class="stdlink" href="edit_moduleimpl_expr?moduleimpl_id=%s">changer</a>)' ' (<a class="stdlink" href="edit_moduleimpl_expr?moduleimpl_id=%s">changer</a>)'
% moduleimpl_id % moduleimpl_id

View File

@ -90,7 +90,7 @@ def add(typ, object=None, text="", url=None, max_frequency=False):
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
args = { args = {
"authenticated_user": authuser_name, "authenticated_user": authuser_name,
"user_info": sco_users.user_info(user_name=authuser_name), "user_info": sco_users.user_info(authuser_name),
"type": typ, "type": typ,
"object": object, "object": object,
"text": text, "text": text,
@ -163,8 +163,7 @@ def scolar_news_summary(n=5):
% infos % infos
) )
n["text"] += ( n["text"] += (
" par " " par " + sco_users.user_info(n["authenticated_user"])["nomcomplet"]
+ sco_users.user_info(user_name=n["authenticated_user"])["nomcomplet"]
) )
return news return news

View File

@ -144,14 +144,13 @@ def _menuScolarite(authuser, sem, etudid):
def ficheEtud(etudid=None, REQUEST=None): def ficheEtud(etudid=None, REQUEST=None):
"fiche d'informations sur un etudiant" "fiche d'informations sur un etudiant"
log("XXX ficheEtud etudid=%s" % etudid)
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
if etudid and REQUEST: if etudid and REQUEST:
# 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 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) 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.form=%s" % (etudid, REQUEST.form))
@ -494,7 +493,7 @@ def menus_etud(REQUEST=None):
return "" return ""
authuser = REQUEST.AUTHENTICATED_USER 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 = [ 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() formsemestre_id = sco_formsemestre_status.retreive_formsemestre_from_request()
with_photo = int(with_photo) 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( photo_html = sco_photos.etud_photo_html(
etud, title="fiche de " + etud["nom"], REQUEST=REQUEST etud, title="fiche de " + etud["nom"], REQUEST=REQUEST
) )

View File

@ -6,6 +6,8 @@
from flask import g from flask import g
from flask_login import current_user from flask_login import current_user
from app.auth.models import User
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header 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_formsemestre
from app.scodoc import sco_parcours_dut from app.scodoc import sco_parcours_dut
uid = str(authuser)
M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if not sem["etat"]: 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 ! # il y a des décisions de jury dans ce semestre !
return ( return (
authuser.has_permission(Permission.ScoEditAllNotes) authuser.has_permission(Permission.ScoEditAllNotes)
or uid in sem["responsables"] or authuser.id in sem["responsables"]
) )
else: else:
if ( if (
(not authuser.has_permission(Permission.ScoEditAllNotes)) (not authuser.has_permission(Permission.ScoEditAllNotes))
and uid != M["responsable_id"] and authuser.id != M["responsable_id"]
and uid not in sem["responsables"] and authuser.id not in sem["responsables"]
): ):
# enseignant (chargé de TD) ? # enseignant (chargé de TD) ?
if allow_ens: if allow_ens:
for ens in M["ens"]: for ens in M["ens"]:
if ens["ens_id"] == uid: if ens["ens_id"] == authuser.id:
return True return True
return False return False
else: else:
@ -58,26 +59,23 @@ def can_edit_evaluation(moduleimpl_id=None):
Sinon, lance une exception. Sinon, lance une exception.
(nb: n'implique pas le droit de saisir ou modifier des notes) (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 from app.scodoc import sco_formsemestre
# acces pour resp. moduleimpl et resp. form semestre (dir etud) # acces pour resp. moduleimpl et resp. form semestre (dir etud)
if moduleimpl_id is None: if moduleimpl_id is None:
raise ValueError("no moduleimpl specified") # bug raise ValueError("no moduleimpl specified") # bug
uid = current_user.user_name
M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] M = sco_moduleimpl.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if ( if (
current_user.has_permission(Permission.ScoEditAllEvals) current_user.has_permission(Permission.ScoEditAllEvals)
or uid == M["responsable_id"] or current_user.id == M["responsable_id"]
or uid in sem["responsables"] or current_user.id in sem["responsables"]
): ):
return True return True
elif sem["ens_can_edit_eval"]: elif sem["ens_can_edit_eval"]:
for ens in M["ens"]: for ens in M["ens"]:
if ens["ens_id"] == uid: if ens["ens_id"] == current_user.id:
return True return True
return False return False
@ -130,7 +128,7 @@ def is_chef_or_diretud(sem):
"Vrai si utilisateur est admin, chef dept ou responsable du semestre" "Vrai si utilisateur est admin, chef dept ou responsable du semestre"
if ( if (
current_user.has_permission(Permission.ScoImplement) current_user.has_permission(Permission.ScoImplement)
or current_user.user_name in sem["responsables"] or current_user.id in sem["responsables"]
): ):
return True return True
return False return False
@ -145,9 +143,9 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
header = html_sco_header.sco_header(page_title="Accès interdit") header = html_sco_header.sco_header(page_title="Accès interdit")
footer = html_sco_header.sco_footer() footer = html_sco_header.sco_footer()
if ( if (current_user.id not in sem["responsables"]) and not current_user.has_permission(
current_user.user_name not in sem["responsables"] required_permission
) and not current_user.has_permission(required_permission): ):
return ( return (
False, False,
"\n".join( "\n".join(
@ -155,7 +153,9 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
header, header,
"<h2>Opération non autorisée pour %s</h2>" % current_user, "<h2>Opération non autorisée pour %s</h2>" % current_user,
"<p>Responsable de ce semestre : <b>%s</b></p>" "<p>Responsable de ce semestre : <b>%s</b></p>"
% ", ".join(sem["responsables"]), % ", ".join(
[User.query.get(i).get_prenomnom() for i in sem["responsables"]]
),
footer, footer,
] ]
), ),
@ -173,7 +173,7 @@ def can_change_groups(formsemestre_id):
return False # semestre verrouillé return False # semestre verrouillé
if current_user.has_permission(Permission.ScoEtudChangeGroups): if current_user.has_permission(Permission.ScoEtudChangeGroups):
return True # admin, chef dept return True # admin, chef dept
if current_user.user_name in sem["responsables"]: if current_user.id in sem["responsables"]:
return True return True
return False return False

View File

@ -125,7 +125,7 @@ def get_photo_image(etudid=None, size="small", REQUEST=None):
if not etudid: if not etudid:
filename = UNKNOWN_IMAGE_PATH filename = UNKNOWN_IMAGE_PATH
else: 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) filename = photo_pathname(etud, size=size)
if not filename: if not filename:
filename = UNKNOWN_IMAGE_PATH 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 not etud:
if etudid: 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: else:
raise ValueError("etud_photo_html: either etud or etudid must be specified") raise ValueError("etud_photo_html: either etud or etudid must be specified")
photo_url = etud_photo_url(etud, size=size) photo_url = etud_photo_url(etud, size=size)

View File

@ -609,7 +609,7 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids=[], etudid=None, REQUEST=
groups_infos = None groups_infos = None
if etudid: if etudid:
# PV pour ce seul étudiant: # 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 = '<a class="discretelink" href="ficheEtud?etudid=%s">%s</a>' % ( etuddescr = '<a class="discretelink" href="ficheEtud?etudid=%s">%s</a>' % (
etudid, etudid,
etud["nomprenom"], etud["nomprenom"],

View File

@ -42,6 +42,8 @@ from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import styles from reportlab.lib import styles
from reportlab.lib.colors import Color from reportlab.lib.colors import Color
from flask import g
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc import sco_bulletins_pdf from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_codes_parcours from app.scodoc import sco_codes_parcours

View File

@ -194,7 +194,7 @@ def formsemestre_synchro_etuds(
if a_desinscrire or a_desinscrire_without_key: if a_desinscrire or a_desinscrire_without_key:
H.append("<h3>Etudiants à désinscrire :</h3><ol>") H.append("<h3>Etudiants à désinscrire :</h3><ol>")
for key in a_desinscrire: 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('<li class="desinscription">%(nomprenom)s</li>' % etud) H.append('<li class="desinscription">%(nomprenom)s</li>' % etud)
for etudid in a_desinscrire_without_key: for etudid in a_desinscrire_without_key:
etud = inscrits_without_key_all[etudid] etud = inscrits_without_key_all[etudid]
@ -794,7 +794,7 @@ def formsemestre_import_etud_admission(
for i in ins: for i in ins:
etudid = i["etudid"] 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"] code_nip = info["code_nip"]
if not code_nip: if not code_nip:
no_nip.append(etudid) no_nip.append(etudid)

View File

@ -81,7 +81,6 @@ def external_ue_create(
acronyme="", acronyme="",
ue_type=sco_codes_parcours.UE_STANDARD, ue_type=sco_codes_parcours.UE_STANDARD,
ects=0.0, ects=0.0,
REQUEST=None,
): ):
"""Crée UE/matiere/module/evaluation puis saisie les notes""" """Crée UE/matiere/module/evaluation puis saisie les notes"""
log("external_ue_create( formsemestre_id=%s, titre=%s )" % (formsemestre_id, titre)) log("external_ue_create( formsemestre_id=%s, titre=%s )" % (formsemestre_id, titre))
@ -127,9 +126,8 @@ def external_ue_create(
{ {
"module_id": module_id, "module_id": module_id,
"formsemestre_id": formsemestre_id, "formsemestre_id": formsemestre_id,
"responsable_id": sem["responsables"][ # affecte le 1er responsable du semestre comme resp. du module
0 "responsable_id": sem["responsables"][0],
], # affecte le 1er responsable du semestre comme resp. du module
}, },
) )
@ -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"]): 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") 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"] formation_id = sem["formation_id"]
existing_external_ue = get_existing_external_ue(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( moduleimpl_id = external_ue_create(
formsemestre_id, formsemestre_id,
REQUEST=REQUEST,
titre=tf[2]["titre"], titre=tf[2]["titre"],
acronyme=acronyme, acronyme=acronyme,
ue_type=tf[2]["type"], # type de l'UE ue_type=tf[2]["type"], # type de l'UE

View File

@ -238,17 +238,18 @@ def _user_list(user_name):
return None 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). """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 Si user_name est specifie (string ou id), interroge la BD. Sinon, user doit etre une instance
de User. de User.
""" """
if user_name is not None: if user_name_or_id is not None:
if isinstance(user_name, int): if isinstance(user_name_or_id, int):
u = User.query.filter_by(id=user_name).first() u = User.query.filter_by(id=user_name_or_id).first()
else: 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: if u:
user_name = u.user_name
info = u.to_dict() info = u.to_dict()
else: else:
info = None info = None

View File

@ -151,7 +151,7 @@ def index_html(REQUEST=None):
H.append( H.append(
"""<p>Pour signaler, annuler ou justifier une absence, choisissez d'abord l'étudiant concerné:</p>""" """<p>Pour signaler, annuler ou justifier une absence, choisissez d'abord l'étudiant concerné:</p>"""
) )
H.append(sco_find_etud.form_search_etud(REQUEST)) H.append(sco_find_etud.form_search_etud())
if authuser.has_permission(Permission.ScoAbsChange): if authuser.has_permission(Permission.ScoAbsChange):
H.extend( H.extend(
( (
@ -1070,9 +1070,7 @@ def AddBilletAbsence(
""" """
t0 = time.time() t0 = time.time()
# check etudid # check etudid
etuds = sco_etud.get_etud_info( etuds = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=True)
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
)
if not etuds: if not etuds:
return scu.log_unknown_etud(REQUEST=REQUEST) return scu.log_unknown_etud(REQUEST=REQUEST)
etud = etuds[0] etud = etuds[0]
@ -1117,7 +1115,7 @@ def AddBilletAbsenceForm(etudid, REQUEST=None):
"""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).
""" """
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 = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
page_title="Billet d'absence de %s" % etud["nomprenom"] page_title="Billet d'absence de %s" % etud["nomprenom"]
@ -1227,7 +1225,7 @@ def _tableBillets(billets, etud=None, title=""):
@scodoc7func @scodoc7func
def listeBilletsEtud(etudid=False, REQUEST=None, format="html"): def listeBilletsEtud(etudid=False, REQUEST=None, format="html"):
"""Liste billets pour un etudiant""" """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: if not etuds:
return scu.log_unknown_etud(format=format, REQUEST=REQUEST) return scu.log_unknown_etud(format=format, REQUEST=REQUEST)
@ -1386,7 +1384,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None):
) )
billet = billets[0] billet = billets[0]
etudid = billet["etudid"] 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 = [ H = [
html_sco_header.sco_header( html_sco_header.sco_header(
@ -1470,7 +1468,7 @@ def ProcessBilletAbsenceForm(billet_id, REQUEST=None):
def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None): def XMLgetAbsEtud(beg_date="", end_date="", REQUEST=None):
"""returns list of absences in date interval""" """returns list of absences in date interval"""
t0 = time.time() 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])$") 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): if not exp.match(beg_date):
raise ScoValueError("invalid date: %s" % beg_date) raise ScoValueError("invalid date: %s" % beg_date)

View File

@ -671,7 +671,7 @@ def formsemestre_custommenu_edit(REQUEST, formsemestre_id):
@scodoc7func @scodoc7func
def edit_enseignants_form(REQUEST, moduleimpl_id): def edit_enseignants_form(REQUEST, moduleimpl_id):
"modif liste enseignants/moduleimpl" "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( header = html_sco_header.html_sem_header(
REQUEST, REQUEST,
@ -915,7 +915,7 @@ def edit_moduleimpl_expr(REQUEST, 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
""" """
M, sem = sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) M, sem = sco_moduleimpl.can_change_ens(moduleimpl_id)
H = [ H = [
html_sco_header.html_sem_header( html_sco_header.html_sem_header(
REQUEST, REQUEST,
@ -1230,12 +1230,12 @@ def formsemestre_enseignants_list(REQUEST, formsemestre_id, format="html"):
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @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 """remove ens from this modueimpl
ens_id: user.id ens_id: user.id
""" """
M, _ = sco_moduleimpl.can_change_ens(REQUEST, moduleimpl_id) M, _ = sco_moduleimpl.can_change_ens(moduleimpl_id)
# search ens_id # search ens_id
ok = False ok = False
for ens in M["ens"]: for ens in M["ens"]:
@ -1319,7 +1319,7 @@ def formsemestre_desinscription(
% (etudid, formsemestre_id) % (etudid, formsemestre_id)
) )
if not dialog_confirmed: 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": if sem["modalite"] != "EXT":
msg_ext = """ msg_ext = """
<p>%s sera désinscrit de tous les modules du semestre %s (%s - %s).</p> <p>%s sera désinscrit de tous les modules du semestre %s (%s - %s).</p>
@ -1867,7 +1867,7 @@ def appreciation_add_form(
logdb(cnx, method="appreciation_suppress", etudid=etudid, msg="") logdb(cnx, method="appreciation_suppress", etudid=etudid, msg="")
return flask.redirect(bull_url) 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: if id:
a = "Edition" a = "Edition"
else: else:
@ -2144,7 +2144,7 @@ def formsemestre_validation_suppress_etud(
) )
if not dialog_confirmed: if not dialog_confirmed:
sem = sco_formsemestre.get_formsemestre(formsemestre_id) 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 nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_decision_sem
decision_jury = nt.get_etud_decision_sem(etudid) decision_jury = nt.get_etud_decision_sem(etudid)
if decision_jury: if decision_jury:

View File

@ -34,7 +34,6 @@ Emmanuel Viennet, 2021
import sys import sys
import time import time
# StringIO => io.StringIO or io.BytesIO for text and data respectively. #py3
from io import StringIO from io import StringIO
from zipfile import ZipFile from zipfile import ZipFile
@ -134,7 +133,7 @@ log("ScoDoc8 restarting...")
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
@scodoc7func @scodoc7func
def about(REQUEST): def about():
"version info" "version info"
H = [ H = [
"""<h2>Système de gestion scolarité</h2> """<h2>Système de gestion scolarité</h2>
@ -180,18 +179,19 @@ def edit_preferences(REQUEST):
@scodoc7func @scodoc7func
def formsemestre_edit_preferences(formsemestre_id, REQUEST): def formsemestre_edit_preferences(formsemestre_id, REQUEST):
"""Edit preferences for a semestre""" """Edit preferences for a semestre"""
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
ok = ( ok = (
authuser.has_permission(Permission.ScoImplement) current_user.has_permission(Permission.ScoImplement)
or ((str(authuser) 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 REQUEST=REQUEST
) )
else: else:
raise AccessDenied("Modification impossible pour %s" % authuser) raise AccessDenied(
"Modification impossible pour %s" % current_user.get_nomplogin()
)
@bp.route("/doc_preferences") @bp.route("/doc_preferences")
@ -217,7 +217,7 @@ def doc_preferences(REQUEST):
@scodoc7func @scodoc7func
def showEtudLog(etudid, format="html", REQUEST=None): def showEtudLog(etudid, format="html", REQUEST=None):
"""Display log of operations on this student""" """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) 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 ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine
(dans cet ordre). (dans cet ordre).
""" """
etud = sco_etud.get_etud_info( etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled)
etudid=etudid, code_nip=code_nip, filled=filled, REQUEST=REQUEST
)
if format is None: if format is None:
return etud return etud
else: else:
@ -339,7 +337,7 @@ sco_publish(
def etud_info(etudid=None, format="xml", REQUEST=None): def etud_info(etudid=None, format="xml", REQUEST=None):
"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, REQUEST=REQUEST) args = sco_etud.make_etud_args(etudid=etudid)
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
etuds = sco_etud.etudident_list(cnx, args) etuds = sco_etud.etudident_list(cnx, args)
if not etuds: if not etuds:
@ -562,7 +560,7 @@ def doSuppressAnnotation(etudid, annotation_id, REQUEST):
def formChangeCoordonnees(etudid, REQUEST): def formChangeCoordonnees(etudid, REQUEST):
"edit coordonnees etudiant" "edit coordonnees etudiant"
cnx = ndb.GetDBConnexion() 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}) adrs = sco_etud.adresse_list(cnx, {"etudid": etudid})
if adrs: if adrs:
adr = adrs[0] adr = adrs[0]
@ -747,7 +745,7 @@ sco_publish("/etud_photo_html", sco_photos.etud_photo_html, Permission.ScoView)
@scodoc7func @scodoc7func
def etud_photo_orig_page(etudid=None, REQUEST=None): def etud_photo_orig_page(etudid=None, REQUEST=None):
"Page with photo in orig. size" "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 = [ H = [
html_sco_header.sco_header(page_title=etud["nomprenom"]), html_sco_header.sco_header(page_title=etud["nomprenom"]),
"<h2>%s</h2>" % etud["nomprenom"], "<h2>%s</h2>" % etud["nomprenom"],
@ -766,7 +764,7 @@ def etud_photo_orig_page(etudid=None, REQUEST=None):
@scodoc7func @scodoc7func
def formChangePhoto(etudid=None, REQUEST=None): def formChangePhoto(etudid=None, REQUEST=None):
"""Formulaire changement photo étudiant""" """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): if sco_photos.etud_photo_is_local(etud):
etud["photoloc"] = "dans ScoDoc" etud["photoloc"] = "dans ScoDoc"
else: else:
@ -824,7 +822,7 @@ def formChangePhoto(etudid=None, REQUEST=None):
@scodoc7func @scodoc7func
def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False): def formSuppressPhoto(etudid=None, REQUEST=None, dialog_confirmed=False):
"""Formulaire suppression photo étudiant""" """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: if not dialog_confirmed:
return scu.confirm_dialog( return scu.confirm_dialog(
"<p>Confirmer la suppression de la photo de %(nomprenom)s ?</p>" % etud, "<p>Confirmer la suppression de la photo de %(nomprenom)s ?</p>" % etud,
@ -881,7 +879,7 @@ def _formDem_of_Def(
operation_method="", operation_method="",
): ):
"Formulaire démission ou défaillance Etudiant" "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) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]: if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille") raise ScoValueError("Modification impossible: semestre verrouille")

View File

@ -84,7 +84,7 @@ def index_html(REQUEST, all_depts=False, with_inactives=False, format="html"):
@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", 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) return scu.sendResult(REQUEST, info, name="user", format=format)