1
0
forked from ScoDoc/ScoDoc

migration en cours

This commit is contained in:
Emmanuel Viennet 2021-06-21 12:13:25 +02:00
parent 597b83e6a4
commit ede5aa680d
13 changed files with 79 additions and 71 deletions

View File

@ -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,

View File

@ -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:

View File

@ -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)

View File

@ -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(

View File

@ -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:

View File

@ -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

View File

@ -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("<p>Import terminé !</p>")
H.append(
'<p><a class="stdlink" href="%s">Continuer</a></p>'
% "formsemestre_status?formsemestre_id=%s"
% formsemestre_id
)
if diag:
H.append("<p>Diagnostic: <ul><li>%s</li></ul></p>" % "</li><li>".join(diag))
return "\n".join(H) + html_sco_header.sco_footer(REQUEST)
def _import_one_student(
context,
cnx,

View File

@ -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

View File

@ -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

View File

@ -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(
"""<tr bgcolor="#FFFFFF"><td>
@ -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,
"""<h2>Supprimer ce billet ?</h2>""" + tab.html(),
dest_url="",
REQUEST=REQUEST,

View File

@ -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 = [
"""<div id="sidebar-container">
<div class="sidebar">""",
@ -285,7 +285,7 @@ def entreprise_contact_list(context, entreprise_id=None, format="html", REQUEST=
c["etud"] = context.getEtudInfo(etudid=c["etudid"], filled=1)[0]
c["etudnom"] = c["etud"]["nomprenom"]
c["_etudnom_target"] = "%s/ficheEtud?etudid=%s" % (
context.ScoURL(),
scu.ScoURL(),
c["etudid"],
)
else:
@ -1012,7 +1012,7 @@ def entreprise_delete(context, entreprise_id, REQUEST=None):
for c in Cts:
H.append("""<li>%(date)s %(description)s</li>""" % c)
H.append("""</ul>""")
tf = context.TrivialFormulator(
tf = TrivialFormulator(
REQUEST.URL0,
REQUEST.form,
(("entreprise_id", {"input_type": "hidden"}),),
@ -1290,7 +1290,7 @@ def entreprise_edit(context, entreprise_id, REQUEST=None, start=1):
etud = etud[0]
H.append(
"""<a href="%s/ficheEtud?etudid=%s">%s</a>"""
% (context.ScoURL(), c["etudid"], etud["nomprenom"])
% (scu.ScoURL(), c["etudid"], etud["nomprenom"])
)
if c["description"]:
H.append("(%s)" % c["description"])

View File

@ -847,7 +847,7 @@ def edit_moduleimpl_resp(context, REQUEST, moduleimpl_id):
)
_expr_help = """<p class="help">Expérimental: formule de calcul de la moyenne %(target)s</p>
_EXPR_HELP = """<p class="help">Expérimental: formule de calcul de la moyenne %(target)s</p>
<p class="help">Attention: l'utilisation de formules ralenti considérablement
les traitements. A utiliser uniquement dans els cas ne pouvant pas être traités autrement.</p>
<p class="help">Dans la formule, les variables suivantes sont définies:</p>
@ -885,7 +885,7 @@ def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
% (moduleimpl_id, M["module"]["titre"]),
sem,
),
context._expr_help
_EXPR_HELP
% {
"target": "du module",
"objs": "évaluations",
@ -1041,7 +1041,7 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
% (ue["acronyme"], ue["titre"]),
sem,
),
context._expr_help % {"target": "de l'UE", "objs": "modules", "ordre": ""},
_EXPR_HELP % {"target": "de l'UE", "objs": "modules", "ordre": ""},
]
el = sco_compute_moy.formsemestre_ue_computation_expr_list(
cnx, {"formsemestre_id": formsemestre_id, "ue_id": ue_id}
@ -1636,6 +1636,7 @@ def formsemestre_bulletins_mailetuds_choice(
):
"""Choix version puis envois classeur bulletins pdf"""
if version:
# XXX devrait plutôt utiliser un redirect #sco8
return context.formsemestre_bulletins_mailetuds(
formsemestre_id,
REQUEST,
@ -2451,10 +2452,10 @@ def check_integrity_all(context, REQUEST=None):
for F in sco_formations.formation_list(
context,
):
context.check_form_integrity(F["formation_id"], REQUEST=REQUEST)
check_form_integrity(context, F["formation_id"], REQUEST=REQUEST)
# semestres
for sem in sco_formsemestre.do_formsemestre_list(context):
context.check_formsemestre_integrity(sem["formsemestre_id"], REQUEST=REQUEST)
check_formsemestre_integrity(context, sem["formsemestre_id"], REQUEST=REQUEST)
return (
html_sco_header.sco_header(context, REQUEST=REQUEST)
+ "<p>empty page: see logs and mails</p>"

View File

@ -757,7 +757,8 @@ def formSuppressPhoto(context, etudid=None, REQUEST=None, dialog_confirmed=False
@scodoc7func(context)
def formDem(context, etudid, formsemestre_id, REQUEST):
"Formulaire Démission Etudiant"
return context._formDem_of_Def(
return _formDem_of_Def(
context,
etudid,
formsemestre_id,
REQUEST=REQUEST,
@ -771,7 +772,8 @@ def formDem(context, etudid, formsemestre_id, REQUEST):
@scodoc7func(context)
def formDef(context, etudid, formsemestre_id, REQUEST):
"Formulaire Défaillance Etudiant"
return context._formDem_of_Def(
return _formDem_of_Def(
context,
etudid,
formsemestre_id,
REQUEST=REQUEST,
@ -833,7 +835,8 @@ def _formDem_of_Def(
@scodoc7func(context)
def doDemEtudiant(context, etudid, formsemestre_id, event_date=None, REQUEST=None):
"Déclare la démission d'un etudiant dans le semestre"
return context._doDem_or_Def_Etudiant(
return _do_dem_or_def_etud(
context,
etudid,
formsemestre_id,
event_date=event_date,
@ -849,7 +852,8 @@ def doDemEtudiant(context, etudid, formsemestre_id, event_date=None, REQUEST=Non
@scodoc7func(context)
def doDefEtudiant(context, etudid, formsemestre_id, event_date=None, REQUEST=None):
"Déclare la défaillance d'un etudiant dans le semestre"
return context._doDem_or_Def_Etudiant(
return _do_dem_or_def_etud(
context,
etudid,
formsemestre_id,
event_date=event_date,
@ -860,7 +864,7 @@ def doDefEtudiant(context, etudid, formsemestre_id, event_date=None, REQUEST=Non
)
def _doDem_or_Def_Etudiant(
def _do_dem_or_def_etud(
context,
etudid,
formsemestre_id,
@ -909,7 +913,8 @@ def doCancelDem(
context, etudid, formsemestre_id, dialog_confirmed=False, args=None, REQUEST=None
):
"Annule une démission"
return context._doCancelDem_or_Def(
return _do_cancel_dem_or_def(
context,
etudid,
formsemestre_id,
dialog_confirmed=dialog_confirmed,
@ -930,7 +935,8 @@ def doCancelDef(
context, etudid, formsemestre_id, dialog_confirmed=False, args=None, REQUEST=None
):
"Annule la défaillance de l'étudiant"
return context._doCancelDem_or_Def(
return _do_cancel_dem_or_def(
context,
etudid,
formsemestre_id,
dialog_confirmed=dialog_confirmed,
@ -944,7 +950,7 @@ def doCancelDef(
)
def _doCancelDem_or_Def(
def _do_cancel_dem_or_def(
context,
etudid,
formsemestre_id,
@ -1010,7 +1016,7 @@ def _doCancelDem_or_Def(
@scodoc7func(context)
def etudident_create_form(context, REQUEST=None):
"formulaire creation individuelle etudiant"
return context._etudident_create_or_edit_form(REQUEST, edit=False)
return _etudident_create_or_edit_form(context, REQUEST, edit=False)
@bp.route("/etudident_edit_form")
@ -1018,7 +1024,7 @@ def etudident_create_form(context, REQUEST=None):
@scodoc7func(context)
def etudident_edit_form(context, REQUEST=None):
"formulaire edition individuelle etudiant"
return context._etudident_create_or_edit_form(REQUEST, edit=True)
return _etudident_create_or_edit_form(context, REQUEST, edit=True)
def _etudident_create_or_edit_form(context, REQUEST, edit):
@ -1904,7 +1910,8 @@ def form_students_import_infos_admissions(context, REQUEST, formsemestre_id=None
scu.ScoURL() + "/formsemestre_status?formsemestre_id=" + formsemestre_id
)
else:
return context._students_import_admission(
return sco_import_etuds.students_import_admission(
context,
tf[2]["csvfile"],
type_admission=tf[2]["type_admission"],
REQUEST=REQUEST,
@ -1912,36 +1919,6 @@ def form_students_import_infos_admissions(context, REQUEST, formsemestre_id=None
)
# unpublished
def _students_import_admission(
context, csvfile, type_admission="", REQUEST=None, formsemestre_id=None
):
"import donnees admission from Excel file (v2016)"
diag = sco_import_etuds.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("<p>Import terminé !</p>")
H.append(
'<p><a class="stdlink" href="%s">Continuer</a></p>'
% "formsemestre_status?formsemestre_id=%s"
% formsemestre_id
)
if diag:
H.append("<p>Diagnostic: <ul><li>%s</li></ul></p>" % "</li><li>".join(diag))
return "\n".join(H) + html_sco_header.sco_footer(REQUEST)
@bp.route("/formsemestre_import_etud_admission")
@permission_required(Permission.ScoEtudChangeAdr)
@scodoc7func(context)