From 8cf1cc7c347476c3959b536725f0fd519c067f65 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Mon, 14 Jun 2021 00:23:22 +0200
Subject: [PATCH] WIP refactoring
---
app/scodoc/ImportScolars.py | 2 +-
app/scodoc/html_sidebar.py | 6 +-
app/scodoc/pe_jurype.py | 4 +-
app/scodoc/sco_abs.py | 2 +-
app/scodoc/sco_abs_notification.py | 12 +--
app/scodoc/sco_abs_views.py | 26 ++---
app/scodoc/sco_apogee_csv.py | 2 +-
app/scodoc/sco_archives_etud.py | 11 +-
app/scodoc/sco_bulletins.py | 93 +---------------
app/scodoc/sco_bulletins_json.py | 2 +-
app/scodoc/sco_bulletins_pdf.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_etape_apogee_view.py | 8 +-
app/scodoc/sco_export_results.py | 4 +-
app/scodoc/sco_find_etud.py | 2 +-
app/scodoc/sco_formsemestre_exterieurs.py | 6 +-
app/scodoc/sco_formsemestre_inscriptions.py | 10 +-
app/scodoc/sco_formsemestre_validation.py | 16 +--
app/scodoc/sco_groups.py | 6 +-
app/scodoc/sco_groups_view.py | 4 +-
app/scodoc/sco_inscr_passage.py | 6 +-
app/scodoc/sco_liste_notes.py | 4 +-
app/scodoc/sco_moduleimpl_inscriptions.py | 6 +-
app/scodoc/sco_page_etud.py | 7 +-
app/scodoc/sco_photos.py | 4 +-
app/scodoc/sco_poursuite_dut.py | 2 +-
app/scodoc/sco_prepajury.py | 2 +-
app/scodoc/sco_pvjury.py | 6 +-
app/scodoc/sco_pvpdf.py | 2 +-
app/scodoc/sco_report.py | 8 +-
app/scodoc/sco_saisie_notes.py | 2 +-
app/scodoc/sco_synchro_etuds.py | 6 +-
app/scodoc/sco_tag_module.py | 4 +-
app/scodoc/sco_trombino.py | 2 +-
app/scodoc/sco_ue_external.py | 5 +-
app/scodoc/scolars.py | 21 +++-
app/views/absences.py | 26 +++--
app/views/notes.py | 112 +++++++++++++++-----
app/views/scolar.py | 27 ++---
41 files changed, 235 insertions(+), 241 deletions(-)
diff --git a/app/scodoc/ImportScolars.py b/app/scodoc/ImportScolars.py
index 92a3d447af..908782a1ba 100644
--- a/app/scodoc/ImportScolars.py
+++ b/app/scodoc/ImportScolars.py
@@ -198,7 +198,7 @@ def sco_import_generate_excel_sample(
# rempli table avec données actuelles
lines = []
for i in members:
- etud = context.getEtudInfo(etudid=i["etudid"], filled=True)[0]
+ etud = scolars.get_etud_info(etudid=i["etudid"], filled=True)[0]
l = []
for field in titles:
if field == "groupes":
diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py
index 67c1a34120..d3fe1224d3 100644
--- a/app/scodoc/html_sidebar.py
+++ b/app/scodoc/html_sidebar.py
@@ -97,7 +97,7 @@ def sidebar(context, REQUEST=None):
# ---- s'il y a un etudiant selectionné:
if REQUEST.form.has_key("etudid"):
etudid = REQUEST.form["etudid"]
- etud = context.getEtudInfo(filled=1, etudid=etudid)[0]
+ etud = scolars.get_etud_info(filled=1, etudid=etudid)[0]
params.update(etud)
# compte les absences du semestre en cours
H.append(
@@ -166,7 +166,9 @@ def sidebar_dept(context, REQUEST=None):
"""Partie supérieure de la marge de gauche"""
infos = {
"BASE0": REQUEST.BASE0,
- "DeptIntranetTitle": sco_preferences.get_preference(context, "DeptIntranetTitle"),
+ "DeptIntranetTitle": sco_preferences.get_preference(
+ context, "DeptIntranetTitle"
+ ),
"DeptIntranetURL": sco_preferences.get_preference(context, "DeptIntranetURL"),
"DeptName": sco_preferences.get_preference(context, "DeptName"),
"ScoURL": context.ScoURL(),
diff --git a/app/scodoc/pe_jurype.py b/app/scodoc/pe_jurype.py
index 62863b4819..d0c5bae3ad 100644
--- a/app/scodoc/pe_jurype.py
+++ b/app/scodoc/pe_jurype.py
@@ -1117,7 +1117,7 @@ class JuryPE:
ETUDINFO_DICT si mémorisée soit en les chargeant et en les mémorisant
"""
if etudid not in self.ETUDINFO_DICT:
- self.ETUDINFO_DICT[etudid] = context.getEtudInfo(
+ self.ETUDINFO_DICT[etudid] = scolars.get_etud_info(
etudid=etudid, filled=True
)[0]
return self.ETUDINFO_DICT[etudid]
@@ -1139,7 +1139,7 @@ class JuryPE:
def get_semestresDUT_d_un_etudiant(self, etudid, semestre_id=None):
"""Renvoie la liste des semestres DUT d'un étudiant
pour un semestre_id (parmi 1,2,3,4) donné
- en fonction de ses infos d'etud (cf. context.getEtudInfo(etudid=etudid, filled=True)[0]),
+ en fonction de ses infos d'etud (cf. scolars.get_etud_info( etudid=etudid, filled=True)[0]),
les semestres étant triés par ordre décroissant.
Si semestre_id == None renvoie tous les semestres"""
etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid)
diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py
index 415101eab7..0bd38dff34 100644
--- a/app/scodoc/sco_abs.py
+++ b/app/scodoc/sco_abs.py
@@ -604,7 +604,7 @@ def invalidateAbsEtudDate(context, etudid, date):
date: date au format ISO
"""
# Semestres a cette date:
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
sems = [
sem
for sem in etud["sems"]
diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py
index 5433d0bb65..e2a8afb1b0 100644
--- a/app/scodoc/sco_abs_notification.py
+++ b/app/scodoc/sco_abs_notification.py
@@ -152,7 +152,7 @@ def abs_notify_get_destinations(context, sem, prefs, etudid, date, nbabs, nbabsj
if prefs["abs_notify_email"]:
destinations.append(prefs["abs_notify_email"])
if prefs["abs_notify_etud"]:
- etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
if etud["email_default"]:
destinations.append(etud["email_default"])
@@ -181,11 +181,11 @@ def abs_notify_is_above_threshold(context, etudid, nbabs, nbabsjust, formsemestr
(nbabs > abs_notify_abs_threshold)
(nbabs - nbabs_last_notified) > abs_notify_abs_increment
"""
- abs_notify_abs_threshold = sco_preferences.get_preference(context,
- "abs_notify_abs_threshold", formsemestre_id
+ abs_notify_abs_threshold = sco_preferences.get_preference(
+ context, "abs_notify_abs_threshold", formsemestre_id
)
- abs_notify_abs_increment = sco_preferences.get_preference(context,
- "abs_notify_abs_increment", formsemestre_id
+ abs_notify_abs_increment = sco_preferences.get_preference(
+ context, "abs_notify_abs_increment", formsemestre_id
)
nbabs_last_notified = etud_nbabs_last_notified(context, etudid, formsemestre_id)
@@ -236,7 +236,7 @@ def abs_notification_message(context, sem, prefs, etudid, nbabs, nbabsjust):
"""Mime notification message based on template.
returns None if sending should be canceled (emplty template).
"""
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
# Variables accessibles dans les balises du template: %(nom_variable)s :
values = sco_bulletins.make_context_dict(context, sem, etud)
diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py
index cc38fc80b4..3d9e7de2d9 100644
--- a/app/scodoc/sco_abs_views.py
+++ b/app/scodoc/sco_abs_views.py
@@ -70,7 +70,7 @@ def doSignaleAbsence(
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
"""
- etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
description_abs = description
@@ -149,12 +149,12 @@ def doSignaleAbsence(
def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de signalement d'une absence"""
# brute-force portage from very old dtml code ...
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
disabled = False
if not etud["cursem"]:
- require_module = sco_preferences.get_preference(context,
- "abs_require_module"
+ require_module = sco_preferences.get_preference(
+ context, "abs_require_module"
) # on utilise la pref globale car pas de sem courant
if require_module:
menu_module = """Pas inscrit dans un semestre courant,
@@ -164,7 +164,9 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
menu_module = ""
else:
formsemestre_id = etud["cursem"]["formsemestre_id"]
- require_module = sco_preferences.get_preference(context, "abs_require_module", formsemestre_id)
+ require_module = sco_preferences.get_preference(
+ context, "abs_require_module", formsemestre_id
+ )
nt = context.Notes._getNotesCache().get_NotesTable(
context.Notes, formsemestre_id
)
@@ -286,7 +288,7 @@ def doJustifAbsence(
description: str
etudid: etudiant concerné. Si non spécifié, cherche dans REQUEST.form
"""
- etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
description_abs = description
dates = sco_abs.DateRangeISO(context, datedebut, datefin)
@@ -355,7 +357,7 @@ def doJustifAbsence(
def JustifAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple de justification d'une absence"""
# brute-force portage from very old dtml code ...
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
H = [
html_sco_header.sco_header(
@@ -413,7 +415,7 @@ def doAnnuleAbsence(
context, datedebut, datefin, demijournee, etudid=False, REQUEST=None
): # etudid implied
"""Annulation des absences pour une demi journée"""
- etud = context.getEtudInfo(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, etudid=etudid, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(context, datedebut, datefin)
@@ -464,7 +466,7 @@ autre absence pour
%(nomprenom)s
def AnnuleAbsenceEtud(context, REQUEST=None): # etudid implied
"""Formulaire individuel simple d'annulation d'une absence"""
# brute-force portage from very old dtml code ...
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
H = [
@@ -553,7 +555,7 @@ def doAnnuleJustif(
context, datedebut0, datefin0, demijournee, REQUEST=None
): # etudid implied
"""Annulation d'une justification"""
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
dates = sco_abs.DateRangeISO(context, datedebut0, datefin0)
nbadded = 0
@@ -658,7 +660,7 @@ def formChoixSemestreGroupe(context, all=False):
def CalAbs(context, REQUEST=None): # etud implied
"""Calendrier des absences d un etudiant"""
# crude portage from 1999 DTML
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
anneescolaire = int(scu.AnneeScolaire(REQUEST))
datedebut = str(anneescolaire) + "-08-31"
@@ -746,7 +748,7 @@ def ListeAbsEtud(
absjust_only = int(absjust_only) # si vrai, table absjust seule (export xls ou pdf)
datedebut = "%s-08-31" % scu.AnneeScolaire(REQUEST)
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
# Liste des absences et titres colonnes tables:
titles, columns_ids, absnonjust, absjust = context.Absences._TablesAbsEtud(
diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py
index 619f646283..e8117e0cf8 100644
--- a/app/scodoc/sco_apogee_csv.py
+++ b/app/scodoc/sco_apogee_csv.py
@@ -285,7 +285,7 @@ class ApoEtud(dict):
return "ApoEtud( nom='%s', nip='%s' )" % (self["nom"], self["nip"])
def lookup_scodoc(self, context, etape_formsemestre_ids):
- etuds = context.getEtudInfo(code_nip=self["nip"], filled=True)
+ etuds = scolars.get_etud_info(code_nip=self["nip"], filled=True)
if not etuds:
# pas dans ScoDoc
self.etud = None
diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py
index 6171534896..77cb6189ec 100644
--- a/app/scodoc/sco_archives_etud.py
+++ b/app/scodoc/sco_archives_etud.py
@@ -129,9 +129,10 @@ def etud_upload_file_form(context, REQUEST, etudid):
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
H = [
- html_sco_header.sco_header(context,
+ html_sco_header.sco_header(
+ context,
REQUEST,
page_title="Chargement d'un document associé à %(nomprenom)s" % etud,
),
@@ -197,7 +198,7 @@ def etud_delete_archive(context, REQUEST, etudid, archive_name, dialog_confirmed
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
archive_id = EtudsArchive.get_id_from_name(context, etudid, archive_name)
dest_url = "ficheEtud?etudid=%s" % etudid
if not dialog_confirmed:
@@ -252,8 +253,8 @@ def etudarchive_generate_excel_sample(context, group_id=None, REQUEST=None):
def etudarchive_import_files_form(context, group_id, REQUEST=None):
"""Formualaire pour importation fichiers d'un groupe"""
H = [
- html_sco_header.sco_header(context,
- REQUEST, page_title="Import de fichiers associés aux étudiants"
+ html_sco_header.sco_header(
+ context, REQUEST, page_title="Import de fichiers associés aux étudiants"
),
"""
Les fichiers associés (dossiers d'admission, certificats, ...), de types quelconques (pdf, doc, images)
diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py
index 43f8b89e47..cbad075431 100644
--- a/app/scodoc/sco_bulletins.py
+++ b/app/scodoc/sco_bulletins.py
@@ -138,7 +138,7 @@ def formsemestre_bulletinetud_dict(
I["formation"]["type_parcours"]
)
# Infos sur l'etudiant
- I["etud"] = context.getEtudInfo(etudid=etudid, filled=1)[0]
+ I["etud"] = scolars.get_etud_info(etudid=etudid, filled=1)[0]
I["descr_situation"] = I["etud"]["inscriptionstr"]
if I["etud"]["inscription_formsemestre_id"]:
I[
@@ -780,7 +780,7 @@ def formsemestre_bulletinetud(
):
"page bulletin de notes"
try:
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"]
except:
return scu.log_unknown_etud(context, REQUEST, format=format)
@@ -1210,92 +1210,3 @@ def _formsemestre_bulletinetud_header_html(
)
return "".join(H)
-
-
-def formsemestre_bulletins_choice(
- context, REQUEST, formsemestre_id, title="", explanation="", choose_mail=False
-):
- """Choix d'une version de bulletin"""
- sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
- H = [
- html_sco_header.html_sem_header(context, REQUEST, title, sem),
- """
-
"""
- header = html_sco_header.sco_header(context,
+ header = html_sco_header.sco_header(
+ context,
REQUEST,
page_title="Fiche étudiant %(prenom)s %(nom)s" % info,
cssstyles=["libjs/jQuery-tagEditor/jquery.tag-editor.css"],
@@ -504,7 +505,7 @@ def menus_etud(context, REQUEST=None):
return ""
authuser = REQUEST.AUTHENTICATED_USER
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
menuEtud = [
{
@@ -555,7 +556,7 @@ def etud_info_html(context, etudid, with_photo="1", REQUEST=None, debug=False):
# log('etud_info_html: formsemestre_id=%s' % formsemestre_id)
with_photo = int(with_photo)
- etud = context.getEtudInfo(filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(filled=1, REQUEST=REQUEST)[0]
photo_html = sco_photos.etud_photo_html(
context, etud, title="fiche de " + etud["nom"], REQUEST=REQUEST
)
diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py
index 199ec7fc0f..cf79103c6e 100644
--- a/app/scodoc/sco_photos.py
+++ b/app/scodoc/sco_photos.py
@@ -117,7 +117,7 @@ def get_photo_image(context, etudid=None, size="small", REQUEST=None):
if not etudid:
filename = UNKNOWN_IMAGE_PATH
else:
- etud = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
filename = photo_pathname(context, etud, size=size)
if not filename:
filename = UNKNOWN_IMAGE_PATH
@@ -172,7 +172,7 @@ def etud_photo_html(
"""
if not etud:
if etudid:
- etud = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
else:
raise ValueError("etud_photo_html: either etud or etudid must be specified")
photo_url = etud_photo_url(context, etud, size=size, REQUEST=REQUEST)
diff --git a/app/scodoc/sco_poursuite_dut.py b/app/scodoc/sco_poursuite_dut.py
index ac64a8e123..3fa466f6bc 100644
--- a/app/scodoc/sco_poursuite_dut.py
+++ b/app/scodoc/sco_poursuite_dut.py
@@ -158,7 +158,7 @@ def _getEtudInfoGroupes(context, group_ids, etat=None):
for group_id in group_ids:
members = sco_groups.get_group_members(context, group_id, etat=etat)
for m in members:
- etud = context.getEtudInfo(etudid=m["etudid"], filled=True)[0]
+ etud = scolars.get_etud_info(etudid=m["etudid"], filled=True)[0]
etuds.append(etud)
return etuds
diff --git a/app/scodoc/sco_prepajury.py b/app/scodoc/sco_prepajury.py
index c90ac0ef11..3fc41e6bd9 100644
--- a/app/scodoc/sco_prepajury.py
+++ b/app/scodoc/sco_prepajury.py
@@ -71,7 +71,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
nbabs = {}
nbabsjust = {}
for etudid in etudids:
- info = context.getEtudInfo(etudid=etudid, filled=True)
+ info = scolars.get_etud_info(etudid=etudid, filled=True)
if not info:
continue # should not occur...
etud = info[0]
diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py
index b266d9027b..6f8e436714 100644
--- a/app/scodoc/sco_pvjury.py
+++ b/app/scodoc/sco_pvjury.py
@@ -226,7 +226,7 @@ def dict_pvjury(
L = []
D = {} # même chose que L, mais { etudid : dec }
for etudid in etudids:
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
d = {}
@@ -327,7 +327,7 @@ def dict_pvjury(
max_date = date
# Code semestre precedent
if with_prev: # optionnel car un peu long...
- info = context.getEtudInfo(etudid=etudid, filled=True)
+ info = scolars.get_etud_info(etudid=etudid, filled=True)
if not info:
continue # should not occur
etud = info[0]
@@ -614,7 +614,7 @@ def formsemestre_pvjury_pdf(
groups_infos = None
if etudid:
# PV pour ce seul étudiant:
- etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
etuddescr = '%s' % (
etudid,
etud["nomprenom"],
diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py
index 2321b0039a..eb20a25880 100644
--- a/app/scodoc/sco_pvpdf.py
+++ b/app/scodoc/sco_pvpdf.py
@@ -367,7 +367,7 @@ def pdf_lettres_individuelles(
npages = 0
for e in dpv["decisions"]:
if e["decision_sem"]: # decision prise
- etud = context.getEtudInfo(e["identite"]["etudid"], filled=True)[0]
+ etud = scolars.get_etud_info(e["identite"]["etudid"], filled=True)[0]
params["nomEtud"] = etud["nomprenom"]
bookmarks[npages + 1] = scu.suppress_accents(etud["nomprenom"])
objects += pdf_lettre_individuelle(
diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py
index 40aae5daac..e8fce74311 100644
--- a/app/scodoc/sco_report.py
+++ b/app/scodoc/sco_report.py
@@ -63,7 +63,7 @@ def formsemestre_etuds_stats(context, sem, only_primo=False):
etuds = []
for t in T:
etudid = t[-1]
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
decision = nt.get_etud_decision_sem(etudid)
if decision:
etud["codedecision"] = decision["code"]
@@ -418,7 +418,7 @@ def table_suivi_cohorte(
civilites = set()
statuts = set()
for etudid in etudids:
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
bacspe = etud["bac"] + " / " + etud["specialite"]
# sélection sur bac:
if (
@@ -900,7 +900,7 @@ def _descr_etud_set(context, etudids):
"textual html description of a set of etudids"
etuds = []
for etudid in etudids:
- etuds.append(context.getEtudInfo(etudid=etudid, filled=True)[0])
+ etuds.append(scolars.get_etud_info(etudid=etudid, filled=True)[0])
# sort by name
etuds.sort(lambda x, y: cmp(x["nom"], y["nom"]))
return ", ".join([e["nomprenom"] for e in etuds])
@@ -1032,7 +1032,7 @@ def tsp_etud_list(
civilites = set()
statuts = set()
for etudid in etudids:
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
bacspe = etud["bac"] + " / " + etud["specialite"]
# sélection sur bac, primo, ...:
if (
diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py
index 07bc643466..c3ceb6f77d 100644
--- a/app/scodoc/sco_saisie_notes.py
+++ b/app/scodoc/sco_saisie_notes.py
@@ -265,7 +265,7 @@ def do_evaluation_upload_xls(context, REQUEST):
)
if len(invalids) < 25:
etudsnames = [
- context.getEtudInfo(etudid=etudid, filled=True)[0]["nomprenom"]
+ scolars.get_etud_info(etudid=etudid, filled=True)[0]["nomprenom"]
for etudid in invalids
]
diag.append("Notes invalides pour: " + ", ".join(etudsnames))
diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py
index 74a603a910..0c6fbba09d 100644
--- a/app/scodoc/sco_synchro_etuds.py
+++ b/app/scodoc/sco_synchro_etuds.py
@@ -195,7 +195,7 @@ def formsemestre_synchro_etuds(
if a_desinscrire or a_desinscrire_without_key:
H.append("Etudiants à désinscrire :
")
for key in a_desinscrire:
- etud = context.getEtudInfo(filled=1, code_nip=key)[0]
+ etud = scolars.get_etud_info(filled=1, code_nip=key)[0]
H.append('- %(nomprenom)s
' % etud)
for etudid in a_desinscrire_without_key:
etud = inscrits_without_key_all[etudid]
@@ -229,7 +229,7 @@ def formsemestre_synchro_etuds(
# Conversions des listes de codes NIP en listes de codes etudid
def nip2etudid(code_nip):
- etud = context.getEtudInfo(code_nip=code_nip)[0]
+ etud = scolars.get_etud_info(code_nip=code_nip)[0]
return etud["etudid"]
etudids_a_inscrire = [nip2etudid(x) for x in a_inscrire]
@@ -807,7 +807,7 @@ def formsemestre_import_etud_admission(
for i in ins:
etudid = i["etudid"]
- info = context.getEtudInfo(etudid=etudid, filled=1)[0]
+ info = scolars.get_etud_info(etudid=etudid, filled=1)[0]
code_nip = info["code_nip"]
if not code_nip:
no_nip.append(etudid)
diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py
index 81e1ad9a10..9718fcfd5a 100644
--- a/app/scodoc/sco_tag_module.py
+++ b/app/scodoc/sco_tag_module.py
@@ -270,7 +270,7 @@ def get_etud_tagged_modules(context, etudid, tagname):
Cherche dans tous les semestres dans lesquel l'étudiant est ou a été inscrit.
Construit la liste des modules avec le tag donné par tagname
"""
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
R = []
for sem in etud["sems"]:
nt = sco_core.get_notes_cache(
@@ -337,7 +337,7 @@ from sco_tag_module import *
context = go_dept(app, 'GEA').Notes
etudid='GEAEID80687'
-etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+etud = scolars.get_etud_info( etudid=etudid, filled=True)[0]
sem = etud['sems'][0]
[ tm['moy'] for tm in get_etud_tagged_modules(context, etudid, 'allo') ]
diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py
index 6d54834a91..d34c1f5ed5 100644
--- a/app/scodoc/sco_trombino.py
+++ b/app/scodoc/sco_trombino.py
@@ -621,7 +621,7 @@ def zip_excel_import_files(
etudid = Filename2Etud[normname]
# ok, store photo
try:
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
del Filename2Etud[normname]
except:
raise ScoValueError("ID étudiant invalide: %s" % etudid)
diff --git a/app/scodoc/sco_ue_external.py b/app/scodoc/sco_ue_external.py
index f3d442729b..51855dd66b 100644
--- a/app/scodoc/sco_ue_external.py
+++ b/app/scodoc/sco_ue_external.py
@@ -214,12 +214,13 @@ def external_ue_create_form(context, formsemestre_id, etudid, REQUEST=None):
if not sem["resp_can_edit"] or str(authuser) not in sem["responsables"]:
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération")
- etud = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
formation_id = sem["formation_id"]
existing_external_ue = get_existing_external_ue(context, formation_id)
H = [
- html_sco_header.html_sem_header(context,
+ html_sco_header.html_sem_header(
+ context,
REQUEST,
"Ajout d'une UE externe pour %(nomprenom)s" % etud,
sem,
diff --git a/app/scodoc/scolars.py b/app/scodoc/scolars.py
index f63d981c61..84b0231ac9 100644
--- a/app/scodoc/scolars.py
+++ b/app/scodoc/scolars.py
@@ -399,7 +399,7 @@ def identite_edit(cnx, args, context=None, REQUEST=None):
# Notification du changement par e-mail:
if notify_to:
- etud = context.getEtudInfo(etudid=args["etudid"], filled=True)[0]
+ etud = getEtudInfo(context, etudid=args["etudid"], filled=True)[0]
after = identite_list(cnx, {"etudid": args["etudid"]})[0]
notify_etud_change(
context,
@@ -513,7 +513,7 @@ def adresse_edit(cnx, args, context=None):
# Notification du changement par e-mail:
if notify_to:
- etud = context.getEtudInfo(etudid=args["etudid"], filled=True)[0]
+ etud = getEtudInfo(context, etudid=args["etudid"], filled=True)[0]
after = adresse_list(cnx, {"etudid": args["etudid"]})[0]
notify_etud_change(
context,
@@ -652,6 +652,23 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True):
return args
+def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None):
+ """infos sur un etudiant (API)
+ On peut specifier etudid ou conde_nip
+ ou bien cherche dans REQUEST.form: etudid, code_nip, code_ine
+ (dans cet ordre).
+ """
+ if etudid is None:
+ return []
+ cnx = context.GetDBConnexion()
+ args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST)
+ etud = scolars.etudident_list(cnx, args=args)
+
+ if filled:
+ fillEtudsInfo(context, etud)
+ return etud
+
+
def create_etud(context, cnx, args={}, REQUEST=None):
"""Creation d'un étudiant. génère aussi évenement et "news".
diff --git a/app/views/absences.py b/app/views/absences.py
index 0bebf0ea17..e8db99b302 100644
--- a/app/views/absences.py
+++ b/app/views/absences.py
@@ -718,9 +718,11 @@ def SignaleAbsenceGrHebdo(
)
formsemestre_id = groups_infos.formsemestre_id
- require_module = sco_preferences.get_preference(context, "abs_require_module", formsemestre_id)
+ require_module = sco_preferences.get_preference(
+ context, "abs_require_module", formsemestre_id
+ )
etuds = [
- context.getEtudInfo(etudid=m["etudid"], filled=True)[0]
+ scolars.get_etud_info(etudid=m["etudid"], filled=True)[0]
for m in groups_infos.members
]
# Restreint aux inscrits au module sélectionné
@@ -880,9 +882,11 @@ def SignaleAbsenceGrSemestre(
+ context.sco_footer(REQUEST)
)
formsemestre_id = groups_infos.formsemestre_id
- require_module = sco_preferences.get_preference(context, "abs_require_module", formsemestre_id)
+ require_module = sco_preferences.get_preference(
+ context, "abs_require_module", formsemestre_id
+ )
etuds = [
- context.getEtudInfo(etudid=m["etudid"], filled=True)[0]
+ scolars.get_etud_info(etudid=m["etudid"], filled=True)[0]
for m in groups_infos.members
]
# Restreint aux inscrits au module sélectionné
@@ -1380,7 +1384,7 @@ def EtatAbsencesGr(
# Construit tableau (etudid, statut, nomprenom, nbJust, nbNonJust, NbTotal)
T = []
for m in groups_infos.members:
- etud = context.getEtudInfo(etudid=m["etudid"], filled=True)[0]
+ etud = scolars.get_etud_info(etudid=m["etudid"], filled=True)[0]
nbabs = context.CountAbs(etudid=etud["etudid"], debut=datedebut, fin=datefin)
nbabsjust = context.CountAbsJust(
etudid=etud["etudid"], debut=datedebut, fin=datefin
@@ -1604,7 +1608,7 @@ def AddBilletAbsence(
"""
t0 = time.time()
# check etudid
- etuds = context.getEtudInfo(
+ etuds = scolars.get_etud_info(
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
)
if not etuds:
@@ -1650,7 +1654,7 @@ def AddBilletAbsenceForm(context, etudid, REQUEST=None):
"""Formulaire ajout billet (pour tests seulement, le vrai formulaire accessible aux etudiants
étant sur le portail étudiant).
"""
- etud = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
H = [
html_sco_header.sco_header(
context, REQUEST, page_title="Billet d'absence de %s" % etud["nomprenom"]
@@ -1719,7 +1723,7 @@ def _tableBillets(context, billets, etud=None, title=""):
b["etat_str"] = "ok"
if not etud:
# ajoute info etudiant
- e = context.getEtudInfo(etudid=b["etudid"], filled=1)
+ e = scolars.get_etud_info(etudid=b["etudid"], filled=1)
if not e:
b["nomprenom"] = "???" # should not occur
else:
@@ -1759,7 +1763,7 @@ def _tableBillets(context, billets, etud=None, title=""):
@scodoc7func(context)
def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
"""Liste billets pour un etudiant"""
- etuds = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)
+ etuds = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)
if not etuds:
return scu.log_unknown_etud(context, format=format, REQUEST=REQUEST)
@@ -1902,7 +1906,7 @@ def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
)
billet = billets[0]
etudid = billet["etudid"]
- etud = context.getEtudInfo(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
H = [
html_sco_header.sco_header(
@@ -1983,7 +1987,7 @@ def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
def XMLgetAbsEtud(context, beg_date="", end_date="", REQUEST=None):
"""returns list of absences in date interval"""
t0 = time.time()
- etud = context.getEtudInfo(REQUEST=REQUEST)[0]
+ etud = scolars.get_etud_info(REQUEST=REQUEST)[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 2d9ffbd79f..767d8fac82 100644
--- a/app/views/notes.py
+++ b/app/views/notes.py
@@ -1499,7 +1499,7 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
fin=fin_sem,
moduleimpl_id=moduleimpl_id,
)
- etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=True)[0]
T.append(
{
"nomprenom": etud["nomprenom"],
@@ -1811,7 +1811,7 @@ def do_formsemestre_inscription_listinscrits(
context, formsemestre_id, format=None, REQUEST=None
):
"""Liste les inscrits (état I) à ce semestre et cache le résultat"""
- cache = sco_core.get_formsemestre_inscription_cache(context, )
+ cache = context.get_formsemestre_inscription_cache()
r = cache.get(formsemestre_id)
if r is None:
# retreive list
@@ -1834,17 +1834,6 @@ def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
) # > modif inscription semestre (demission ?)
-# Cache inscriptions semestres
-def get_formsemestre_inscription_cache(context, format=None):
- u = context.GetDBConnexionString()
- if CACHE_formsemestre_inscription.has_key(u):
- return CACHE_formsemestre_inscription[u]
- else:
- log("get_formsemestre_inscription_cache: new simpleCache")
- CACHE_formsemestre_inscription[u] = sco_cache.simpleCache()
- return CACHE_formsemestre_inscription[u]
-
-
@bp.route("/formsemestre_desinscription")
@permission_required(Permission.ScoImplement)
@scodoc7func(context)
@@ -1874,7 +1863,7 @@ def formsemestre_desinscription(
% (etudid, formsemestre_id)
)
if not dialog_confirmed:
- etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
+ etud = scolars.get_etud_info(etudid=etudid, filled=1)[0]
if sem["modalite"] != "EXT":
msg_ext = """
%s sera désinscrit de tous les modules du semestre %s (%s - %s).
@@ -2573,6 +2562,25 @@ def formsemestre_bulletins_pdf(
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
+@bp.route("/formsemestre_bulletins_pdf_choice")
+@permission_required(Permission.ScoView)
+@scodoc7func(context)
+def formsemestre_bulletins_pdf_choice(context, REQUEST, formsemestre_id, version=None):
+ """Choix version puis envois classeur bulletins pdf"""
+ if version:
+ pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
+ context, formsemestre_id, REQUEST, version=version
+ )
+ return scu.sendPDFFile(REQUEST, pdfdoc, filename)
+ return formsemestre_bulletins_choice(
+ context,
+ REQUEST,
+ formsemestre_id,
+ title="Choisir la version des bulletins à générer",
+ explanation=expl_bull,
+ )
+
+
@bp.route("/etud_bulletins_pdf")
@permission_required(Permission.ScoView)
@scodoc7func(context)
@@ -2584,16 +2592,68 @@ def etud_bulletins_pdf(context, etudid, REQUEST, version="selectedevals"):
return scu.sendPDFFile(REQUEST, pdfdoc, filename)
-sco_publish(
- "/formsemestre_bulletins_pdf_choice",
- sco_bulletins.formsemestre_bulletins_pdf_choice,
- Permission.ScoView,
-)
-sco_publish(
- "/formsemestre_bulletins_mailetuds_choice",
- sco_bulletins.formsemestre_bulletins_mailetuds_choice,
- Permission.ScoView,
-)
+@bp.route("/formsemestre_bulletins_mailetuds_choice")
+@permission_required(Permission.ScoView)
+@scodoc7func(context)
+def formsemestre_bulletins_mailetuds_choice(
+ context,
+ REQUEST,
+ formsemestre_id,
+ version=None,
+ dialog_confirmed=False,
+ prefer_mail_perso=0,
+):
+ """Choix version puis envois classeur bulletins pdf"""
+ if version:
+ return context.formsemestre_bulletins_mailetuds(
+ formsemestre_id,
+ REQUEST,
+ version=version,
+ dialog_confirmed=dialog_confirmed,
+ prefer_mail_perso=prefer_mail_perso,
+ )
+ expl_bull = """Versions des bulletins:- courte: moyennes des modules
- intermédiaire: moyennes des modules et notes des évaluations sélectionnées
- complète: toutes les notes
"""
+ return formsemestre_bulletins_choice(
+ context,
+ REQUEST,
+ formsemestre_id,
+ title="Choisir la version des bulletins à envoyer par mail",
+ explanation="Chaque étudiant ayant une adresse mail connue de ScoDoc recevra une copie PDF de son bulletin de notes, dans la version choisie.
"
+ + expl_bull,
+ choose_mail=True,
+ )
+
+
+def formsemestre_bulletins_choice(
+ context, REQUEST, formsemestre_id, title="", explanation="", choose_mail=False
+):
+ """Choix d'une version de bulletin"""
+ sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
+ H = [
+ html_sco_header.html_sem_header(context, REQUEST, title, sem),
+ """
+