diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index b620220d3..528c2c85b 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 520820f79..7090f0766 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 1f4981218..272bbd467 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 baa84096d..e42aa9c06 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 92379bcc9..0c173b3d3 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 9f54f2ca7..072c15b8b 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 ae1a52239..448d67970 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 96516637b..49b1d9ddf 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 5a40c6364..e37c0e6fc 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 9fb8f387d..5afdab0f3 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 eabe5366e..04225376f 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 = [ """
  • %(date)s %(description)s
  • """ % c) H.append("""""") - 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( """%s""" - % (context.ScoURL(), c["etudid"], etud["nomprenom"]) + % (scu.ScoURL(), c["etudid"], etud["nomprenom"]) ) if c["description"]: H.append("(%s)" % c["description"]) diff --git a/app/views/notes.py b/app/views/notes.py index cb3b93641..739200a7a 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -847,7 +847,7 @@ def edit_moduleimpl_resp(context, REQUEST, moduleimpl_id): ) -_expr_help = """

    Expérimental: formule de calcul de la moyenne %(target)s

    +_EXPR_HELP = """

    Expérimental: formule de calcul de la moyenne %(target)s

    Attention: l'utilisation de formules ralenti considérablement les traitements. A utiliser uniquement dans els cas ne pouvant pas être traités autrement.

    Dans la formule, les variables suivantes sont définies:

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

    empty page: see logs and mails

    " diff --git a/app/views/scolar.py b/app/views/scolar.py index 0d9e7c499..128cd6f5a 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -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("

    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) - - @bp.route("/formsemestre_import_etud_admission") @permission_required(Permission.ScoEtudChangeAdr) @scodoc7func(context)