From 24416e256dbdce0100f01643f4030c8261bc3bf6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 19 Aug 2021 10:28:35 +0200 Subject: [PATCH] refactoring (context) --- app/decorators.py | 4 +- app/scodoc/gen_tables.py | 5 +- app/scodoc/notes_table.py | 6 +- app/scodoc/pe_jurype.py | 8 +- app/scodoc/pe_view.py | 2 +- app/scodoc/sco_abs.py | 12 +- app/scodoc/sco_abs_notification.py | 2 +- app/scodoc/sco_abs_views.py | 12 +- app/scodoc/sco_apogee_csv.py | 8 +- app/scodoc/sco_archives.py | 8 +- app/scodoc/sco_archives_etud.py | 2 +- app/scodoc/sco_bulletins.py | 22 +- app/scodoc/sco_bulletins_generator.py | 1 - app/scodoc/sco_bulletins_json.py | 10 +- app/scodoc/sco_bulletins_legacy.py | 2 +- app/scodoc/sco_bulletins_pdf.py | 3 +- app/scodoc/sco_bulletins_standard.py | 2 +- app/scodoc/sco_bulletins_xml.py | 10 +- app/scodoc/sco_compute_moy.py | 8 +- app/scodoc/sco_cost_formation.py | 4 +- app/scodoc/sco_dept.py | 8 +- app/scodoc/sco_edit_formation.py | 14 +- app/scodoc/sco_edit_matiere.py | 12 +- app/scodoc/sco_edit_module.py | 18 +- app/scodoc/sco_edit_ue.py | 28 +-- app/scodoc/sco_edt_cal.py | 4 +- app/scodoc/sco_etape_apogee_view.py | 7 +- app/scodoc/sco_etud.py | 8 +- app/scodoc/sco_evaluations.py | 18 +- app/scodoc/sco_export_results.py | 2 +- app/scodoc/sco_find_etud.py | 2 +- app/scodoc/sco_formations.py | 6 +- app/scodoc/sco_formsemestre.py | 101 ++++---- app/scodoc/sco_formsemestre_custommenu.py | 4 +- app/scodoc/sco_formsemestre_edit.py | 75 +++--- app/scodoc/sco_formsemestre_exterieurs.py | 12 +- app/scodoc/sco_formsemestre_inscriptions.py | 42 ++-- app/scodoc/sco_formsemestre_status.py | 48 ++-- app/scodoc/sco_formsemestre_validation.py | 38 ++- app/scodoc/sco_groups.py | 242 +++++++++----------- app/scodoc/sco_groups_edit.py | 6 +- app/scodoc/sco_groups_view.py | 42 ++-- app/scodoc/sco_import_etuds.py | 12 +- app/scodoc/sco_inscr_passage.py | 25 +- app/scodoc/sco_liste_notes.py | 14 +- app/scodoc/sco_lycee.py | 6 +- app/scodoc/sco_moduleimpl.py | 6 +- app/scodoc/sco_moduleimpl_inscriptions.py | 24 +- app/scodoc/sco_moduleimpl_status.py | 8 +- app/scodoc/sco_news.py | 2 +- app/scodoc/sco_page_etud.py | 12 +- app/scodoc/sco_parcours_dut.py | 22 +- app/scodoc/sco_pdf.py | 6 +- app/scodoc/sco_permissions_check.py | 12 +- app/scodoc/sco_placement.py | 14 +- app/scodoc/sco_poursuite_dut.py | 4 +- app/scodoc/sco_preferences.py | 2 +- app/scodoc/sco_prepajury.py | 12 +- app/scodoc/sco_pvjury.py | 24 +- app/scodoc/sco_pvpdf.py | 2 +- app/scodoc/sco_recapcomplet.py | 20 +- app/scodoc/sco_report.py | 20 +- app/scodoc/sco_saisie_notes.py | 12 +- app/scodoc/sco_semset.py | 5 +- app/scodoc/sco_synchro_etuds.py | 8 +- app/scodoc/sco_trombino.py | 2 - app/scodoc/sco_trombino_tours.py | 10 +- app/scodoc/sco_ue_external.py | 8 +- app/scodoc/sco_undo_notes.py | 6 +- app/views/absences.py | 16 +- app/views/entreprises.py | 6 +- app/views/notes.py | 38 ++- app/views/scolar.py | 26 +-- refactor.py | 191 --------------- scotests/test_groupes.py | 8 +- scotests/test_jurype.py | 2 +- tests/unit/sco_fake_gen.py | 4 +- tests/unit/test_abs_demijournee.py | 9 +- tests/unit/test_caches.py | 2 +- 79 files changed, 552 insertions(+), 916 deletions(-) delete mode 100755 refactor.py diff --git a/app/decorators.py b/app/decorators.py index 0f23be895..2ebb5accb 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -112,11 +112,11 @@ def scodoc(func): def scodoc_function(*args, **kwargs): if "scodoc_dept" in kwargs: dept_acronym = kwargs["scodoc_dept"] - current_app.logger.info("setting dept to " + dept_acronym) + # current_app.logger.info("setting dept to " + dept_acronym) app.set_sco_dept(dept_acronym) del kwargs["scodoc_dept"] elif not hasattr(g, "scodoc_dept"): - current_app.logger.info("setting dept to None") + # current_app.logger.info("setting dept to None") g.scodoc_dept = None g.scodoc_dept_id = -1 # invalide return func(*args, **kwargs) diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 7936f23dc..d1817d364 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -604,7 +604,6 @@ class GenTable(object): def make_page( self, - context, title="", format="html", page_title="", @@ -644,7 +643,7 @@ class GenTable(object): elif format == "pdf": objects = self.pdf() doc = sco_pdf.pdf_basic_page( - objects, title=title, preferences=self.preferences, context=context + objects, title=title, preferences=self.preferences ) if publish: return scu.sendPDFFile(REQUEST, doc, filename + ".pdf") @@ -731,5 +730,5 @@ if __name__ == "__main__": document.build(objects) data = doc.getvalue() open("/tmp/gen_table.pdf", "wb").write(data) - p = T.make_page(None, format="pdf", REQUEST=None) + p = T.make_page(format="pdf", REQUEST=None) open("toto.pdf", "wb").write(p) diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index daf87666a..ca49fc1b7 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -182,7 +182,7 @@ class NotesTable(object): self.context = context self.formsemestre_id = formsemestre_id cnx = ndb.GetDBConnexion() - self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + self.sem = sco_formsemestre.get_formsemestre(formsemestre_id) self.moduleimpl_stats = {} # { moduleimpl_id : {stats} } self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap self._evaluations_etats = None # liste des evaluations avec état @@ -191,7 +191,7 @@ class NotesTable(object): ) # Infos sur les etudiants self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( - context, args={"formsemestre_id": formsemestre_id} + args={"formsemestre_id": formsemestre_id} ) # infos identite etudiant # xxx sous-optimal: 1/select par etudiant -> 0.17" pour identdict sur GTR1 ! @@ -245,7 +245,7 @@ class NotesTable(object): # nb_inscrits, nb_notes, nb_abs, nb_neutre, moy, median, last_modif= self.formation = sco_formations.formation_list( - context, args={"formation_id": self.sem["formation_id"]} + args={"formation_id": self.sem["formation_id"]} )[0] self.parcours = sco_codes_parcours.get_parcours_from_code( self.formation["type_parcours"] diff --git a/app/scodoc/pe_jurype.py b/app/scodoc/pe_jurype.py index 0a0c073b5..888924f09 100644 --- a/app/scodoc/pe_jurype.py +++ b/app/scodoc/pe_jurype.py @@ -67,9 +67,7 @@ def comp_nom_semestre_dans_parcours(context, sem): """ from app.scodoc import sco_formations - F = sco_formations.formation_list( - context, args={"formation_id": sem["formation_id"]} - )[0] + F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"]) return "%s %s %s %s" % ( parcours.SESSION_NAME, # eg "semestre" @@ -1240,8 +1238,8 @@ def get_cosemestres_diplomants(context, semBase, avec_meme_formation=False): > dont la formation est la même (optionnel) > ne prenant en compte que les etudiants sans redoublement """ - tousLesSems = sco_formsemestre.do_formsemestre_list( - context + tousLesSems = ( + sco_formsemestre.do_formsemestre_list() ) # tous les semestres memorisés dans scodoc diplome = get_annee_diplome_semestre(semBase) diff --git a/app/scodoc/pe_view.py b/app/scodoc/pe_view.py index 788de9b13..9411a0b6c 100644 --- a/app/scodoc/pe_view.py +++ b/app/scodoc/pe_view.py @@ -91,7 +91,7 @@ def pe_view_sem_recap( return _pe_view_sem_recap_form(context, formsemestre_id, REQUEST=REQUEST) prefs = sco_preferences.SemPreferences(formsemestre_id=formsemestre_id) - semBase = sco_formsemestre.get_formsemestre(context, formsemestre_id) + semBase = sco_formsemestre.get_formsemestre(formsemestre_id) jury = pe_jurype.JuryPE(context, semBase) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 323a1e1d8..025bc6d43 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -28,14 +28,12 @@ """Fonctions sur les absences """ -# Anciennement dans ZAbscences.py, séparé pour migration - +import calendar +import datetime +import html import string import time import types -import datetime -import calendar -import cgi from app.scodoc import notesdb as ndb from app.scodoc.notes_log import log @@ -896,7 +894,7 @@ def MonthTableBody( if href: href = 'href="%s"' % href if descr: - descr = 'title="%s"' % cgi.escape(descr, quote=True) + descr = 'title="%s"' % html.escape(descr, quote=True) if href or descr: cc.append("" % (href, descr)) @@ -990,7 +988,7 @@ def MonthTableBody( if href: href = 'href="%s"' % href if descr: - descr = 'title="%s"' % cgi.escape(descr, quote=True) + descr = 'title="%s"' % html.escape(descr, quote=True) if href or descr: cc.append("" % (href, descr)) if legend or d == 1: diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py index d583a6272..afe9e584a 100644 --- a/app/scodoc/sco_abs_notification.py +++ b/app/scodoc/sco_abs_notification.py @@ -284,7 +284,7 @@ def retreive_current_formsemestre(context, etudid, cur_date): if not r: return None # s'il y a plusieurs semestres, prend le premier (rarissime et non significatif): - sem = sco_formsemestre.get_formsemestre(context, r[0]["formsemestre_id"]) + sem = sco_formsemestre.get_formsemestre(r[0]["formsemestre_id"]) return sem diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 9088a0efe..0d7f16926 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -700,15 +700,15 @@ def formChoixSemestreGroupe(context, all=False): """ # XXX assez primitif, à ameliorer TOTALEMENT OBSOLETE ! if all: - sems = sco_formsemestre.do_formsemestre_list(context) + sems = sco_formsemestre.do_formsemestre_list() else: - sems = sco_formsemestre.do_formsemestre_list(context, args={"etat": "1"}) + sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"}) if not sems: raise ScoValueError("aucun semestre !") H = [' """, - REQUEST=REQUEST, ) tab.base_url = "%s?etape_apo=%s" % (REQUEST.URL0, etape_apo or "") - return tab.make_page(context, format=format, REQUEST=REQUEST) + return tab.make_page(format=format, REQUEST=REQUEST) def sem_has_etape(sem, code_etape): diff --git a/app/scodoc/sco_formsemestre_custommenu.py b/app/scodoc/sco_formsemestre_custommenu.py index dc039057f..18036050d 100644 --- a/app/scodoc/sco_formsemestre_custommenu.py +++ b/app/scodoc/sco_formsemestre_custommenu.py @@ -62,7 +62,7 @@ def formsemestre_custommenu_html(context, formsemestre_id): "HTML code for custom menu" menu = [] # Calendrier électronique ? - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) ics_url = sco_edt_cal.formsemestre_get_ics_url(context, sem) if ics_url: menu.append({"title": "Emploi du temps (ics)", "url": ics_url}) @@ -79,7 +79,7 @@ def formsemestre_custommenu_html(context, formsemestre_id): def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None): """Dialog to edit the custom menu""" - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) dest_url = ( scu.NotesURL() + "/formsemestre_status?formsemestre_id=%s" % formsemestre_id ) diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index a3575dedc..dfb036fb1 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -88,7 +88,7 @@ def formsemestre_createwithmodules(context, REQUEST=None): def formsemestre_editwithmodules(context, REQUEST, formsemestre_id): """Page modification semestre""" # portage from dtml - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) H = [ html_sco_header.html_sem_header( context, @@ -124,7 +124,7 @@ def formsemestre_editwithmodules(context, REQUEST, formsemestre_id): def can_edit_sem(context, REQUEST, formsemestre_id="", sem=None): """Return sem if user can edit it, False otherwise""" - sem = sem or sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sem or sco_formsemestre.get_formsemestre(formsemestre_id) if not current_user.has_permission(Permission.ScoImplement): # pas chef if not sem["resp_can_edit"] or current_user.id not in sem["responsables"]: return False @@ -136,7 +136,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): # Fonction accessible à tous, controle acces à la main: if edit: formsemestre_id = int(REQUEST.form["formsemestre_id"]) - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) if not current_user.has_permission(Permission.ScoImplement): if not edit: # il faut ScoImplement pour creer un semestre @@ -155,7 +155,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): allowed_user_names = list(uid2display.values()) + [""] # formation_id = int(REQUEST.form["formation_id"]) - F = sco_formations.formation_list(context, args={"formation_id": formation_id}) + F = sco_formations.formation_list(args={"formation_id": formation_id}) if not F: raise ScoValueError("Formation inexistante !") F = F[0] @@ -551,9 +551,9 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): opt_selected(default_group_id), ) fcg += '' % opt_selected("") - for p in sco_groups.get_partitions_list(context, formsemestre_id): + for p in sco_groups.get_partitions_list(formsemestre_id): if p["partition_name"] != None: - for group in sco_groups.get_partition_groups(context, p): + for group in sco_groups.get_partition_groups(p): fcg += '' % ( group["group_id"], opt_selected(group["group_id"]), @@ -750,7 +750,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): # nouveaux modules # (retire le "MI" du début du nom de champs) checkedmods = [int(x[2:]) for x in tf[2]["tf-checked"]] - sco_formsemestre.do_formsemestre_edit(context, tf[2]) + sco_formsemestre.do_formsemestre_edit(tf[2]) ams = sco_moduleimpl.do_moduleimpl_list( context, formsemestre_id=formsemestre_id ) @@ -781,8 +781,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): group_id = tf[2]["%s!group_id" % module_id] if group_id: etudids = [ - x["etudid"] - for x in sco_groups.get_group_members(context, group_id) + x["etudid"] for x in sco_groups.get_group_members(group_id) ] log( "inscription module:module_id=%s,moduleimpl_id=%s: %s" @@ -882,7 +881,7 @@ def formsemestre_clone(context, formsemestre_id, REQUEST=None): """ Formulaire clonage d'un semestre """ - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) # Liste des enseignants avec forme pour affichage / saisie avec suggestion userlist = sco_users.get_user_list() uid2display = {} # user_name : forme pour affichage = "NOM Prenom (login)" @@ -1020,7 +1019,7 @@ def do_formsemestre_clone( New dates, responsable_id """ log("cloning %s" % orig_formsemestre_id) - orig_sem = sco_formsemestre.get_formsemestre(context, orig_formsemestre_id) + orig_sem = sco_formsemestre.get_formsemestre(orig_formsemestre_id) cnx = ndb.GetDBConnexion() # 1- create sem args = orig_sem.copy() @@ -1098,30 +1097,27 @@ def do_formsemestre_clone( listgroups = [] listnamegroups = [] # Création des partitions: - for part in sco_groups.get_partitions_list(context, orig_formsemestre_id): + for part in sco_groups.get_partitions_list(orig_formsemestre_id): if part["partition_name"] != None: partname = part["partition_name"] new_partition_id = sco_groups.partition_create( - context, formsemestre_id, partition_name=partname, redirect=0, ) - for g in sco_groups.get_partition_groups(context, part): + for g in sco_groups.get_partition_groups(part): if g["group_name"] != None: listnamegroups.append(g["group_name"]) listgroups.append([new_partition_id, listnamegroups]) listnamegroups = [] # Création des groupes dans les nouvelles partitions: - for newpart in sco_groups.get_partitions_list(context, formsemestre_id): + for newpart in sco_groups.get_partitions_list(formsemestre_id): for g in listgroups: if newpart["partition_id"] == g[0]: part_id = g[0] for group_name in g[1]: - _ = sco_groups.createGroup( - context, part_id, group_name=group_name - ) + _ = sco_groups.createGroup(part_id, group_name=group_name) return formsemestre_id @@ -1139,12 +1135,9 @@ def formsemestre_associate_new_version( """Formulaire changement formation d'un semestre""" if not dialog_confirmed: # dresse le liste des semestres de la meme formation et version - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) - F = sco_formations.formation_list( - context, args={"formation_id": sem["formation_id"]} - )[0] + sem = sco_formsemestre.get_formsemestre(formsemestre_id) + F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] othersems = sco_formsemestre.do_formsemestre_list( - context, args={ "formation_id": F["formation_id"], "version": F["version"], @@ -1202,10 +1195,10 @@ def do_formsemestres_associate_new_version(context, formsemestre_ids, REQUEST=No if not formsemestre_ids: return # Check: tous de la même formation - sem = sco_formsemestre.get_formsemestre(context, formsemestre_ids[0]) + sem = sco_formsemestre.get_formsemestre(formsemestre_ids[0]) formation_id = sem["formation_id"] for formsemestre_id in formsemestre_ids[1:]: - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) if formation_id != sem["formation_id"]: raise ScoValueError("les semestres ne sont pas tous de la même formation !") @@ -1220,9 +1213,9 @@ def do_formsemestres_associate_new_version(context, formsemestre_ids, REQUEST=No ) for formsemestre_id in formsemestre_ids: - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) sem["formation_id"] = formation_id - sco_formsemestre.do_formsemestre_edit(context, sem, cnx=cnx, html_quote=False) + sco_formsemestre.do_formsemestre_edit(sem, cnx=cnx, html_quote=False) _reassociate_moduleimpls( context, cnx, formsemestre_id, ues_old2new, modules_old2new ) @@ -1261,10 +1254,8 @@ def _reassociate_moduleimpls( def formsemestre_delete(context, formsemestre_id, REQUEST=None): """Delete a formsemestre (affiche avertissements)""" - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) - F = sco_formations.formation_list( - context, args={"formation_id": sem["formation_id"]} - )[0] + sem = sco_formsemestre.get_formsemestre(formsemestre_id) + F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0] H = [ html_sco_header.html_sem_header( context, REQUEST, "Suppression du semestre", sem @@ -1357,7 +1348,7 @@ def do_formsemestre_delete(context, formsemestre_id): No checks, no warnings: erase all ! """ cnx = ndb.GetDBConnexion() - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) sco_cache.EvaluationCache.invalidate_sem(formsemestre_id) @@ -1478,7 +1469,7 @@ def formsemestre_change_lock( ok, err = sco_permissions_check.check_access_diretud(formsemestre_id) if not ok: return err - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) etat = not sem["etat"] if REQUEST and not dialog_confirmed: @@ -1500,7 +1491,7 @@ def formsemestre_change_lock( ) args = {"formsemestre_id": formsemestre_id, "etat": etat} - sco_formsemestre.do_formsemestre_edit(context, args) + sco_formsemestre.do_formsemestre_edit(args) if REQUEST: return flask.redirect( "formsemestre_status?formsemestre_id=%s" % formsemestre_id @@ -1514,7 +1505,7 @@ def formsemestre_change_publication_bul( ok, err = sco_permissions_check.check_access_diretud(formsemestre_id) if not ok: return err - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) etat = not sem["bul_hide_xml"] if REQUEST and not dialog_confirmed: @@ -1535,7 +1526,7 @@ def formsemestre_change_publication_bul( ) args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat} - sco_formsemestre.do_formsemestre_edit(context, args) + sco_formsemestre.do_formsemestre_edit(args) if REQUEST: return flask.redirect( "formsemestre_status?formsemestre_id=%s" % formsemestre_id @@ -1550,7 +1541,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST= ok, err = sco_permissions_check.check_access_diretud(formsemestre_id) if not ok: return err - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) footer = html_sco_header.sco_footer() help = """

