From ede5aa680db0d172722d5020422842d1770e9177 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Mon, 21 Jun 2021 12:13:25 +0200
Subject: [PATCH] migration en cours
---
app/scodoc/notes_table.py | 2 +-
app/scodoc/sco_abs.py | 6 +--
app/scodoc/sco_abs_notification.py | 2 +-
app/scodoc/sco_abs_views.py | 2 +-
app/scodoc/sco_formsemestre.py | 2 +-
app/scodoc/sco_formsemestre_validation.py | 6 +--
app/scodoc/sco_import_etuds.py | 31 +++++++++++-
app/scodoc/sco_parcours_dut.py | 4 +-
app/scodoc/sco_saisie_notes.py | 2 +-
app/views/absences.py | 15 +++---
app/views/entreprises.py | 8 +--
app/views/notes.py | 11 +++--
app/views/scolar.py | 59 +++++++----------------
13 files changed, 79 insertions(+), 71 deletions(-)
diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py
index b620220d..528c2c85 100644
--- a/app/scodoc/notes_table.py
+++ b/app/scodoc/notes_table.py
@@ -1205,7 +1205,7 @@ class NotesTable:
and moy_ue_cap >= self.parcours.NOTES_BARRE_VALID_UE
):
if not cnx:
- cnx = self.context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
sco_parcours_dut.do_formsemestre_validate_ue(
cnx,
nt_cap,
diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py
index 520820f7..7090f076 100644
--- a/app/scodoc/sco_abs.py
+++ b/app/scodoc/sco_abs.py
@@ -437,7 +437,7 @@ def GetAbsDescription(context, a, cursor=None):
if a["moduleimpl_id"] and a["moduleimpl_id"] != "NULL":
# Trouver le nom du module
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
- context.Notes, moduleimpl_id=a["moduleimpl_id"]
+ context, moduleimpl_id=a["moduleimpl_id"]
)
if Mlist:
M = Mlist[0]
@@ -1055,8 +1055,8 @@ def invalidateAbsEtudDate(context, etudid, date):
True # efface toujours le PDF car il affiche en général les absences
)
- context.Notes._inval_cache(
- pdfonly=pdfonly, formsemestre_id=sem["formsemestre_id"]
+ sco_core.inval_cache(
+ context, pdfonly=pdfonly, formsemestre_id=sem["formsemestre_id"]
)
# Inval cache compteurs absences:
diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py
index 1f498121..272bbd46 100644
--- a/app/scodoc/sco_abs_notification.py
+++ b/app/scodoc/sco_abs_notification.py
@@ -62,7 +62,7 @@ def abs_notify(context, etudid, date):
debut_sem = ndb.DateDMYtoISO(sem["date_debut"])
fin_sem = ndb.DateDMYtoISO(sem["date_fin"])
nbabs = sco_abs.CountAbs(context, etudid, debut=debut_sem, fin=fin_sem)
- nbabsjust = context.CountAbsJust(etudid, debut=debut_sem, fin=fin_sem)
+ nbabsjust = sco_abs.CountAbsJust(context, etudid, debut=debut_sem, fin=fin_sem)
do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust)
diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py
index baa84096..e42aa9c0 100644
--- a/app/scodoc/sco_abs_views.py
+++ b/app/scodoc/sco_abs_views.py
@@ -737,7 +737,7 @@ def CalAbs(context, REQUEST=None): # etud implied
datedebut = str(anneescolaire) + "-08-31"
datefin = str(anneescolaire + 1) + "-07-31"
nbabs = sco_abs.CountAbs(context, etudid=etudid, debut=datedebut, fin=datefin)
- nbabsjust = context.CountAbsJust(etudid=etudid, debut=datedebut, fin=datefin)
+ nbabsjust = sco_abs.CountAbsJust(context, etudid=etudid, debut=datedebut, fin=datefin)
events = []
for a in sco_abs.ListeAbsJust(context, etudid=etudid, datedebut=datedebut):
events.append(
diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py
index 92379bcc..0c173b3d 100644
--- a/app/scodoc/sco_formsemestre.py
+++ b/app/scodoc/sco_formsemestre.py
@@ -360,7 +360,7 @@ def _write_formsemestre_aux(context, sem, fieldname, valuename):
# uniquify
values = set([str(x) for x in sem[fieldname]])
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
tablename = "notes_formsemestre_" + fieldname
try:
diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py
index 9f54f2ca..072c15b8 100644
--- a/app/scodoc/sco_formsemestre_validation.py
+++ b/app/scodoc/sco_formsemestre_validation.py
@@ -968,7 +968,7 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
) # > get_etudids, get_etud_decision_sem, get_ues, get_etud_decision_ues, get_etud_ue_status
etudids = nt.get_etudids()
modifs = [] # liste d'étudiants modifiés
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
@@ -1046,7 +1046,7 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
def formsemestre_validation_suppress_etud(context, formsemestre_id, etudid):
"""Suppression des decisions de jury pour un etudiant."""
log("formsemestre_validation_suppress_etud( %s, %s)" % (formsemestre_id, etudid))
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
args = {"formsemestre_id": formsemestre_id, "etudid": etudid}
try:
@@ -1228,7 +1228,7 @@ def do_formsemestre_validate_previous_ue(
cette UE (utile seulement pour les semestres extérieurs).
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_ue_status
diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py
index ae1a5223..448d6797 100644
--- a/app/scodoc/sco_import_etuds.py
+++ b/app/scodoc/sco_import_etuds.py
@@ -269,7 +269,7 @@ def scolars_import_excel_file(
et les inscrit dans le semestre indiqué (et à TOUS ses modules)
"""
log("scolars_import_excel_file: formsemestre_id=%s" % formsemestre_id)
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
annee_courante = time.localtime()[0]
always_require_ine = sco_preferences.get_preference(context, "always_require_ine")
@@ -495,6 +495,35 @@ def scolars_import_excel_file(
return diag
+def students_import_admission(
+ context, csvfile, type_admission="", REQUEST=None, formsemestre_id=None
+):
+ "import donnees admission from Excel file (v2016)"
+ diag = scolars_import_admission(
+ csvfile,
+ context,
+ REQUEST,
+ formsemestre_id=formsemestre_id,
+ type_admission=type_admission,
+ )
+ if REQUEST:
+ H = [
+ html_sco_header.sco_header(
+ context, REQUEST, page_title="Import données admissions"
+ )
+ ]
+ H.append("Import terminé !
")
+ H.append(
+ 'Continuer
'
+ % "formsemestre_status?formsemestre_id=%s"
+ % formsemestre_id
+ )
+ if diag:
+ H.append("Diagnostic:
" % "".join(diag))
+
+ return "\n".join(H) + html_sco_header.sco_footer(REQUEST)
+
+
def _import_one_student(
context,
cnx,
diff --git a/app/scodoc/sco_parcours_dut.py b/app/scodoc/sco_parcours_dut.py
index 96516637..49b1d9dd 100644
--- a/app/scodoc/sco_parcours_dut.py
+++ b/app/scodoc/sco_parcours_dut.py
@@ -543,7 +543,7 @@ class SituationEtudParcoursGeneric:
"""Enregistre la decision (instance de DecisionSem)
Enregistre codes semestre et UE, et autorisations inscription.
"""
- cnx = self.context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
# -- check
if decision.code_etat in self.parcours.UNUSED_CODES:
raise ScoValueError("code decision invalide dans ce parcours")
@@ -909,7 +909,7 @@ def formsemestre_validate_ues(
Les UE des semestres NON ASSIDUS ne sont jamais validées (code AJ).
"""
valid_semestre = CODES_SEM_VALIDES.get(code_etat_sem, False)
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_ues, get_etud_ue_status
diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py
index 5a40c636..e37c0e6f 100644
--- a/app/scodoc/sco_saisie_notes.py
+++ b/app/scodoc/sco_saisie_notes.py
@@ -472,7 +472,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
# Recherche notes existantes
NotesDB = sco_evaluations.do_evaluation_get_all_notes(context, evaluation_id)
# Met a jour la base
- cnx = context.GetDBConnexion(autocommit=False)
+ cnx = ndb.GetDBConnexion(autocommit=False)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
nb_changed = 0
nb_suppress = 0
diff --git a/app/views/absences.py b/app/views/absences.py
index 9fb8f387..5afdab0f 100644
--- a/app/views/absences.py
+++ b/app/views/absences.py
@@ -765,8 +765,8 @@ def EtatAbsencesGr(
nbabs = sco_abs.CountAbs(
context, etudid=etud["etudid"], debut=datedebut, fin=datefin
)
- nbabsjust = context.CountAbsJust(
- etudid=etud["etudid"], debut=datedebut, fin=datefin
+ nbabsjust = sco_abs.CountAbsJust(
+ context, etudid=etud["etudid"], debut=datedebut, fin=datefin
)
nbjustifs_noabs = len(
sco_abs.ListeJustifs(
@@ -918,11 +918,11 @@ def EtatAbsencesDate(
)
if (nbabsam != 0) or (nbabspm != 0):
nbetud += 1
- nbabsjustam = context.CountAbsJust(
- etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=1
+ nbabsjustam = sco_abs.CountAbsJust(
+ context, etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=1
)
- nbabsjustpm = context.CountAbsJust(
- etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=0
+ nbabsjustpm = sco_abs.CountAbsJust(
+ context, etudid=etud["etudid"], debut=dateiso, fin=dateiso, matin=0
)
H.append(
"""
@@ -1210,7 +1210,8 @@ def deleteBilletAbsence(context, billet_id, REQUEST=None, dialog_confirmed=False
)
if not dialog_confirmed:
tab = _tableBillets(context, billets)
- return context.confirmDialog(
+ return scu.confirm_dialog(
+ context,
"""Supprimer ce billet ?""" + tab.html(),
dest_url="",
REQUEST=REQUEST,
diff --git a/app/views/entreprises.py b/app/views/entreprises.py
index eabe5366..04225376 100644
--- a/app/views/entreprises.py
+++ b/app/views/entreprises.py
@@ -73,7 +73,7 @@ def sidebar(context, REQUEST):
"barre gauche (overide std sco sidebar)"
# rewritten from legacy DTML code
# XXX rare cas restant d'utilisation de l'acquisition Zope2: à revoir
- params = {"ScoURL": context.ScoURL()}
+ params = {"ScoURL": scu.ScoURL()}
H = [
""" |