@@ -1664,11 +1655,11 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST= # apply modifications for ue in ue_modified: sco_formsemestre.do_formsemestre_uecoef_edit_or_create( - context, cnx, formsemestre_id, ue["ue_id"], ue["coef"] + cnx, formsemestre_id, ue["ue_id"], ue["coef"] ) for ue in ue_deleted: sco_formsemestre.do_formsemestre_uecoef_delete( - context, cnx, formsemestre_id, ue["ue_id"] + cnx, formsemestre_id, ue["ue_id"] ) if ue_modified or ue_deleted: @@ -1702,7 +1693,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST= # ----- identification externe des sessions (pour SOJA et autres logiciels) -def get_formsemestre_session_id(context, sem, F, parcours): +def get_formsemestre_session_id(sem, F, parcours): """Identifiant de session pour ce semestre Exemple: RT-DUT-FI-S1-ANNEE @@ -1716,8 +1707,8 @@ def get_formsemestre_session_id(context, sem, F, parcours): ANNEE=annee universitaire de debut (exemple: un S2 de 2013-2014 sera S2-2013) """ - # sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) - # F = sco_formations.formation_list(context, args={ 'formation_id' : sem['formation_id'] } )[0] + # sem = sco_formsemestre.get_formsemestre( formsemestre_id) + # F = sco_formations.formation_list( args={ 'formation_id' : sem['formation_id'] } )[0] # parcours = sco_codes_parcours.get_parcours_from_code(F['type_parcours']) ImputationDept = sco_preferences.get_preference( diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index 40555ad7f..d648d9c44 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -57,7 +57,7 @@ def formsemestre_ext_create(context, etudid, sem_params, REQUEST=None): """ # Check args _formation = sco_formations.formation_list( - context, args={"formation_id": sem_params["formation_id"]} + args={"formation_id": sem_params["formation_id"]} )[0] if etudid: _etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] @@ -105,17 +105,15 @@ def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None) ), ] F = html_sco_header.sco_footer() - orig_sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + orig_sem = sco_formsemestre.get_formsemestre(formsemestre_id) # Ne propose que des semestres de semestre_id strictement inférieur au semestre courant # et seulement si pas inscrit au même semestre_id d'un semestre ordinaire ScoDoc. # Les autres situations (eg redoublements en changeant d'établissement) # doivent être gérées par les validations de semestres "antérieurs" insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( - context, args={"etudid": etudid, "etat": "I"} + args={"etudid": etudid, "etat": "I"} ) - semlist = [ - sco_formsemestre.get_formsemestre(context, i["formsemestre_id"]) for i in insem - ] + semlist = [sco_formsemestre.get_formsemestre(i["formsemestre_id"]) for i in insem] existing_semestre_ids = set([s["semestre_id"] for s in semlist]) min_semestre_id = 1 max_semestre_id = orig_sem["semestre_id"] @@ -223,7 +221,7 @@ def formsemestre_ext_edit_ue_validations( La moyenne générale du semestre est calculée et affichée, mais pas enregistrée. """ - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] ue_list = _list_ue_with_coef_and_validations(context, sem, etudid) descr = _ue_form_description(context, ue_list, REQUEST.form) diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 6d510a20d..5da1bba3e 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -58,19 +58,19 @@ _formsemestre_inscriptionEditor = ndb.EditableTable( ) -def do_formsemestre_inscription_list(context, *args, **kw): +def do_formsemestre_inscription_list(*args, **kw): "list formsemestre_inscriptions" cnx = ndb.GetDBConnexion() return _formsemestre_inscriptionEditor.list(cnx, *args, **kw) -def do_formsemestre_inscription_listinscrits(context, formsemestre_id): +def do_formsemestre_inscription_listinscrits(formsemestre_id): """Liste les inscrits (état I) à ce semestre et cache le résultat""" r = sco_cache.SemInscriptionsCache.get(formsemestre_id) if r is None: # retreive list r = do_formsemestre_inscription_list( - context, args={"formsemestre_id": formsemestre_id, "etat": "I"} + args={"formsemestre_id": formsemestre_id, "etat": "I"} ) sco_cache.SemInscriptionsCache.set(formsemestre_id, r) return r @@ -81,7 +81,7 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None): cnx = ndb.GetDBConnexion() log("do_formsemestre_inscription_create: args=%s" % str(args)) sems = sco_formsemestre.do_formsemestre_list( - context, {"formsemestre_id": args["formsemestre_id"]} + {"formsemestre_id": args["formsemestre_id"]} ) if len(sems) != 1: raise ScoValueError("code de semestre invalide: %s" % args["formsemestre_id"]) @@ -141,7 +141,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non """ from app.scodoc import sco_formsemestre_edit - sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + sem = sco_formsemestre.get_formsemestre(formsemestre_id) # -- check lock if not sem["etat"]: raise ScoValueError("desinscription impossible: semestre verrouille") @@ -154,7 +154,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non ) insem = do_formsemestre_inscription_list( - context, args={"formsemestre_id": formsemestre_id, "etudid": etudid} + args={"formsemestre_id": formsemestre_id, "etudid": etudid} ) if not insem: raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid) @@ -179,7 +179,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non # --- Semestre extérieur if sem["modalite"] == "EXT": inscrits = do_formsemestre_inscription_list( - context, args={"formsemestre_id": formsemestre_id} + args={"formsemestre_id": formsemestre_id} ) nbinscrits = len(inscrits) if nbinscrits == 0: @@ -224,13 +224,13 @@ def do_formsemestre_inscription_with_modules( # inscriptions aux groupes # 1- inscrit au groupe 'tous' group_id = sco_groups.get_default_group(formsemestre_id) - sco_groups.set_group(context, etudid, group_id) + sco_groups.set_group(etudid, group_id) gdone = {group_id: 1} # empeche doublons # 2- inscrit aux groupes for group_id in group_ids: if group_id and not group_id in gdone: - sco_groups.set_group(context, etudid, group_id) + sco_groups.set_group(etudid, group_id) gdone[group_id] = 1 # inscription a tous les modules de ce semestre @@ -289,10 +289,8 @@ def formsemestre_inscription_with_modules_form(

Choisir un semestre:

""" ) F = html_sco_header.sco_footer() - sems = sco_formsemestre.do_formsemestre_list(context, args={"etat": "1"}) - insem = do_formsemestre_inscription_list( - context, args={"etudid": etudid, "etat": "I"} - ) + sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"}) + insem = do_formsemestre_inscription_list(args={"etudid": etudid, "etat": "I"}) if sems: H.append("