From eff9ae59bc94dade30ad377692b12d2cdcf452b1 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 28 Jul 2021 18:03:54 +0300 Subject: [PATCH] removed useless context arg from preferences --- app/scodoc/html_sidebar.py | 10 ++-- app/scodoc/notes_log.py | 2 +- app/scodoc/notes_table.py | 3 +- app/scodoc/notesdb.py | 6 +-- app/scodoc/pe_avislatex.py | 2 +- app/scodoc/pe_view.py | 2 +- app/scodoc/sco_abs.py | 2 +- app/scodoc/sco_abs_notification.py | 15 +++--- app/scodoc/sco_abs_views.py | 12 ++--- app/scodoc/sco_apogee_compare.py | 4 +- app/scodoc/sco_bulletins.py | 46 ++++++---------- app/scodoc/sco_bulletins_generator.py | 10 ++-- app/scodoc/sco_bulletins_json.py | 17 +++--- app/scodoc/sco_bulletins_legacy.py | 24 ++++----- app/scodoc/sco_bulletins_pdf.py | 16 +++--- app/scodoc/sco_bulletins_standard.py | 2 +- app/scodoc/sco_bulletins_ucac.py | 4 +- app/scodoc/sco_bulletins_xml.py | 17 +++--- app/scodoc/sco_cache.py | 12 ++--- app/scodoc/sco_cost_formation.py | 2 +- app/scodoc/sco_debouche.py | 9 +--- app/scodoc/sco_dept.py | 6 +-- app/scodoc/sco_dump_db.py | 4 +- app/scodoc/sco_edit_matiere.py | 2 - app/scodoc/sco_edit_module.py | 2 - app/scodoc/sco_edit_ue.py | 11 +--- app/scodoc/sco_edt_cal.py | 4 +- app/scodoc/sco_etape_apogee_view.py | 22 +++----- app/scodoc/sco_etud.py | 10 ++-- app/scodoc/sco_evaluations.py | 2 +- app/scodoc/sco_excel.py | 2 +- app/scodoc/sco_export_results.py | 5 +- app/scodoc/sco_find_etud.py | 24 +-------- app/scodoc/sco_formations.py | 4 +- app/scodoc/sco_formsemestre.py | 10 +--- app/scodoc/sco_formsemestre_edit.py | 20 +++---- app/scodoc/sco_formsemestre_status.py | 22 ++++---- app/scodoc/sco_formsemestre_validation.py | 7 +-- app/scodoc/sco_groups.py | 26 ++------- app/scodoc/sco_groups_view.py | 4 +- app/scodoc/sco_import_etuds.py | 6 +-- app/scodoc/sco_import_users.py | 2 +- app/scodoc/sco_inscr_passage.py | 4 +- app/scodoc/sco_liste_notes.py | 6 +-- app/scodoc/sco_lycee.py | 6 +-- app/scodoc/sco_moduleimpl_inscriptions.py | 1 - app/scodoc/sco_news.py | 2 +- app/scodoc/sco_photos.py | 2 +- app/scodoc/sco_placement.py | 2 +- app/scodoc/sco_portal_apogee.py | 28 +++++----- app/scodoc/sco_poursuite_dut.py | 2 +- app/scodoc/sco_preferences.py | 51 +++++++++--------- app/scodoc/sco_prepajury.py | 8 +-- app/scodoc/sco_pvjury.py | 14 ++--- app/scodoc/sco_pvpdf.py | 64 +++++++++-------------- app/scodoc/sco_recapcomplet.py | 10 ++-- app/scodoc/sco_report.py | 6 +-- app/scodoc/sco_semset.py | 5 +- app/scodoc/sco_tag_module.py | 4 -- app/scodoc/sco_trombino.py | 4 +- app/scodoc/sco_trombino_tours.py | 39 ++++++-------- app/scodoc/sco_ue_external.py | 10 ++-- app/scodoc/sco_undo_notes.py | 5 +- app/scodoc/sco_utils.py | 8 ++- app/views/absences.py | 18 +++---- app/views/notes.py | 6 +-- app/views/scolar.py | 14 +++-- scotests/test-all-moys.py | 4 +- 68 files changed, 270 insertions(+), 465 deletions(-) diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index 8fe5e5d9..c041c693 100644 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -135,7 +135,7 @@ def sidebar(context, REQUEST=None): """ % params ) - if sco_preferences.get_preference(context, "handle_billets_abs"): + if sco_preferences.get_preference("handle_billets_abs"): H.append( """
  • Billets
  • """ % params @@ -172,11 +172,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" - ), - "DeptIntranetURL": sco_preferences.get_preference(context, "DeptIntranetURL"), - "DeptName": sco_preferences.get_preference(context, "DeptName"), + "DeptIntranetTitle": sco_preferences.get_preference("DeptIntranetTitle"), + "DeptIntranetURL": sco_preferences.get_preference("DeptIntranetURL"), + "DeptName": sco_preferences.get_preference("DeptName"), "ScoURL": scu.ScoURL(), } diff --git a/app/scodoc/notes_log.py b/app/scodoc/notes_log.py index add8455e..7b0b7288 100644 --- a/app/scodoc/notes_log.py +++ b/app/scodoc/notes_log.py @@ -105,7 +105,7 @@ def sendAlarm(context, subj, txt): msg = MIMEMultipart() subj = Header(subj, sco_utils.SCO_ENCODING) msg["Subject"] = subj - msg["From"] = sco_preferences.get_preference(context, "email_from_addr") + msg["From"] = sco_preferences.get_preference("email_from_addr") msg["To"] = ALARM_DESTINATION msg.epilogue = "" txt = MIMEText(txt, "plain", sco_utils.SCO_ENCODING) diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index 6e849893..70d00587 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -131,7 +131,6 @@ def comp_etud_sum_coef_modules_ue(context, formsemestre_id, etudid, ue_id): (nécessaire pour éviter appels récursifs de nt, qui peuvent boucler) """ infos = ndb.SimpleDictFetch( - context, """SELECT mod.coefficient FROM notes_modules mod, notes_moduleimpl mi, notes_moduleimpl_inscription ins WHERE mod.module_id = mi.module_id @@ -188,7 +187,7 @@ class NotesTable(object): self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap self._evaluations_etats = None # liste des evaluations avec état self.use_ue_coefs = sco_preferences.get_preference( - context, "use_ue_coefs", formsemestre_id + "use_ue_coefs", formsemestre_id ) # Infos sur les etudiants self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 7c1ff399..e23fc903 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -78,7 +78,7 @@ class ScoDocCursor(psycopg2.extensions.cursor): return {} -def SimpleQuery(context, query, args, cursor=None): +def SimpleQuery(query, args, cursor=None): if not cursor: cnx = GetDBConnexion() cursor = cnx.cursor(cursor_factory=ScoDocCursor) @@ -87,8 +87,8 @@ def SimpleQuery(context, query, args, cursor=None): return cursor -def SimpleDictFetch(context, query, args, cursor=None): - cursor = SimpleQuery(context, query, args, cursor=cursor) +def SimpleDictFetch(query, args, cursor=None): + cursor = SimpleQuery(query, args, cursor=cursor) return cursor.dictfetchall() diff --git a/app/scodoc/pe_avislatex.py b/app/scodoc/pe_avislatex.py index 01e1a65c..9699359a 100644 --- a/app/scodoc/pe_avislatex.py +++ b/app/scodoc/pe_avislatex.py @@ -73,7 +73,7 @@ def get_code_latex_from_scodoc_preference( Extrait le template (ou le tag d'annotation au regard du champ fourni) des préférences LaTeX et s'assure qu'il est renvoyé au format unicode """ - template_latex = sco_preferences.get_preference(context, champ, formsemestre_id) + template_latex = sco_preferences.get_preference(champ, formsemestre_id) return template_latex or "" diff --git a/app/scodoc/pe_view.py b/app/scodoc/pe_view.py index 1906cb0a..efe0e72b 100644 --- a/app/scodoc/pe_view.py +++ b/app/scodoc/pe_view.py @@ -91,7 +91,7 @@ def pe_view_sem_recap( """ if REQUEST and REQUEST.REQUEST_METHOD == "GET": return _pe_view_sem_recap_form(context, formsemestre_id, REQUEST=REQUEST) - prefs = sco_preferences.SemPreferences(context, formsemestre_id=formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id=formsemestre_id) semBase = sco_formsemestre.get_formsemestre(context, formsemestre_id) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 65e1f9d5..13db0e33 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -68,7 +68,7 @@ def _toboolean(x): def is_work_saturday(context): "Vrai si le samedi est travaillé" - return int(sco_preferences.get_preference(context, "work_saturday")) + return int(sco_preferences.get_preference("work_saturday")) def MonthNbDays(month, year): diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py index bbb7bd70..9b92563c 100644 --- a/app/scodoc/sco_abs_notification.py +++ b/app/scodoc/sco_abs_notification.py @@ -73,9 +73,7 @@ def do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust): formsemestre_id = sem["formsemestre_id"] else: formsemestre_id = None - prefs = sco_preferences.SemPreferences( - context, formsemestre_id=sem["formsemestre_id"] - ) + prefs = sco_preferences.SemPreferences(formsemestre_id=sem["formsemestre_id"]) destinations = abs_notify_get_destinations( context, sem, prefs, etudid, date, nbabs, nbabsjust @@ -85,7 +83,7 @@ def do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust): return # abort # Vérification fréquence (pour ne pas envoyer de mails trop souvent) - abs_notify_max_freq = sco_preferences.get_preference(context, "abs_notify_max_freq") + abs_notify_max_freq = sco_preferences.get_preference("abs_notify_max_freq") destinations_filtered = [] for email_addr in destinations: nbdays_since_last_notif = user_nbdays_since_last_notif( @@ -120,7 +118,6 @@ def abs_notify_send( msg["To"] = email sco_emails.sendEmail(context, msg) ndb.SimpleQuery( - context, """insert into absences_notifications (etudid, email, nbabs, nbabsjust, formsemestre_id) values (%(etudid)s, %(email)s, %(nbabs)s, %(nbabsjust)s, %(formsemestre_id)s)""", vars(), cursor=cursor, @@ -184,10 +181,10 @@ def abs_notify_is_above_threshold(context, etudid, nbabs, nbabsjust, formsemestr (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", formsemestre_id ) abs_notify_abs_increment = sco_preferences.get_preference( - context, "abs_notify_abs_increment", formsemestre_id + "abs_notify_abs_increment", formsemestre_id ) nbabs_last_notified = etud_nbabs_last_notified(context, etudid, formsemestre_id) @@ -278,7 +275,7 @@ def retreive_current_formsemestre(context, etudid, cur_date): WHERE sem.formsemestre_id = i.formsemestre_id AND i.etudid=%(etudid)s AND (%(cur_date)s >= sem.date_debut) AND (%(cur_date)s <= sem.date_fin)""" - r = ndb.SimpleDictFetch(context, req, {"etudid": etudid, "cur_date": cur_date}) + r = ndb.SimpleDictFetch(req, {"etudid": etudid, "cur_date": cur_date}) if not r: return None # s'il y a plusieurs semestres, prend le premier (rarissime et non significatif): @@ -291,5 +288,5 @@ def mod_with_evals_at_date(context, date_abs, etudid): req = """SELECT m.* FROM notes_moduleimpl m, notes_evaluation e, notes_moduleimpl_inscription i WHERE m.moduleimpl_id = e.moduleimpl_id AND e.moduleimpl_id = i.moduleimpl_id AND i.etudid = %(etudid)s AND e.jour = %(date_abs)s""" - r = ndb.SimpleDictFetch(context, req, {"etudid": etudid, "date_abs": date_abs}) + r = ndb.SimpleDictFetch(req, {"etudid": etudid, "date_abs": date_abs}) return r diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 09ea59ea..7f75aa15 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -169,7 +169,7 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied disabled = False if not etud["cursem"]: require_module = sco_preferences.get_preference( - context, "abs_require_module" + "abs_require_module" ) # on utilise la pref globale car pas de sem courant if require_module: menu_module = """
    Pas inscrit dans un semestre courant, @@ -180,7 +180,7 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied else: formsemestre_id = etud["cursem"]["formsemestre_id"] require_module = sco_preferences.get_preference( - context, "abs_require_module", formsemestre_id + "abs_require_module", formsemestre_id ) nt = sco_cache.NotesTableCache.get(formsemestre_id) ues = nt.get_ues(etudid=etudid) @@ -839,9 +839,7 @@ def ListeAbsEtud( base_url=base_url_nj, filename="abs_" + scu.make_filename(etud["nomprenom"]), caption="Absences non justifiées de %(nomprenom)s" % etud, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) tab_absjust = GenTable( titles=titles, @@ -852,9 +850,7 @@ def ListeAbsEtud( base_url=base_url_j, filename="absjust_" + scu.make_filename(etud["nomprenom"]), caption="Absences justifiées de %(nomprenom)s" % etud, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) # Formats non HTML et demande d'une seule table: diff --git a/app/scodoc/sco_apogee_compare.py b/app/scodoc/sco_apogee_compare.py index 5079ed96..fa2df322 100644 --- a/app/scodoc/sco_apogee_compare.py +++ b/app/scodoc/sco_apogee_compare.py @@ -266,9 +266,7 @@ def apo_table_compare_etud_results(context, A, B, REQUEST=None): columns_ids=("nip", "nom", "prenom", "elt_code", "type_res", "val_A", "val_B"), html_class="table_leftalign", html_with_td_classes=True, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return T diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 26bb2f97..7755f35d 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -100,7 +100,7 @@ def make_context_dict(context, sem, etud): # copie preferences # XXX devrait acceder directement à un dict de preferences, à revoir for name in sco_preferences.get_base_preferences(context).prefs_name: - C[name] = sco_preferences.get_preference(context, name, sem["formsemestre_id"]) + C[name] = sco_preferences.get_preference(name, sem["formsemestre_id"]) # ajoute groupes et group_0, group_1, ... sco_groups.etud_add_group_infos(context, etud, sem) @@ -133,7 +133,7 @@ def formsemestre_bulletinetud_dict( if not version in scu.BULLETINS_VERSIONS: raise ValueError("invalid version code !") - prefs = sco_preferences.SemPreferences(context, formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id) nt = sco_cache.NotesTableCache.get(formsemestre_id) # > toutes notes I = scu.DictDefault(defaultvalue="") @@ -417,10 +417,10 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers Result: liste de modules de l'UE avec les infos dans chacun (seulement ceux où l'étudiant est inscrit). """ bul_show_mod_rangs = sco_preferences.get_preference( - context, "bul_show_mod_rangs", formsemestre_id + "bul_show_mod_rangs", formsemestre_id ) bul_show_abs_modules = sco_preferences.get_preference( - context, "bul_show_abs_modules", formsemestre_id + "bul_show_abs_modules", formsemestre_id ) if bul_show_abs_modules: sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) @@ -481,9 +481,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers '' % (modimpl["moduleimpl_id"], mod["mod_descr_txt"]) ) - if sco_preferences.get_preference( - context, "bul_show_codemodules", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id): mod["code"] = modimpl["module"]["code"] mod["code_html"] = link_mod + mod["code"] + "" else: @@ -502,9 +500,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers '' % (modimpl["moduleimpl_id"], mod_descr) ) - if sco_preferences.get_preference( - context, "bul_show_codemodules", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id): mod["code_txt"] = modimpl["module"]["code"] mod["code_html"] = link_mod + mod["code_txt"] + "" else: @@ -565,9 +561,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers # Evaluations incomplètes ou futures: mod["evaluations_incompletes"] = [] - if sco_preferences.get_preference( - context, "bul_show_all_evals", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_all_evals", formsemestre_id): complete_eval_ids = set([e["evaluation_id"] for e in evals]) all_evals = sco_evaluations.do_evaluation_list( context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} @@ -784,7 +778,7 @@ def formsemestre_bulletinetud( etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0] etudid = etud["etudid"] except: - return scu.log_unknown_etud(context, REQUEST, format=format) + return scu.log_unknown_etud(REQUEST, format=format) bulletin = do_formsemestre_bulletinetud( context, @@ -848,9 +842,7 @@ def can_send_bulletin_by_mail(context, formsemestre_id, REQUEST): authuser = REQUEST.AUTHENTICATED_USER sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) return ( - sco_preferences.get_preference( - context, "bul_mail_allowed_for_all", formsemestre_id - ) + sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id) or authuser.has_permission(Permission.ScoImplement) or str(authuser) in sem["responsables"] ) @@ -978,18 +970,12 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr If bul_mail_list_abs pref is true, put list of absences in mail body (text). """ etud = I["etud"] - webmaster = sco_preferences.get_preference( - context, "bul_mail_contact_addr", formsemestre_id - ) + webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id) dept = scu.unescape_html( - sco_preferences.get_preference(context, "DeptName", formsemestre_id) - ) - copy_addr = sco_preferences.get_preference( - context, "email_copy_bulletins", formsemestre_id - ) - intro_mail = sco_preferences.get_preference( - context, "bul_intro_mail", formsemestre_id + sco_preferences.get_preference("DeptName", formsemestre_id) ) + copy_addr = sco_preferences.get_preference("email_copy_bulletins", formsemestre_id) + intro_mail = sco_preferences.get_preference("bul_intro_mail", formsemestre_id) if intro_mail: hea = intro_mail % { @@ -1000,7 +986,7 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr else: hea = "" - if sco_preferences.get_preference(context, "bul_mail_list_abs"): + if sco_preferences.get_preference("bul_mail_list_abs"): hea += "\n\n" + sco_abs_views.ListeAbsEtud( context, etud["etudid"], with_evals=False, format="text" ) @@ -1009,9 +995,7 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr subj = Header("Relevé de notes de %s" % etud["nomprenom"], scu.SCO_ENCODING) recipients = [recipient_addr] msg["Subject"] = subj - msg["From"] = sco_preferences.get_preference( - context, "email_from_addr", formsemestre_id - ) + msg["From"] = sco_preferences.get_preference("email_from_addr", formsemestre_id) msg["To"] = " ,".join(recipients) if copy_addr: msg["Bcc"] = copy_addr.strip() diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 561a5e37..fd7780c7 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -89,9 +89,7 @@ def bulletin_get_class_name_displayed(context, formsemestre_id): """Le nom du générateur utilisé, en clair""" from app.scodoc import sco_preferences - bul_class_name = sco_preferences.get_preference( - context, "bul_class_name", formsemestre_id - ) + bul_class_name = sco_preferences.get_preference("bul_class_name", formsemestre_id) try: gen_class = bulletin_get_class(bul_class_name) return gen_class.description @@ -127,7 +125,7 @@ class BulletinGenerator(object): self.server_name = server_name # Store preferences for convenience: formsemestre_id = self.infos["formsemestre_id"] - self.preferences = sco_preferences.SemPreferences(context, formsemestre_id) + self.preferences = sco_preferences.SemPreferences(formsemestre_id) self.diagnostic = None # error message if any problem # Common PDF styles: # - Pour tous les champs du bulletin sauf les cellules de table: @@ -285,9 +283,7 @@ def make_formsemestre_bulletinetud( raise ValueError("invalid version code !") formsemestre_id = infos["formsemestre_id"] - bul_class_name = sco_preferences.get_preference( - context, "bul_class_name", formsemestre_id - ) + bul_class_name = sco_preferences.get_preference("bul_class_name", formsemestre_id) try: gen_class = bulletin_get_class(bul_class_name) except: diff --git a/app/scodoc/sco_bulletins_json.py b/app/scodoc/sco_bulletins_json.py index 7e0e18ff..f1626f18 100644 --- a/app/scodoc/sco_bulletins_json.py +++ b/app/scodoc/sco_bulletins_json.py @@ -158,8 +158,7 @@ def formsemestre_bulletinetud_published_dict( mg = scu.fmt_note(nt.get_etud_moy_gen(etudid)) if ( nt.get_moduleimpls_attente() - or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) - == 0 + or sco_preferences.get_preference("bul_show_rangs", formsemestre_id) == 0 ): # n'affiche pas le rang sur le bulletin s'il y a des # notes en attente dans ce semestre @@ -254,9 +253,7 @@ def formsemestre_bulletinetud_published_dict( m["note"][k] = scu.fmt_note(m["note"][k]) u["module"].append(m) - if sco_preferences.get_preference( - context, "bul_show_mod_rangs", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_mod_rangs", formsemestre_id): m["rang"] = dict( value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid] ) @@ -293,7 +290,7 @@ def formsemestre_bulletinetud_published_dict( # Evaluations incomplètes ou futures: complete_eval_ids = set([e["evaluation_id"] for e in evals]) if sco_preferences.get_preference( - context, "bul_show_all_evals", formsemestre_id + "bul_show_all_evals", formsemestre_id ): all_evals = sco_evaluations.do_evaluation_list( context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} @@ -338,13 +335,13 @@ def formsemestre_bulletinetud_published_dict( ) # --- Absences - if sco_preferences.get_preference(context, "bul_show_abs", formsemestre_id): + if sco_preferences.get_preference("bul_show_abs", formsemestre_id): nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem) d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust) # --- Decision Jury if ( - sco_preferences.get_preference(context, "bul_show_decision", formsemestre_id) + sco_preferences.get_preference("bul_show_decision", formsemestre_id) or xml_with_decisions ): infos, dpv = sco_bulletins.etud_descr_situation_semestre( @@ -353,7 +350,7 @@ def formsemestre_bulletinetud_published_dict( formsemestre_id, format="xml", show_uevalid=sco_preferences.get_preference( - context, "bul_show_uevalid", formsemestre_id + "bul_show_uevalid", formsemestre_id ), ) d["situation"] = scu.quote_xml_attr(infos["situation"]) @@ -377,7 +374,7 @@ def formsemestre_bulletinetud_published_dict( d["decision_ue"] = [] if decision[ "decisions_ue" - ]: # and sco_preferences.get_preference(context, 'bul_show_uevalid', formsemestre_id): always publish (car utile pour export Apogee) + ]: # and sco_preferences.get_preference( 'bul_show_uevalid', formsemestre_id): always publish (car utile pour export Apogee) for ue_id in decision["decisions_ue"].keys(): ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0] d["decision_ue"].append( diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index 96dafd25..318e479c 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -88,7 +88,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): context = self.context bul_show_abs_modules = sco_preferences.get_preference( - context, "bul_show_abs_modules", formsemestre_id + "bul_show_abs_modules", formsemestre_id ) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) @@ -103,7 +103,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): H = ['' % bgcolor] - if sco_preferences.get_preference(context, "bul_show_minmax", formsemestre_id): + if sco_preferences.get_preference("bul_show_minmax", formsemestre_id): minmax = ( '[%s, %s]' % (I["moy_min"], I["moy_max"]) @@ -129,7 +129,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): continue # saute les modules où on n'est pas inscrit H.append('' % rowstyle) if sco_preferences.get_preference( - context, "bul_show_minmax_mod", formsemestre_id + "bul_show_minmax_mod", formsemestre_id ): rang_minmax = '%s [%s, %s]' % ( mod["mod_rang_txt"], @@ -178,7 +178,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): plusminus = minuslink # if ue["ue_status"]["is_capitalized"]: if sco_preferences.get_preference( - context, "bul_show_ue_cap_details", formsemestre_id + "bul_show_ue_cap_details", formsemestre_id ): plusminus = minuslink hide = "" @@ -209,9 +209,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): ) H.append('') - if sco_preferences.get_preference( - context, "bul_show_minmax", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_minmax", formsemestre_id): moy_txt = ( '%s [%s, %s]' % ( @@ -448,10 +446,10 @@ def _bulletin_pdf_table_legacy(context, I, version="long"): P = [] # elems pour gen. pdf formsemestre_id = I["formsemestre_id"] bul_show_abs_modules = sco_preferences.get_preference( - context, "bul_show_abs_modules", formsemestre_id + "bul_show_abs_modules", formsemestre_id ) - if sco_preferences.get_preference(context, "bul_show_minmax", formsemestre_id): + if sco_preferences.get_preference("bul_show_minmax", formsemestre_id): minmax = ' [%s, %s]' % (I["moy_min"], I["moy_max"]) else: minmax = "" @@ -473,9 +471,7 @@ def _bulletin_pdf_table_legacy(context, I, version="long"): if mod["mod_moy_txt"] == "NI": continue # saute les modules où on n'est pas inscrit S.modline(ue_type=ue_type) - if sco_preferences.get_preference( - context, "bul_show_minmax_mod", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_minmax_mod", formsemestre_id): rang_minmax = '%s [%s, %s]' % ( mod["mod_rang_txt"], scu.fmt_note(mod["stats"]["min"]), @@ -516,12 +512,12 @@ def _bulletin_pdf_table_legacy(context, I, version="long"): ue_descr = "(en cours, non prise en compte)" S.ueline() if sco_preferences.get_preference( - context, "bul_show_ue_cap_details", formsemestre_id + "bul_show_ue_cap_details", formsemestre_id ): list_modules(ue["modules_capitalized"]) ue_type = "cur" - if sco_preferences.get_preference(context, "bul_show_minmax", formsemestre_id): + if sco_preferences.get_preference("bul_show_minmax", formsemestre_id): moy_txt = '%s [%s, %s]' % ( ue["cur_moy_ue_txt"], ue["min"], diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index 5e23a842..07e1a88c 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -86,10 +86,10 @@ def pdfassemblebulletins( return "" # Paramètres de mise en page margins = ( - sco_preferences.get_preference(context, "left_margin", formsemestre_id), - sco_preferences.get_preference(context, "top_margin", formsemestre_id), - sco_preferences.get_preference(context, "right_margin", formsemestre_id), - sco_preferences.get_preference(context, "bottom_margin", formsemestre_id), + sco_preferences.get_preference("left_margin", formsemestre_id), + sco_preferences.get_preference("top_margin", formsemestre_id), + sco_preferences.get_preference("right_margin", formsemestre_id), + sco_preferences.get_preference("bottom_margin", formsemestre_id), ) report = StringIO.StringIO() # in-memory document, no disk file @@ -105,7 +105,7 @@ def pdfassemblebulletins( margins=margins, pagesbookmarks=pagesbookmarks, filigranne=filigranne, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) ) document.build(objects) @@ -194,9 +194,7 @@ def get_formsemestre_bulletins_pdf( bookmarks[i] = scu.suppress_accents(nt.get_sexnom(etudid)) i = i + 1 # - infos = { - "DeptName": sco_preferences.get_preference(context, "DeptName", formsemestre_id) - } + infos = {"DeptName": sco_preferences.get_preference("DeptName", formsemestre_id)} if REQUEST: server_name = REQUEST.BASE0 else: @@ -248,7 +246,7 @@ def get_etud_bulletins_pdf(context, etudid, REQUEST, version="selectedevals"): filigrannes[i] = filigranne bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015 i = i + 1 - infos = {"DeptName": sco_preferences.get_preference(context, "DeptName")} + infos = {"DeptName": sco_preferences.get_preference("DeptName")} if REQUEST: server_name = REQUEST.BASE0 else: diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index 4e86c091..b30dc4c4 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -278,7 +278,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): context = self.context P = [] # elems pour générer table avec gen_table (liste de dicts) formsemestre_id = I["formsemestre_id"] - prefs = sco_preferences.SemPreferences(context, formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id) # Colonnes à afficher: with_col_abs = prefs["bul_show_abs_modules"] diff --git a/app/scodoc/sco_bulletins_ucac.py b/app/scodoc/sco_bulletins_ucac.py index a474592b..17ccf269 100644 --- a/app/scodoc/sco_bulletins_ucac.py +++ b/app/scodoc/sco_bulletins_ucac.py @@ -72,7 +72,7 @@ class BulletinGeneratorUCAC(sco_bulletins_standard.BulletinGeneratorStandard): I = self.infos context = self.context formsemestre_id = I["formsemestre_id"] - prefs = sco_preferences.SemPreferences(context, formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id) P = [] # elems pour générer table avec gen_table (liste de dicts) @@ -192,7 +192,7 @@ class BulletinGeneratorUCAC(sco_bulletins_standard.BulletinGeneratorStandard): # --- UE capitalisée: if ue["ue_status"]["is_capitalized"]: if sco_preferences.get_preference( - context, "bul_show_ue_cap_details", formsemestre_id + "bul_show_ue_cap_details", formsemestre_id ): nb_modules = len(ue["modules_capitalized"]) hidden = False diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 6bcd55e8..0440e287 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -151,8 +151,7 @@ def make_xml_formsemestre_bulletinetud( mg = scu.fmt_note(nt.get_etud_moy_gen(etudid)) if ( nt.get_moduleimpls_attente() - or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) - == 0 + or sco_preferences.get_preference("bul_show_rangs", formsemestre_id) == 0 ): # n'affiche pas le rang sur le bulletin s'il y a des # notes en attente dans ce semestre @@ -255,9 +254,7 @@ def make_xml_formsemestre_bulletinetud( moy=scu.fmt_note(modstat["moy"]), ) ) - if sco_preferences.get_preference( - context, "bul_show_mod_rangs", formsemestre_id - ): + if sco_preferences.get_preference("bul_show_mod_rangs", formsemestre_id): x_mod.append( Element( "rang", @@ -298,7 +295,7 @@ def make_xml_formsemestre_bulletinetud( # Evaluations incomplètes ou futures: complete_eval_ids = set([e["evaluation_id"] for e in evals]) if sco_preferences.get_preference( - context, "bul_show_all_evals", formsemestre_id + "bul_show_all_evals", formsemestre_id ): all_evals = sco_evaluations.do_evaluation_list( context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} @@ -349,12 +346,12 @@ def make_xml_formsemestre_bulletinetud( ) # --- Absences - if sco_preferences.get_preference(context, "bul_show_abs", formsemestre_id): + if sco_preferences.get_preference("bul_show_abs", formsemestre_id): nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem) doc.append(Element("absences", nbabs=nbabs, nbabsjust=nbabsjust)) # --- Decision Jury if ( - sco_preferences.get_preference(context, "bul_show_decision", formsemestre_id) + sco_preferences.get_preference("bul_show_decision", formsemestre_id) or xml_with_decisions ): infos, dpv = sco_bulletins.etud_descr_situation_semestre( @@ -363,7 +360,7 @@ def make_xml_formsemestre_bulletinetud( formsemestre_id, format="xml", show_uevalid=sco_preferences.get_preference( - context, "bul_show_uevalid", formsemestre_id + "bul_show_uevalid", formsemestre_id ), ) x_situation = Element("situation") @@ -395,7 +392,7 @@ def make_xml_formsemestre_bulletinetud( if decision[ "decisions_ue" - ]: # and sco_preferences.get_preference(context, 'bul_show_uevalid', formsemestre_id): always publish (car utile pour export Apogee) + ]: # and sco_preferences.get_preference( 'bul_show_uevalid', formsemestre_id): always publish (car utile pour export Apogee) for ue_id in decision["decisions_ue"].keys(): ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0] doc.append( diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index 07b8aabd..49ee2d95 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -132,8 +132,7 @@ class EvaluationCache(ScoDocCache): WHERE s.formsemestre_id = %(formsemestre_id)s and s.formsemestre_id=m.formsemestre_id and e.moduleimpl_id=m.moduleimpl_id; """ evaluation_ids = [ - x[0] - for x in ndb.SimpleQuery(None, req, {"formsemestre_id": formsemestre_id}) + x[0] for x in ndb.SimpleQuery(req, {"formsemestre_id": formsemestre_id}) ] cls.delete_many(evaluation_ids) @@ -142,9 +141,7 @@ class EvaluationCache(ScoDocCache): "delete all evaluations from cache" evaluation_ids = [ x[0] - for x in ndb.SimpleQuery( - None, "SELECT evaluation_id FROM notes_evaluation", "" - ) + for x in ndb.SimpleQuery("SELECT evaluation_id FROM notes_evaluation", "") ] cls.delete_many(evaluation_ids) @@ -224,7 +221,8 @@ class NotesTableCache(ScoDocCache): from app.scodoc import notes_table t0 = time.time() - nt = notes_table.NotesTable(None, formsemestre_id) + context = None # XXX TO REMOVE #context + nt = notes_table.NotesTable(context, formsemestre_id) dt = time.time() - t0 log("caching formsemestre_id=%s (%gs)" % (formsemestre_id, dt)) _ = cls.set(formsemestre_id, nt) @@ -247,7 +245,7 @@ def invalidate_formsemestre( # was inval_cache( context, formsemestre_id=None, formsemestre_ids = [ x[0] for x in ndb.SimpleQuery( - None, "SELECT formsemestre_id FROM notes_formsemestre", "" + "SELECT formsemestre_id FROM notes_formsemestre", "" ) ] else: diff --git a/app/scodoc/sco_cost_formation.py b/app/scodoc/sco_cost_formation.py index eef25381..800b614b 100644 --- a/app/scodoc/sco_cost_formation.py +++ b/app/scodoc/sco_cost_formation.py @@ -121,7 +121,7 @@ def formsemestre_table_estim_cost( ), rows=T, html_sortable=True, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), html_class="table_leftalign table_listegroupe", xls_before_table=[ ["%(titre)s %(num_sem)s %(modalitestr)s" % sem], diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py index 7a1b99a9..3d1a61c4 100644 --- a/app/scodoc/sco_debouche.py +++ b/app/scodoc/sco_debouche.py @@ -82,7 +82,7 @@ def get_etudids_with_debouche(context, start_year): start_date = str(start_year) + "-01-01" # Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre # posterieur à la date de depart: - # r = ndb.SimpleDictFetch(context, + # r = ndb.SimpleDictFetch( # """SELECT DISTINCT i.etudid # FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s # WHERE adm.debouche is not NULL @@ -92,7 +92,6 @@ def get_etudids_with_debouche(context, start_year): # {'start_date' : start_date }) r = ndb.SimpleDictFetch( - context, """SELECT DISTINCT i.etudid FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it WHERE i.etudid = it.etudid @@ -189,9 +188,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True): # html_col_width='4em', html_sortable=True, html_class="table_leftalign table_listegroupe", - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab @@ -338,7 +335,6 @@ def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None): def itemsuivi_tag_list(context, itemsuivi_id): """les noms de tags associés à cet item""" r = ndb.SimpleDictFetch( - context, """SELECT t.title FROM itemsuivi_tags_assoc a, itemsuivi_tags t WHERE a.tag_id = t.tag_id @@ -356,7 +352,6 @@ def itemsuivi_tag_search(context, term, REQUEST=None): data = [] else: r = ndb.SimpleDictFetch( - context, "SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s", {"term": term + "%"}, ) diff --git a/app/scodoc/sco_dept.py b/app/scodoc/sco_dept.py index 6d5471f2..d2451c01 100644 --- a/app/scodoc/sco_dept.py +++ b/app/scodoc/sco_dept.py @@ -125,7 +125,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0): """

    Semestres de %s

    """ - % sco_preferences.get_preference(context, "DeptName") + % sco_preferences.get_preference("DeptName") ) H.append(_sem_table_gt(context, sems).html()) H.append("
    ") @@ -250,9 +250,7 @@ def _sem_table_gt(context, sems, showcodes=False): html_sortable=True, # base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id), # caption='Maquettes enregistrées', - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab diff --git a/app/scodoc/sco_dump_db.py b/app/scodoc/sco_dump_db.py index 78481968..e9ccb338 100644 --- a/app/scodoc/sco_dump_db.py +++ b/app/scodoc/sco_dump_db.py @@ -70,7 +70,7 @@ def sco_dump_and_send_db(context, REQUEST=None): html_sco_header.sco_header(context, REQUEST, page_title="Assistance technique") ] # get currect (dept) DB name: - cursor = ndb.SimpleQuery(context, "SELECT current_database()", {}) + cursor = ndb.SimpleQuery("SELECT current_database()", {}) db_name = cursor.fetchone()[0] ano_db_name = "ANO" + db_name # Lock @@ -190,7 +190,7 @@ def _send_db(context, REQUEST, ano_db_name): scu.SCO_DUMP_UP_URL, files=files, data={ - "dept_name": sco_preferences.get_preference(context, "DeptName"), + "dept_name": sco_preferences.get_preference("DeptName"), "serial": _get_scodoc_serial(context), "sco_user": str(REQUEST.AUTHENTICATED_USER), "sent_by": sco_users.user_info(str(REQUEST.AUTHENTICATED_USER))[ diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index e909dafa..0ab757fd 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -314,7 +314,6 @@ associé. if tf[2]["ue_id"] != F["ue_id"]: log("attaching mat %s to new UE %s" % (matiere_id, tf[2]["ue_id"])) ndb.SimpleQuery( - context, "UPDATE notes_modules SET ue_id = %(ue_id)s WHERE matiere_id=%(matiere_id)s", {"ue_id": tf[2]["ue_id"], "matiere_id": matiere_id}, ) @@ -329,7 +328,6 @@ def matiere_is_locked(context, matiere_id): (contains modules used in a locked formsemestre) """ r = ndb.SimpleDictFetch( - context, """SELECT ma.* from notes_matieres ma, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi WHERE ma.matiere_id = mod.matiere_id AND mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id AND ma.matiere_id = %(matiere_id)s AND sem.etat = 0 diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 5510567c..1582cb5c 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -359,7 +359,6 @@ def module_edit(context, module_id=None, REQUEST=None): )[0] parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"]) M = ndb.SimpleDictFetch( - context, "SELECT ue.acronyme, mat.* FROM notes_matieres mat, notes_ue ue WHERE mat.ue_id = ue.ue_id AND ue.formation_id = %(formation_id)s ORDER BY ue.numero, mat.numero", {"formation_id": Mod["formation_id"]}, ) @@ -571,7 +570,6 @@ def module_is_locked(context, module_id): (used in a locked formsemestre) """ r = ndb.SimpleDictFetch( - context, """SELECT mi.* from notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi WHERE mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id AND mi.module_id = %(module_id)s AND sem.etat = 0 diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index cd3a2e7f..86c9ec14 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -144,7 +144,6 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F if delete_validations: log("deleting all validations of UE %s" % ue_id) ndb.SimpleQuery( - context, "DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}, ) @@ -155,13 +154,10 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"], REQUEST) # delete uecoef and events ndb.SimpleQuery( - context, "DELETE FROM notes_formsemestre_uecoef WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}, ) - ndb.SimpleQuery( - context, "DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id} - ) + ndb.SimpleQuery("DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}) cnx = ndb.GetDBConnexion() _ueEditor.delete(cnx, ue_id) # > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?): @@ -949,7 +945,6 @@ def ue_is_locked(context, ue_id): (contains modules used in a locked formsemestre) """ r = ndb.SimpleDictFetch( - context, """SELECT ue.* FROM notes_ue ue, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi WHERE ue.ue_id = mod.ue_id AND mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id @@ -1042,9 +1037,7 @@ def formation_table_recap(context, formation_id, format="html", REQUEST=None): page_title=title, html_title="

    " + title + "

    ", pdf_title=title, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab.make_page(context, format=format, REQUEST=REQUEST) diff --git a/app/scodoc/sco_edt_cal.py b/app/scodoc/sco_edt_cal.py index 08658b5f..28d802f9 100644 --- a/app/scodoc/sco_edt_cal.py +++ b/app/scodoc/sco_edt_cal.py @@ -55,7 +55,7 @@ def formsemestre_get_ics_url(context, sem): https://example.fr/agenda/{sem[etapes][0]} """ ics_url_tmpl = sco_preferences.get_preference( - context, "edt_sem_ics_url", sem["formsemestre_id"] + "edt_sem_ics_url", sem["formsemestre_id"] ) if not ics_url_tmpl: return None @@ -102,7 +102,7 @@ def get_edt_transcodage_groups(context, formsemestre_id): edt2sco = {} sco2edt = {} msg = "" # message erreur, '' si ok - txt = sco_preferences.get_preference(context, "edt_groups2scodoc", formsemestre_id) + txt = sco_preferences.get_preference("edt_groups2scodoc", formsemestre_id) if not txt: return edt2sco, sco2edt, msg diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py index 06ed2fc0..0d105a56 100644 --- a/app/scodoc/sco_etape_apogee_view.py +++ b/app/scodoc/sco_etape_apogee_view.py @@ -82,9 +82,7 @@ def apo_semset_maq_status( block_export_res_modules = int(block_export_res_modules) block_export_res_sdj = int(block_export_res_sdj) - prefs = sco_preferences.SemPreferences( - context, - ) + prefs = sco_preferences.SemPreferences() tab_archives = table_apo_csv_list(context, semset, REQUEST=REQUEST) @@ -486,9 +484,7 @@ def table_apo_csv_list(context, semset, REQUEST=None): html_sortable=True, # base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id), # caption='Maquettes enregistrées', - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab @@ -597,9 +593,7 @@ def _view_etuds_page( html_sortable=True, html_class="table_leftalign", filename="students_apo", - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) if format != "html": return tab.make_page(context, format=format, REQUEST=REQUEST) @@ -785,9 +779,7 @@ def view_apo_csv(context, etape_apo="", semset_id="", format="html", REQUEST=Non base_url="%s?etape_apo=%s&semset_id=%s" % (REQUEST.URL0, etape_apo, semset_id), filename="students_" + etape_apo, caption="Etudiants Apogée en " + etape_apo, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) if format != "html": @@ -823,9 +815,7 @@ def apo_csv_export_results( # nota: on peut éventuellement exporter même si tout n'est pas ok # mais le lien via le tableau de bord n'est pas actif # Les fichiers résultats ne sont pas stockés: pas besoin de permission particulière - prefs = sco_preferences.SemPreferences( - context, - ) + prefs = sco_preferences.SemPreferences() export_res_etape = prefs["export_res_etape"] and not int(block_export_res_etape) export_res_sem = prefs["export_res_sem"] and not int(block_export_res_sem) export_res_ues = prefs["export_res_ues"] and not int(block_export_res_ues) @@ -866,7 +856,7 @@ def apo_csv_export_results( ) basename = ( - sco_preferences.get_preference(context, "DeptName") + sco_preferences.get_preference("DeptName") + str(annee_scolaire) + "-%s-" % periode + "-".join(etapes_apo) diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index cc17bb77..3cad157b 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -377,9 +377,7 @@ def identite_edit(cnx, args, context=None, REQUEST=None): notify_to = None if context: try: - notify_to = sco_preferences.get_preference( - context, "notify_etud_changes_to" - ) + notify_to = sco_preferences.get_preference("notify_etud_changes_to") except: pass @@ -446,7 +444,7 @@ def notify_etud_change(context, email_addr, etud, before, after, subject): msg = MIMEMultipart() subj = Header("[ScoDoc] " + subject, SCO_ENCODING) msg["Subject"] = subj - msg["From"] = sco_preferences.get_preference(context, "email_from_addr") + msg["From"] = sco_preferences.get_preference("email_from_addr") msg["To"] = email_addr mime_txt = MIMEText(txt, "plain", SCO_ENCODING) msg.attach(mime_txt) @@ -492,9 +490,7 @@ def adresse_edit(cnx, args, context=None): notify_to = None if context: try: - notify_to = sco_preferences.get_preference( - context, "notify_etud_changes_to" - ) + notify_to = sco_preferences.get_preference("notify_etud_changes_to") except: pass if notify_to: diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index eba208b8..9e78486e 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -930,7 +930,7 @@ def formsemestre_evaluations_delai_correction( html_sortable=True, html_title="

    Correction des évaluations du semestre

    ", caption="Correction des évaluations du semestre", - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id), origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "", filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]), diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 50925516..1b0ea311 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -571,7 +571,7 @@ def Excel_feuille_listeappel( ( "%s %s (%s - %s)" % ( - sco_preferences.get_preference(context, "DeptName", formsemestre_id), + sco_preferences.get_preference("DeptName", formsemestre_id), notesdb.unquote(sem["titre_num"]), sem["date_debut"], sem["date_fin"], diff --git a/app/scodoc/sco_export_results.py b/app/scodoc/sco_export_results.py index dac44bf4..ba0b9257 100644 --- a/app/scodoc/sco_export_results.py +++ b/app/scodoc/sco_export_results.py @@ -102,9 +102,7 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "", html_class="table_leftalign", html_sortable=True, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab, semlist @@ -207,7 +205,6 @@ def _build_results_list(context, dpv_by_sem, etuds_infos): def get_set_formsemestre_id_dates(context, start_date, end_date): """Ensemble des formsemestre_id entre ces dates""" s = ndb.SimpleDictFetch( - context, "SELECT formsemestre_id FROM notes_formsemestre WHERE date_debut >= %(start_date)s AND date_fin <= %(end_date)s", {"start_date": start_date, "end_date": end_date}, ) diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index 69bde973..c9952b0e 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -166,9 +166,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None): rows=etuds, html_sortable=True, html_class="table_leftalign", - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) H.append(tab.html()) if len(etuds) > 20: # si la page est grande @@ -224,7 +222,6 @@ def search_etud_by_name(context, term, REQUEST=None): else: if may_be_nip: r = ndb.SimpleDictFetch( - context, "SELECT nom, prenom, code_nip FROM identite WHERE code_nip LIKE %(beginning)s ORDER BY nom", {"beginning": term + "%"}, ) @@ -238,7 +235,6 @@ def search_etud_by_name(context, term, REQUEST=None): ] else: r = ndb.SimpleDictFetch( - context, "SELECT etudid, nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom", {"beginning": term + "%"}, ) @@ -257,20 +253,6 @@ def search_etud_by_name(context, term, REQUEST=None): # ---------- Recherche sur plusieurs département -def form_search_etud_in_accessible_depts(context, REQUEST): - """Form recherche etudiants pour page accueil ScoDoc""" - authuser = REQUEST.AUTHENTICATED_USER - # present form only to authenticated users - if not authuser.has_role("Authenticated"): - return "" - return """
    - Chercher étudiant: - - -
    (entrer une partie du nom ou le code NIP, cherche dans tous les départements autorisés) - """ - - def search_etud_in_accessible_depts(expnom=None, code_nip=None): """ result is a list of (sorted) etuds, one list per dept. @@ -351,9 +333,7 @@ def search_inscr_etud_by_nip(context, code_nip, REQUEST=None, format="json"): Renvoie une liste des inscriptions de l'étudiants dans tout ScoDoc: code_nip, nom, prenom, civilite_str, dept, formsemestre_id, date_debut_sem, date_fin_sem """ - result, _ = search_etud_in_accessible_depts( - context, code_nip=code_nip, REQUEST=REQUEST - ) + result, _ = search_etud_in_accessible_depts(code_nip=code_nip) T = [] for etuds in result: diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index b41c481c..14ccb14c 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -334,9 +334,7 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None): base_url="%s?formation_id=%s" % (REQUEST.URL0, formation_id), page_title=title, pdf_title=title, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index de86cf77..79f0e45a 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -277,7 +277,6 @@ def read_formsemestre_responsables(context, formsemestre_id): :returns: liste de chaines """ r = ndb.SimpleDictFetch( - context, "SELECT responsable_id FROM notes_formsemestre_responsables WHERE formsemestre_id = %(formsemestre_id)s", {"formsemestre_id": formsemestre_id}, ) @@ -340,7 +339,6 @@ def read_formsemestre_etapes(context, formsemestre_id): :returns: liste d'instance de ApoEtapeVDI """ r = ndb.SimpleDictFetch( - context, "SELECT etape_apo FROM notes_formsemestre_etapes WHERE formsemestre_id = %(formsemestre_id)s", {"formsemestre_id": formsemestre_id}, ) @@ -518,13 +516,9 @@ def table_formsemestres( "etapes_apo_str": "Apo.", } if sems: - preferences = sco_preferences.SemPreferences( - context, sems[0]["formsemestre_id"] - ) + preferences = sco_preferences.SemPreferences(sems[0]["formsemestre_id"]) else: - preferences = sco_preferences.SemPreferences( - context, - ) + preferences = sco_preferences.SemPreferences() tab = GenTable( columns_ids=columns_ids, rows=sems, diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 8e190da2..4d6c32fa 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -412,7 +412,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): "title": "Element(s) Apogée:", "explanation": "du semestre (ex: VRTW1). Séparés par des virgules.", "allow_null": not sco_preferences.get_preference( - context, "always_require_apo_sem_codes" + "always_require_apo_sem_codes" ), }, ) @@ -425,7 +425,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): "title": "Element(s) Apogée:", "explanation": "de l'année (ex: VRT1A). Séparés par des virgules.", "allow_null": not sco_preferences.get_preference( - context, "always_require_apo_sem_codes" + "always_require_apo_sem_codes" ), }, ) @@ -676,9 +676,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): # check dates if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]): msg = '
    • Dates de début et fin incompatibles !
    ' - if sco_preferences.get_preference( - context, "always_require_apo_sem_codes" - ) and not any( + if sco_preferences.get_preference("always_require_apo_sem_codes") and not any( [tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)] ): msg = '
    • Code étape Apogée manquant
    ' @@ -1085,7 +1083,7 @@ def do_formsemestre_clone( # NB: don't copy notes_formsemestre_custommenu (usually specific) # 4- Copy new style preferences - prefs = sco_preferences.SemPreferences(context, orig_formsemestre_id) + prefs = sco_preferences.SemPreferences(orig_formsemestre_id) if orig_formsemestre_id in prefs.base_prefs.prefs: for pname in prefs.base_prefs.prefs[orig_formsemestre_id]: @@ -1361,7 +1359,6 @@ def formsemestre_has_decisions_or_compensations(context, formsemestre_id): ou bien compensation de ce semestre par d'autre ssemestres. """ r = ndb.SimpleDictFetch( - context, "SELECT v.* FROM scolar_formsemestre_validation v WHERE v.formsemestre_id = %(formsemestre_id)s OR v.compense_formsemestre_id = %(formsemestre_id)s", {"formsemestre_id": formsemestre_id}, ) @@ -1386,17 +1383,14 @@ def do_formsemestre_delete(context, formsemestre_id, REQUEST): ) for e in evals: ndb.SimpleQuery( - context, "DELETE FROM notes_notes WHERE evaluation_id=%(evaluation_id)s", e, ) ndb.SimpleQuery( - context, "DELETE FROM notes_notes_log WHERE evaluation_id=%(evaluation_id)s", e, ) ndb.SimpleQuery( - context, "DELETE FROM notes_evaluation WHERE evaluation_id=%(evaluation_id)s", e, ) @@ -1468,7 +1462,7 @@ def formsemestre_edit_options(context, formsemestre_id, target_url=None, REQUEST ) if not ok: return err - return sco_preferences.SemPreferences(context, formsemestre_id).edit( + return sco_preferences.SemPreferences(formsemestre_id).edit( REQUEST=REQUEST, categories=["bul"] ) @@ -1741,10 +1735,10 @@ def get_formsemestre_session_id(context, sem, F, parcours): # parcours = sco_codes_parcours.get_parcours_from_code(F['type_parcours']) ImputationDept = sco_preferences.get_preference( - context, "ImputationDept", sem["formsemestre_id"] + "ImputationDept", sem["formsemestre_id"] ) if not ImputationDept: - ImputationDept = sco_preferences.get_preference(context, "DeptName") + ImputationDept = sco_preferences.get_preference("DeptName") ImputationDept = ImputationDept.upper() parcours_type = parcours.NAME modalite = sem["modalite"] diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 84c24b8e..a6dbee16 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -286,7 +286,7 @@ def formsemestre_status_menubar(context, sem, REQUEST): "endpoint": "notes.formsemestre_synchro_etuds", "args": {"formsemestre_id": formsemestre_id}, "enabled": authuser.has_permission(Permission.ScoView) - and sco_preferences.get_preference(context, "portal_url") + and sco_preferences.get_preference("portal_url") and (sem["etat"] == "1"), }, { @@ -314,7 +314,7 @@ def formsemestre_status_menubar(context, sem, REQUEST): "endpoint": "scolar.formsemestre_import_etud_admission", "args": {"formsemestre_id": formsemestre_id}, "enabled": authuser.has_permission(Permission.ScoEtudChangeAdr) - and sco_preferences.get_preference(context, "portal_url"), + and sco_preferences.get_preference("portal_url"), }, { "title": "Exporter table des étudiants", @@ -564,9 +564,7 @@ def fill_formsemestre(context, sem, REQUEST=None): ) else: sem["locklink"] = "" - if sco_preferences.get_preference( - context, "bul_display_publication", formsemestre_id - ): + if sco_preferences.get_preference("bul_display_publication", formsemestre_id): if sem["bul_hide_xml"] != "0": eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés") else: @@ -615,9 +613,7 @@ def formsemestre_description_table( """ sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations - use_ue_coefs = sco_preferences.get_preference( - context, "use_ue_coefs", formsemestre_id - ) + use_ue_coefs = sco_preferences.get_preference("use_ue_coefs", formsemestre_id) F = sco_formations.formation_list( context, args={"formation_id": sem["formation_id"]} )[0] @@ -702,7 +698,7 @@ def formsemestre_description_table( sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef} R.append(sums) columns_ids = ["UE", "Code", "Module", "Coef."] - if sco_preferences.get_preference(context, "bul_show_ects", formsemestre_id): + if sco_preferences.get_preference("bul_show_ects", formsemestre_id): columns_ids += ["ects"] columns_ids += ["Inscrits", "Responsable", "Enseignants"] if with_evals: @@ -739,7 +735,7 @@ def formsemestre_description_table( context, REQUEST, "Description du semestre", sem, with_page_header=False ), pdf_title=title, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) @@ -1001,7 +997,7 @@ Il y a des notes en attente ! Le classement des étudiants n'a qu'une valeur ind H.append( '

    Attention: ce semestre couvre plusieurs années scolaires !

    ' ) - # elif sco_preferences.get_preference(context, 'bul_display_publication', formsemestre_id): + # elif sco_preferences.get_preference( 'bul_display_publication', formsemestre_id): # H.append('

    Bulletins publiés sur le portail

    ') return "".join(H) @@ -1081,7 +1077,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None): prev_ue_id = ue["ue_id"] acronyme = ue["acronyme"] titre = ue["titre"] - if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id): + if sco_preferences.get_preference("use_ue_coefs", formsemestre_id): titre += " (coef. %s)" % (ue["coefficient"] or 0.0) H.append( """ @@ -1192,7 +1188,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None): H.append("") H.append("

    ") - if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id): + if sco_preferences.get_preference("use_ue_coefs", formsemestre_id): H.append( """

    utilise les coefficients d'UE pour calculer la moyenne générale.

    diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py index cf1d87c2..924071dd 100644 --- a/app/scodoc/sco_formsemestre_validation.py +++ b/app/scodoc/sco_formsemestre_validation.py @@ -664,9 +664,7 @@ def formsemestre_recap_parcours_table( H.append("") # 3eme ligne: ECTS if ( - sco_preferences.get_preference( - context, "bul_show_ects", sem["formsemestre_id"] - ) + sco_preferences.get_preference("bul_show_ects", sem["formsemestre_id"]) or nt.parcours.ECTS_ONLY ): etud_moy_infos = nt.get_etud_moy_infos(etudid) @@ -1172,7 +1170,6 @@ def do_formsemestre_validate_previous_ue( def _invalidate_etud_formation_caches(context, etudid, formation_id): "Invalide tous les semestres de cette formation où l'etudiant est inscrit..." r = ndb.SimpleDictFetch( - context, """SELECT sem.* FROM notes_formsemestre sem, notes_formsemestre_inscription i WHERE sem.formation_id = %(formation_id)s @@ -1190,7 +1187,6 @@ def _invalidate_etud_formation_caches(context, etudid, formation_id): def get_etud_ue_cap_html(context, etudid, formsemestre_id, ue_id, REQUEST=None): """Ramene bout de HTML pour pouvoir supprimer une validation de cette UE""" valids = ndb.SimpleDictFetch( - context, """SELECT SFV.* FROM scolar_formsemestre_validation SFV WHERE ue_id=%(ue_id)s AND etudid=%(etudid)s""", {"etudid": etudid, "ue_id": ue_id}, @@ -1253,7 +1249,6 @@ def check_formation_ues(context, formation_id): for ue in ues: # formsemestres utilisant cette ue ? sems = ndb.SimpleDictFetch( - context, """SELECT DISTINCT sem.* FROM notes_formsemestre sem, notes_modules mod, notes_moduleimpl mi WHERE sem.formation_id = %(formation_id)s diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 9675307f..4ed4f3da 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -95,7 +95,6 @@ group_list = groupEditor.list def get_group(context, group_id): """Returns group object, with partition""" r = ndb.SimpleDictFetch( - context, "SELECT gd.*, p.* FROM group_descr gd, partition p WHERE gd.group_id=%(group_id)s AND p.partition_id = gd.partition_id", {"group_id": group_id}, ) @@ -109,18 +108,13 @@ def group_delete(context, group, force=False): # if not group['group_name'] and not force: # raise ValueError('cannot suppress this group') # remove memberships: - ndb.SimpleQuery( - context, "DELETE FROM group_membership WHERE group_id=%(group_id)s", group - ) + ndb.SimpleQuery("DELETE FROM group_membership WHERE group_id=%(group_id)s", group) # delete group: - ndb.SimpleQuery( - context, "DELETE FROM group_descr WHERE group_id=%(group_id)s", group - ) + ndb.SimpleQuery("DELETE FROM group_descr WHERE group_id=%(group_id)s", group) def get_partition(context, partition_id): r = ndb.SimpleDictFetch( - context, "SELECT p.* FROM partition p WHERE p.partition_id = %(partition_id)s", {"partition_id": partition_id}, ) @@ -132,7 +126,6 @@ def get_partition(context, partition_id): def get_partitions_list(context, formsemestre_id, with_default=True): """Liste des partitions pour ce semestre (list of dicts)""" partitions = ndb.SimpleDictFetch( - context, "SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s order by numero", {"formsemestre_id": formsemestre_id}, ) @@ -146,7 +139,6 @@ def get_partitions_list(context, formsemestre_id, with_default=True): def get_default_partition(context, formsemestre_id): """Get partition for 'all' students (this one always exists, with NULL name)""" r = ndb.SimpleDictFetch( - context, "SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s AND partition_name is NULL", {"formsemestre_id": formsemestre_id}, ) @@ -174,7 +166,6 @@ def get_partition_groups(context, partition): """List of groups in this partition (list of dicts). Some groups may be empty.""" return ndb.SimpleDictFetch( - context, "SELECT gd.*, p.* FROM group_descr gd, partition p WHERE gd.partition_id=%(partition_id)s AND gd.partition_id=p.partition_id ORDER BY group_name", partition, ) @@ -183,7 +174,6 @@ def get_partition_groups(context, partition): def get_default_group(context, formsemestre_id, fix_if_missing=False, REQUEST=None): """Returns group_id for default ('tous') group""" r = ndb.SimpleDictFetch( - context, "SELECT gd.group_id FROM group_descr gd, partition p WHERE p.formsemestre_id=%(formsemestre_id)s AND p.partition_name is NULL AND p.partition_id = gd.partition_id", {"formsemestre_id": formsemestre_id}, ) @@ -215,7 +205,6 @@ def get_default_group(context, formsemestre_id, fix_if_missing=False, REQUEST=No def get_sem_groups(context, formsemestre_id): """Returns groups for this sem (in all partitions).""" return ndb.SimpleDictFetch( - context, "SELECT gd.*, p.* FROM group_descr gd, partition p WHERE p.formsemestre_id=%(formsemestre_id)s AND p.partition_id = gd.partition_id", {"formsemestre_id": formsemestre_id}, ) @@ -230,7 +219,7 @@ def get_group_members(context, group_id, etat=None): if etat is not None: req += " and ins.etat = %(etat)s" - r = ndb.SimpleDictFetch(context, req, {"group_id": group_id, "etat": etat}) + r = ndb.SimpleDictFetch(req, {"group_id": group_id, "etat": etat}) for etud in r: sco_etud.format_etud_ident(etud) @@ -329,7 +318,6 @@ def get_etud_groups(context, etudid, sem, exclude_default=False): if exclude_default: req += " and p.partition_name is not NULL" groups = ndb.SimpleDictFetch( - context, req + " ORDER BY p.numero", {"etudid": etudid, "formsemestre_id": sem["formsemestre_id"]}, ) @@ -357,7 +345,6 @@ def formsemestre_get_etud_groupnames(context, formsemestre_id, attr="group_name" { etudid : { partition_id : group_name }} (attr=group_name or group_id) """ infos = ndb.SimpleDictFetch( - context, "select i.etudid, p.partition_id, gd.group_name, gd.group_id from notes_formsemestre_inscription i, partition p, group_descr gd, group_membership gm where i.formsemestre_id=%(formsemestre_id)s and i.formsemestre_id=p.formsemestre_id and p.partition_id=gd.partition_id and gm.etudid=i.etudid and gm.group_id = gd.group_id and p.partition_name is not NULL", {"formsemestre_id": formsemestre_id}, ) @@ -380,7 +367,6 @@ def etud_add_group_infos(context, etud, sem, sep=" "): return etud infos = ndb.SimpleDictFetch( - context, "SELECT p.partition_name, g.* from group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s and gm.group_id = g.group_id and g.partition_id = p.partition_id and p.formsemestre_id = %(formsemestre_id)s ORDER BY p.numero", {"etudid": etud["etudid"], "formsemestre_id": sem["formsemestre_id"]}, ) @@ -407,7 +393,6 @@ def etud_add_group_infos(context, etud, sem, sep=" "): def get_etud_groups_in_partition(context, partition_id): """Returns { etudid : group }, with all students in this partition""" infos = ndb.SimpleDictFetch( - context, "SELECT gd.*, etudid from group_descr gd, group_membership gm where gd.partition_id = %(partition_id)s and gm.group_id = gd.group_id", {"partition_id": partition_id}, ) @@ -535,7 +520,6 @@ def set_group(context, etudid, group_id): args = {"etudid": etudid, "group_id": group_id} # déjà inscrit ? r = ndb.SimpleDictFetch( - context, "SELECT * FROM group_membership gm WHERE etudid=%(etudid)s and group_id=%(group_id)s", args, cursor=cursor, @@ -544,7 +528,6 @@ def set_group(context, etudid, group_id): return False # inscrit ndb.SimpleQuery( - context, "INSERT INTO group_membership (etudid, group_id) VALUES (%(etudid)s, %(group_id)s)", args, cursor=cursor, @@ -571,7 +554,6 @@ def change_etud_group_in_partition( partition = get_partition(context, group["partition_id"]) # 1- Supprime membership dans cette partition ndb.SimpleQuery( - context, """DELETE FROM group_membership WHERE group_membership_id IN (SELECT gm.group_membership_id FROM group_membership gm, group_descr gd @@ -660,7 +642,6 @@ def setGroups( for etudid in old_members_set: log("removing %s from group %s" % (etudid, group_id)) ndb.SimpleQuery( - context, "DELETE FROM group_membership WHERE etudid=%(etudid)s and group_id=%(group_id)s", {"etudid": etudid, "group_id": group_id}, cursor=cursor, @@ -1097,7 +1078,6 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi # check unicity r = ndb.SimpleDictFetch( - context, "SELECT p.* FROM partition p WHERE p.partition_name = %(partition_name)s AND formsemestre_id = %(formsemestre_id)s", {"partition_name": partition_name, "formsemestre_id": formsemestre_id}, ) diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 96136495..c2a6dacd 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -589,7 +589,7 @@ def groups_table( else: filename = "etudiants_%s" % groups_infos.groups_filename - prefs = sco_preferences.SemPreferences(context, groups_infos.formsemestre_id) + prefs = sco_preferences.SemPreferences(groups_infos.formsemestre_id) tab = GenTable( rows=groups_infos.members, columns_ids=columns_ids, @@ -995,7 +995,7 @@ def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None): elts.append(group_name) T.append({"email": etud["email"], "semestre_groupe": "-".join(elts)}) # Make table - prefs = sco_preferences.SemPreferences(context, formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id) tab = GenTable( rows=T, columns_ids=("email", "semestre_groupe"), diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py index 026bf691..0dea0162 100644 --- a/app/scodoc/sco_import_etuds.py +++ b/app/scodoc/sco_import_etuds.py @@ -269,7 +269,7 @@ def scolars_import_excel_file( 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") + always_require_ine = sco_preferences.get_preference("always_require_ine") exceldata = datafile.read() if not exceldata: raise ScoValueError("Ficher excel vide ou invalide") @@ -822,8 +822,6 @@ def adm_table_description_format(context): rows=list(Fmt.values()), html_sortable=True, html_class="table_leftalign", - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab diff --git a/app/scodoc/sco_import_users.py b/app/scodoc/sco_import_users.py index f99d7c14..100cdb50 100644 --- a/app/scodoc/sco_import_users.py +++ b/app/scodoc/sco_import_users.py @@ -225,7 +225,7 @@ Pour plus d'informations sur ce logiciel, voir %s msg["Subject"] = Header("Mot de passe ScoDoc", scu.SCO_ENCODING) else: msg["Subject"] = Header("Votre accès ScoDoc", scu.SCO_ENCODING) - msg["From"] = sco_preferences.get_preference(context, "email_from_addr") + msg["From"] = sco_preferences.get_preference("email_from_addr") msg["To"] = u["email"] msg.epilogue = "" txt = MIMEText(txt, "plain", scu.SCO_ENCODING) diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 8dcfabaa..9582fb72 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -643,8 +643,6 @@ def etuds_select_box_xls(context, src_cat): columns_ids=columns_ids, rows=etuds, caption="%(title)s. %(help)s" % src_cat["infos"], - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab.excel() diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index f32bb6bb..48928d8e 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -314,9 +314,9 @@ def _make_table_notes( grc = inscr["etat"] code = "" # code pour listings anonyme, à la place du nom - if sco_preferences.get_preference(context, "anonymous_lst_code") == "INE": + if sco_preferences.get_preference("anonymous_lst_code") == "INE": code = etud["code_ine"] - elif sco_preferences.get_preference(context, "anonymous_lst_code") == "NIP": + elif sco_preferences.get_preference("anonymous_lst_code") == "NIP": code = etud["code_nip"] if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid code = etudid @@ -485,7 +485,7 @@ def _make_table_notes( html_title=html_title, pdf_title=pdf_title, html_class="table_leftalign notes_evaluation", - preferences=sco_preferences.SemPreferences(context, M["formsemestre_id"]), + preferences=sco_preferences.SemPreferences(M["formsemestre_id"]), # html_generate_cells=False # la derniere ligne (moyennes) est incomplete ) diff --git a/app/scodoc/sco_lycee.py b/app/scodoc/sco_lycee.py index f74c3546..42c81361 100644 --- a/app/scodoc/sco_lycee.py +++ b/app/scodoc/sco_lycee.py @@ -59,7 +59,7 @@ def formsemestre_table_etuds_lycees( etuds, group_lycees, title, - sco_preferences.SemPreferences(context, formsemestre_id), + sco_preferences.SemPreferences(formsemestre_id), ) @@ -75,9 +75,7 @@ def scodoc_table_etuds_lycees(context, format="html", REQUEST=None): etuds, False, "Lycées de TOUS les étudiants", - sco_preferences.SemPreferences( - context, - ), + sco_preferences.SemPreferences(), no_links=True, ) tab.base_url = REQUEST.URL0 diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index 805b9d2c..715703dd 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -521,7 +521,6 @@ def is_inscrit_ue(context, etudid, formsemestre_id, ue_id): auxquels l'étudiant est inscrit. """ r = ndb.SimpleDictFetch( - context, """SELECT mod.* FROM notes_moduleimpl mi, notes_modules mod, notes_formsemestre sem, notes_moduleimpl_inscription i diff --git a/app/scodoc/sco_news.py b/app/scodoc/sco_news.py index 5ab608d0..593d50fd 100644 --- a/app/scodoc/sco_news.py +++ b/app/scodoc/sco_news.py @@ -260,7 +260,7 @@ def _send_news_by_mail(context, n): """Notify by email""" infos = _get_formsemestre_infos_from_news(context, n) formsemestre_id = infos.get("formsemestre_id", None) - prefs = sco_preferences.SemPreferences(context, formsemestre_id=formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id=formsemestre_id) destinations = prefs["emails_notifications"] or "" destinations = [x.strip() for x in destinations.split(",")] destinations = [x for x in destinations if x] diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index 6028568f..d717f0c4 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -352,7 +352,7 @@ def copy_portal_photo_to_fs(context, etud, REQUEST=None): url = photo_portal_url(context, etud) if not url: return None, "%(nomprenom)s: pas de code NIP" % etud - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") f = None try: log("copy_portal_photo_to_fs: getting %s" % url) diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index d3f91400..14909cee 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -392,7 +392,7 @@ def do_placement(context, REQUEST): + "", pdf_title=pdf_title, # pdf_shorttitle = '', - preferences=sco_preferences.SemPreferences(context, M["formsemestre_id"]), + preferences=sco_preferences.SemPreferences(M["formsemestre_id"]), # html_generate_cells=False # la derniere ligne (moyennes) est incomplete ) t = tab.make_page( diff --git a/app/scodoc/sco_portal_apogee.py b/app/scodoc/sco_portal_apogee.py index 995dc856..a7dbff26 100644 --- a/app/scodoc/sco_portal_apogee.py +++ b/app/scodoc/sco_portal_apogee.py @@ -56,7 +56,7 @@ class PortalInterface(object): def get_portal_url(self, context): "URL of portal" - portal_url = sco_preferences.get_preference(context, "portal_url") + portal_url = sco_preferences.get_preference("portal_url") if not self.warning: if portal_url: log("Portal URL=%s" % portal_url) @@ -67,7 +67,7 @@ class PortalInterface(object): def get_etapes_url(self, context): "Full URL of service giving list of etapes (in XML)" - etapes_url = sco_preferences.get_preference(context, "etapes_url") + etapes_url = sco_preferences.get_preference("etapes_url") if not etapes_url: # Default: portal_url = self.get_portal_url(context) @@ -82,7 +82,7 @@ class PortalInterface(object): def get_etud_url(self, context): "Full URL of service giving list of students (in XML)" - etud_url = sco_preferences.get_preference(context, "etud_url") + etud_url = sco_preferences.get_preference("etud_url") if not etud_url: # Default: portal_url = self.get_portal_url(context) @@ -97,7 +97,7 @@ class PortalInterface(object): def get_photo_url(self, context): "Full URL of service giving photo of student" - photo_url = sco_preferences.get_preference(context, "photo_url") + photo_url = sco_preferences.get_preference("photo_url") if not photo_url: # Default: portal_url = self.get_portal_url(context) @@ -112,7 +112,7 @@ class PortalInterface(object): def get_maquette_url(self, context): """Full URL of service giving Apogee maquette pour une étape (fichier "CSV")""" - maquette_url = sco_preferences.get_preference(context, "maquette_url") + maquette_url = sco_preferences.get_preference("maquette_url") if not maquette_url: # Default: portal_url = self.get_portal_url(context) @@ -123,7 +123,7 @@ class PortalInterface(object): def get_portal_api_version(self, context): "API version of the portal software" - api_ver = sco_preferences.get_preference(context, "portal_api") + api_ver = sco_preferences.get_preference("portal_api") if not api_ver: # Default: api_ver = 1 @@ -152,7 +152,7 @@ def get_inscrits_etape(context, code_etape, anneeapogee=None, ntrials=2): api_ver = get_portal_api_version(context) if not etud_url: return [] - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") if api_ver > 1: req = ( etud_url @@ -208,7 +208,7 @@ def query_apogee_portal(context, **args): # Ne fonctionne pas avec l'API 2 sur nom et prenom # XXX TODO : va poser problème pour la page modif données étudiants : A VOIR return [] - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") req = etud_url + "?" + six.moves.urllib.parse.urlencode(list(args.items())) doc = scu.query_portal(req, timeout=portal_timeout) # sco_utils return xml_to_list_of_dicts(doc, req=req) @@ -321,7 +321,7 @@ def get_etud_apogee(context, code_nip): etud_url = get_etud_url(context) if not etud_url: return {} - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") req = etud_url + "?" + six.moves.urllib.parse.urlencode((("nip", code_nip),)) doc = scu.query_portal(req, timeout=portal_timeout) d = _normalize_apo_fields(xml_to_list_of_dicts(doc, req=req)) @@ -354,7 +354,7 @@ def _parse_etapes_from_xml(context, doc): """ may raise exception if invalid xml doc """ - xml_etapes_by_dept = sco_preferences.get_preference(context, "xml_etapes_by_dept") + xml_etapes_by_dept = sco_preferences.get_preference("xml_etapes_by_dept") # parser XML dom = xml.dom.minidom.parseString(doc) infos = {} @@ -382,7 +382,7 @@ def get_etapes_apogee(context): etapes_url = get_etapes_url(context) infos = {} if etapes_url: - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") log( "get_etapes_apogee: requesting '%s' with timeout=%s" % (etapes_url, portal_timeout) @@ -430,9 +430,9 @@ def get_etapes_apogee_dept(context): Returns [ ( code, intitule) ], ordonnée """ - xml_etapes_by_dept = sco_preferences.get_preference(context, "xml_etapes_by_dept") + xml_etapes_by_dept = sco_preferences.get_preference("xml_etapes_by_dept") if xml_etapes_by_dept: - portal_dept_name = sco_preferences.get_preference(context, "portal_dept_name") + portal_dept_name = sco_preferences.get_preference("portal_dept_name") log('get_etapes_apogee_dept: portal_dept_name="%s"' % portal_dept_name) else: portal_dept_name = "" @@ -556,7 +556,7 @@ def get_maquette_apogee(context, etape="", annee_scolaire=""): maquette_url = get_maquette_url(context) if not maquette_url: return None - portal_timeout = sco_preferences.get_preference(context, "portal_timeout") + portal_timeout = sco_preferences.get_preference("portal_timeout") req = ( maquette_url + "?" diff --git a/app/scodoc/sco_poursuite_dut.py b/app/scodoc/sco_poursuite_dut.py index c8e3f6bf..42788d38 100644 --- a/app/scodoc/sco_poursuite_dut.py +++ b/app/scodoc/sco_poursuite_dut.py @@ -206,7 +206,7 @@ def formsemestre_poursuite_report( html_sortable=True, html_class="table_leftalign table_listegroupe", pdf_link=False, # pas d'export pdf - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) tab.filename = scu.make_filename("poursuite " + sem["titreannee"]) diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 76f3c709..cd8e70d4 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -68,18 +68,18 @@ des tuples (name, value, formsemestre_id). Si formsemestre_id est NULL, la valeur concerne tous les semestres, sinon, elle ne concerne que le semestre indiqué. -* Utilisation dans ScoDoc7 +* Utilisation dans ScoDoc8 - lire une valeur: - get_preference(context, name, formsemestre_id) + get_preference(name, formsemestre_id) nb: les valeurs sont des chaines, sauf: . si le type est spécfié (float ou int) . les boolcheckbox qui sont des entiers 0 ou 1 - avoir un mapping (read only) de toutes les valeurs: - sco_preferences.SemPreferences(context,formsemestre_id) + sco_preferences.SemPreferences(formsemestre_id) - editer les preferences globales: sco_preferences.get_base_preferences(self).edit(REQUEST=REQUEST) - editer les preferences d'un semestre: - SemPreferences(context,formsemestre_id).edit() + SemPreferences(formsemestre_id).edit() * Implémentation: sco_preferences.py @@ -98,7 +98,7 @@ Une instance unique par site (département, repéré par URL). .deleteformsemestre_id, name) .edit() (HTML dialog) -class SemPreferences(context,formsemestre_id) +class SemPreferences(formsemestre_id) Une instance par semestre, et une instance pour prefs globales. L'attribut .base_prefs point sur BasePreferences. .__getitem__ [name] @@ -106,8 +106,8 @@ L'attribut .base_prefs point sur BasePreferences. .edit(categories=[]) -get_base_preferences(context, formsemestre_id) - Return base preferences for this context (instance BasePreferences) +get_base_preferences(formsemestre_id) + Return base preferences for current scodoc_dept (instance BasePreferences) """ from flask import g @@ -122,20 +122,20 @@ import app.scodoc.sco_utils as scu _SCO_BASE_PREFERENCES = {} # { URL: BasePreferences instance } -def get_base_preferences(context): +def get_base_preferences(): """Return global preferences for the current department""" dept = g.scodoc_dept if not dept in _SCO_BASE_PREFERENCES: - _SCO_BASE_PREFERENCES[dept] = BasePreferences(context) + _SCO_BASE_PREFERENCES[dept] = BasePreferences() return _SCO_BASE_PREFERENCES[dept] -def get_preference(context, name, formsemestre_id=None): +def get_preference(name, formsemestre_id=None): """Returns value of named preference. All preferences have a sensible default value, so this function always returns a usable value for all defined preferences names. """ - return get_base_preferences(context).get(formsemestre_id, name) + return get_base_preferences().get(formsemestre_id, name) PREF_CATEGORIES = ( @@ -205,8 +205,7 @@ class BasePreferences(object): filter_nulls=False, ) - def __init__(self, context): - self.context = context + def __init__(self): self.init() self.load() @@ -1957,8 +1956,9 @@ class BasePreferences(object): """HTML dialog: edit global preferences""" from app.scodoc import html_sco_header + context = None # XXX TO REMOVE #context H = [ - html_sco_header.sco_header(self.context, REQUEST, page_title="Préférences"), + html_sco_header.sco_header(context, REQUEST, page_title="Préférences"), "

    Préférences globales pour %s

    " % scu.ScoURL(), """

    Ces paramètres s'appliquent par défaut à tous les semestres, sauf si ceux-ci définissent des valeurs spécifiques.

    Attention: cliquez sur "Enregistrer les modifications" en bas de page pour appliquer vos changements !

    @@ -1973,9 +1973,7 @@ class BasePreferences(object): submitlabel="Enregistrer les modifications", ) if tf[0] == 0: - return ( - "\n".join(H) + tf[1] + html_sco_header.sco_footer(self.context, REQUEST) - ) + return "\n".join(H) + tf[1] + html_sco_header.sco_footer(context, REQUEST) elif tf[0] == -1: return REQUEST.RESPONSE.redirect(scu.ScoURL()) # cancel else: @@ -2058,10 +2056,9 @@ class BasePreferences(object): class SemPreferences(object): """Preferences for a formsemestre""" - def __init__(self, context, formsemestre_id=None): - self.context = context + def __init__(self, formsemestre_id=None): self.formsemestre_id = formsemestre_id - self.base_prefs = get_base_preferences(self.context) + self.base_prefs = get_base_preferences() def __getitem__(self, name): return self.base_prefs.get(self.formsemestre_id, name) @@ -2091,10 +2088,11 @@ class SemPreferences(object): raise ScoValueError( "sem_preferences.edit doit etre appele sur un semestre !" ) # a bug ! - sem = sco_formsemestre.get_formsemestre(self.context, self.formsemestre_id) + context = None # XXX TO REMOVE + sem = sco_formsemestre.get_formsemestre(context, self.formsemestre_id) H = [ html_sco_header.html_sem_header( - self.context, REQUEST, "Préférences du semestre", sem + context, REQUEST, "Préférences du semestre", sem ), """

    Les paramètres définis ici ne s'appliqueront qu'à ce semestre.

    @@ -2149,10 +2147,9 @@ function set_global_pref(el, pref_name) { scu.NotesURL() + "/formsemestre_status?formsemestre_id=%s" % self.formsemestre_id ) + context = None # XXX TO REMOVE if tf[0] == 0: - return ( - "\n".join(H) + tf[1] + html_sco_header.sco_footer(self.context, REQUEST) - ) + return "\n".join(H) + tf[1] + html_sco_header.sco_footer(context, REQUEST) elif tf[0] == -1: return REQUEST.RESPONSE.redirect( dest_url + "&head_message=Annulé" @@ -2202,7 +2199,7 @@ function set_global_pref(el, pref_name) { # -def doc_preferences(context): +def doc_preferences(): """ Liste les preferences en MarkDown, pour la documentation""" L = [] for cat, cat_descr in PREF_CATEGORIES: @@ -2211,7 +2208,7 @@ def doc_preferences(context): L.append([""]) L.append(["Nom", " ", " "]) L.append(["----", "----", "----"]) - for pref_name, pref in get_base_preferences(context).prefs_definition: + for pref_name, pref in get_base_preferences().prefs_definition: if pref["category"] == cat: L.append( ["`" + pref_name + "`", pref["title"], pref.get("explanation", "")] diff --git a/app/scodoc/sco_prepajury.py b/app/scodoc/sco_prepajury.py index f18b2c49..057f8ea5 100644 --- a/app/scodoc/sco_prepajury.py +++ b/app/scodoc/sco_prepajury.py @@ -158,9 +158,9 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST): L.append([]) # empty line titles = ["Rang"] - if sco_preferences.get_preference(context, "prepa_jury_nip"): + if sco_preferences.get_preference("prepa_jury_nip"): titles.append("NIP") - if sco_preferences.get_preference(context, "prepa_jury_ine"): + if sco_preferences.get_preference("prepa_jury_ine"): titles.append("INE") titles += [ "etudid", @@ -220,9 +220,9 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST): for etudid in etudids: etud = nt.identdict[etudid] l = [str(i)] - if sco_preferences.get_preference(context, "prepa_jury_nip"): + if sco_preferences.get_preference("prepa_jury_nip"): l.append(etud["code_nip"]) - if sco_preferences.get_preference(context, "prepa_jury_ine"): + if sco_preferences.get_preference("prepa_jury_ine"): l.append(etud["code_ine"]) l += [ etudid, diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 28d6632e..2a626346 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -419,10 +419,10 @@ def pvjury_table( columns_ids += ["prev_decision"] columns_ids += ["decision"] - if sco_preferences.get_preference(context, "bul_show_mention", formsemestre_id): + if sco_preferences.get_preference("bul_show_mention", formsemestre_id): columns_ids += ["mention"] columns_ids += ["ue_cap"] - if sco_preferences.get_preference(context, "bul_show_ects", formsemestre_id): + if sco_preferences.get_preference("bul_show_ects", formsemestre_id): columns_ids += ["ects"] # XXX if not dpv["semestre_non_terminal"]: @@ -459,13 +459,13 @@ def pvjury_table( if with_paragraph_nom: cell_style = styles.ParagraphStyle({}) cell_style.fontSize = sco_preferences.get_preference( - context, "SCOLAR_FONT_SIZE", formsemestre_id + "SCOLAR_FONT_SIZE", formsemestre_id ) cell_style.fontName = sco_preferences.get_preference( - context, "PV_FONTNAME", formsemestre_id + "PV_FONTNAME", formsemestre_id ) cell_style.leading = 1.0 * sco_preferences.get_preference( - context, "SCOLAR_FONT_SIZE", formsemestre_id + "SCOLAR_FONT_SIZE", formsemestre_id ) # vertical space i = e["identite"] l["nomprenom"] = [ @@ -540,7 +540,7 @@ def formsemestre_pvjury( caption="Décisions jury pour " + sem["titreannee"], html_class="table_leftalign", html_sortable=True, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) if format != "html": return tab.make_page( @@ -602,7 +602,7 @@ def formsemestre_pvjury( columns_ids=("code", "count", "expl"), html_class="table_leftalign", html_sortable=True, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ).html() ) H.append("

    ") # force space at bottom diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index 623adaa4..64120166 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -349,7 +349,7 @@ def pdf_lettres_individuelles( sco_etud.fill_etuds_info(etuds) # sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) - prefs = sco_preferences.SemPreferences(context, formsemestre_id) + prefs = sco_preferences.SemPreferences(formsemestre_id) params = { "date_jury": date_jury, "date_commission": date_commission, @@ -359,9 +359,7 @@ def pdf_lettres_individuelles( } # copie preferences for name in sco_preferences.get_base_preferences(context).prefs_name: - params[name] = sco_preferences.get_preference( - context, name, sem["formsemestre_id"] - ) + params[name] = sco_preferences.get_preference(name, sem["formsemestre_id"]) bookmarks = {} objects = [] # list of PLATYPUS objects @@ -432,9 +430,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context objects = [] style = reportlab.lib.styles.ParagraphStyle({}) style.fontSize = 14 - style.fontName = sco_preferences.get_preference( - context, "PV_FONTNAME", formsemestre_id - ) + style.fontName = sco_preferences.get_preference("PV_FONTNAME", formsemestre_id) style.leading = 18 style.alignment = TA_JUSTIFY @@ -449,7 +445,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context params["decisions_ue_descr_plural"] = "" params["INSTITUTION_CITY"] = sco_preferences.get_preference( - context, "INSTITUTION_CITY", formsemestre_id + "INSTITUTION_CITY", formsemestre_id ) if decision["prev_decision_sem"]: params["prev_semestre_id"] = decision["prev"]["semestre_id"] @@ -517,9 +513,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context # Corps de la lettre: objects += sco_bulletins_pdf.process_field( context, - sco_preferences.get_preference( - context, "PV_LETTER_TEMPLATE", sem["formsemestre_id"] - ), + sco_preferences.get_preference("PV_LETTER_TEMPLATE", sem["formsemestre_id"]), params, style, suppress_empty_pars=True, @@ -531,7 +525,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context if Se.semestre_non_terminal: sig = ( sco_preferences.get_preference( - context, "PV_LETTER_PASSAGE_SIGNATURE", formsemestre_id + "PV_LETTER_PASSAGE_SIGNATURE", formsemestre_id ) % params ) @@ -548,7 +542,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context else: sig = ( sco_preferences.get_preference( - context, "PV_LETTER_DIPLOMA_SIGNATURE", formsemestre_id + "PV_LETTER_DIPLOMA_SIGNATURE", formsemestre_id ) % params ) @@ -592,16 +586,14 @@ def _make_signature_image(signature, leftindent, formsemestre_id, context=None): width, height = im.size pdfheight = ( 1.0 - * sco_preferences.get_preference( - context, "pv_sig_image_height", formsemestre_id - ) + * sco_preferences.get_preference("pv_sig_image_height", formsemestre_id) * mm ) f.seek(0, 0) style = styles.ParagraphStyle({}) style.leading = 1.0 * sco_preferences.get_preference( - context, "SCOLAR_FONT_SIZE", formsemestre_id + "SCOLAR_FONT_SIZE", formsemestre_id ) # vertical space style.leftIndent = leftindent return Table( @@ -681,7 +673,7 @@ def pvjury_pdf( author="%s %s (E. Viennet)" % (VERSION.SCONAME, VERSION.SCOVERSION), title=SU("PV du jury de %s" % sem["titre_num"]), subject="PV jury", - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) ) @@ -719,9 +711,7 @@ def _pvjury_pdf_type( style = reportlab.lib.styles.ParagraphStyle({}) style.fontSize = 12 - style.fontName = sco_preferences.get_preference( - context, "PV_FONTNAME", formsemestre_id - ) + style.fontName = sco_preferences.get_preference("PV_FONTNAME", formsemestre_id) style.leading = 18 style.alignment = TA_JUSTIFY @@ -729,7 +719,7 @@ def _pvjury_pdf_type( bulletStyle = reportlab.lib.styles.ParagraphStyle({}) bulletStyle.fontSize = 12 bulletStyle.fontName = sco_preferences.get_preference( - context, "PV_FONTNAME", formsemestre_id + "PV_FONTNAME", formsemestre_id ) bulletStyle.leading = 12 bulletStyle.alignment = TA_JUSTIFY @@ -748,7 +738,7 @@ def _pvjury_pdf_type( """ % ( titre_jury, - sco_preferences.get_preference(context, "DeptName", formsemestre_id), + sco_preferences.get_preference("DeptName", formsemestre_id), sem["anneescolaire"], ), style, @@ -766,7 +756,7 @@ def _pvjury_pdf_type( objects += sco_pdf.makeParas( """Semestre: %s""" % sem["titre"], style ) - if sco_preferences.get_preference(context, "PV_TITLE_WITH_VDI", formsemestre_id): + if sco_preferences.get_preference("PV_TITLE_WITH_VDI", formsemestre_id): objects += sco_pdf.makeParas( """VDI et Code: %s""" % (VDICode or ""), style ) @@ -778,13 +768,11 @@ def _pvjury_pdf_type( objects += sco_pdf.makeParas( "" - + sco_preferences.get_preference(context, "PV_INTRO", formsemestre_id) + + sco_preferences.get_preference("PV_INTRO", formsemestre_id) % { "Decnum": numeroArrete, "VDICode": VDICode, - "UnivName": sco_preferences.get_preference( - context, "UnivName", formsemestre_id - ), + "UnivName": sco_preferences.get_preference("UnivName", formsemestre_id), "Type": titre_jury, "Date": date_commission, # deprecated "date_commission": date_commission, @@ -811,13 +799,11 @@ def _pvjury_pdf_type( # Make a new cell style and put all cells in paragraphs cell_style = styles.ParagraphStyle({}) cell_style.fontSize = sco_preferences.get_preference( - context, "SCOLAR_FONT_SIZE", formsemestre_id - ) - cell_style.fontName = sco_preferences.get_preference( - context, "PV_FONTNAME", formsemestre_id + "SCOLAR_FONT_SIZE", formsemestre_id ) + cell_style.fontName = sco_preferences.get_preference("PV_FONTNAME", formsemestre_id) cell_style.leading = 1.0 * sco_preferences.get_preference( - context, "SCOLAR_FONT_SIZE", formsemestre_id + "SCOLAR_FONT_SIZE", formsemestre_id ) # vertical space LINEWIDTH = 0.5 table_style = [ @@ -825,7 +811,7 @@ def _pvjury_pdf_type( "FONTNAME", (0, 0), (-1, 0), - sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id), + sco_preferences.get_preference("PV_FONTNAME", formsemestre_id), ), ("LINEBELOW", (0, 0), (-1, 0), LINEWIDTH, Color(0, 0, 0)), ("GRID", (0, 0), (-1, -1), LINEWIDTH, Color(0, 0, 0)), @@ -844,7 +830,7 @@ def _pvjury_pdf_type( widths = [6 * cm, 2.8 * cm, 2.8 * cm, None, None, None, None] if dpv["has_prev"]: widths[2:2] = [2.8 * cm] - if sco_preferences.get_preference(context, "bul_show_mention", formsemestre_id): + if sco_preferences.get_preference("bul_show_mention", formsemestre_id): widths += [None] objects.append(Table(Pt, repeatRows=1, colWidths=widths, style=table_style)) @@ -853,10 +839,8 @@ def _pvjury_pdf_type( """ %s, %s""" % ( - sco_preferences.get_preference(context, "DirectorName", formsemestre_id) - or "", - sco_preferences.get_preference(context, "DirectorTitle", formsemestre_id) - or "", + sco_preferences.get_preference("DirectorName", formsemestre_id) or "", + sco_preferences.get_preference("DirectorTitle", formsemestre_id) or "", ), style, ) @@ -877,7 +861,7 @@ def _pvjury_pdf_type( "FONTNAME", (0, 0), (-1, 0), - sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id), + sco_preferences.get_preference("PV_FONTNAME", formsemestre_id), ), ("LINEBELOW", (0, 0), (-1, -1), LINEWIDTH, Color(0, 0, 0)), ("LINEABOVE", (0, 0), (-1, -1), LINEWIDTH, Color(0, 0, 0)), diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index da20d77b..bc4442cf 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -85,9 +85,7 @@ def formsemestre_recapcomplet( ) # cache les colonnes des modules pref_override = int(pref_override) if pref_override: - hidebac = int( - sco_preferences.get_preference(context, "recap_hidebac", formsemestre_id) - ) + hidebac = int(sco_preferences.get_preference("recap_hidebac", formsemestre_id)) else: hidebac = int(hidebac) xml_with_decisions = int(xml_with_decisions) @@ -188,7 +186,7 @@ def formsemestre_recapcomplet( % formsemestre_id ) H.append("

    ") - if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id): + if sco_preferences.get_preference("use_ue_coefs", formsemestre_id): H.append( """

    utilise les coefficients d'UE pour calculer la moyenne générale.

    @@ -497,9 +495,7 @@ def make_formsemestre_recapcomplet( if key == "nb_valid_evals": l.append("") elif key == "coef": - if sco_preferences.get_preference( - context, "use_ue_coefs", formsemestre_id - ): + if sco_preferences.get_preference("use_ue_coefs", formsemestre_id): l.append("%2.3f" % ue["coefficient"]) else: l.append("") diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index acc6c4b6..2228af5b 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -202,7 +202,7 @@ def _results_by_category( bottom_titles=bottom_titles, html_col_width="4em", html_sortable=True, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) @@ -655,7 +655,7 @@ def table_suivi_cohorte( caption="Suivi cohorte " + pp + sem["titreannee"] + dbac, page_title="Suivi cohorte " + sem["titreannee"], html_class="table_cohorte", - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) # Explication: liste des semestres associés à chaque date if not P: @@ -1168,7 +1168,7 @@ def table_suivi_parcours( "nb": len(etuds), "codeparcours": len(etuds), }, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) return tab diff --git a/app/scodoc/sco_semset.py b/app/scodoc/sco_semset.py index 00080d6a..8a36ab49 100644 --- a/app/scodoc/sco_semset.py +++ b/app/scodoc/sco_semset.py @@ -86,7 +86,6 @@ class SemSet(dict): self["annee_scolaire"] = L[0]["annee_scolaire"] self["sem_id"] = L[0]["sem_id"] r = ndb.SimpleDictFetch( - context, "SELECT formsemestre_id FROM notes_semset_formsemestre WHERE semset_id = %(semset_id)s", {"semset_id": semset_id}, ) @@ -460,9 +459,7 @@ def semset_page(context, format="html", REQUEST=None): html_sortable=True, html_class="table_leftalign", filename="semsets", - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) if format != "html": return tab.make_page(context, format=format, REQUEST=REQUEST) diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py index 46c5569d..2cfaf566 100644 --- a/app/scodoc/sco_tag_module.py +++ b/app/scodoc/sco_tag_module.py @@ -73,7 +73,6 @@ class ScoTag(object): if not self.title: raise ScoValueError("invalid empty tag") r = ndb.SimpleDictFetch( - context, "SELECT * FROM " + self.tag_table + " WHERE title = %(title)s", {"title": self.title}, ) @@ -87,7 +86,6 @@ class ScoTag(object): cnx, self.tag_table, {"title": self.title}, commit=True ) self.tag_id = ndb.SimpleDictFetch( - context, "SELECT tag_id FROM " + self.tag_table + " WHERE oid=%(oid)s", {"oid": oid}, )[0]["tag_id"] @@ -206,7 +204,6 @@ def module_tag_search(context, term, REQUEST=None): data = [] else: r = ndb.SimpleDictFetch( - context, "SELECT title FROM notes_tags WHERE title LIKE %(term)s", {"term": term + "%"}, ) @@ -218,7 +215,6 @@ def module_tag_search(context, term, REQUEST=None): def module_tag_list(context, module_id=""): """les noms de tags associés à ce module""" r = ndb.SimpleDictFetch( - context, """SELECT t.title FROM notes_modules_tags mt, notes_tags t WHERE mt.tag_id = t.tag_id diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py index eb303fda..7eefaf3a 100644 --- a/app/scodoc/sco_trombino.py +++ b/app/scodoc/sco_trombino.py @@ -391,7 +391,7 @@ def _trombino_pdf(context, groups_infos, REQUEST): sco_pdf.ScolarsPageTemplate( document, context=context, - preferences=sco_preferences.SemPreferences(context, sem["formsemestre_id"]), + preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]), ) ) document.build(objects) @@ -468,7 +468,7 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST): sco_pdf.ScolarsPageTemplate( document, context, - preferences=sco_preferences.SemPreferences(context, sem["formsemestre_id"]), + preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]), ) ) document.build(objects) diff --git a/app/scodoc/sco_trombino_tours.py b/app/scodoc/sco_trombino_tours.py index 7a7be41f..5905ff18 100644 --- a/app/scodoc/sco_trombino_tours.py +++ b/app/scodoc/sco_trombino_tours.py @@ -65,10 +65,10 @@ def pdf_trombino_tours( context, group_ids, formsemestre_id=formsemestre_id, REQUEST=REQUEST ) - DeptName = sco_preferences.get_preference(context, "DeptName") - DeptFullName = sco_preferences.get_preference(context, "DeptFullName") - UnivName = sco_preferences.get_preference(context, "UnivName") - InstituteName = sco_preferences.get_preference(context, "InstituteName") + DeptName = sco_preferences.get_preference("DeptName") + DeptFullName = sco_preferences.get_preference("DeptFullName") + UnivName = sco_preferences.get_preference("UnivName") + InstituteName = sco_preferences.get_preference("InstituteName") # Generate PDF page StyleSheet = styles.getSampleStyleSheet() objects = [] @@ -272,9 +272,7 @@ def pdf_trombino_tours( ScolarsPageTemplate( document, context=context, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) ) document.build(objects) @@ -294,10 +292,10 @@ def pdf_feuille_releve_absences( ): """Generation de la feuille d'absence en fichier PDF, avec photos""" - NB_CELL_AM = sco_preferences.get_preference(context, "feuille_releve_abs_AM") - NB_CELL_PM = sco_preferences.get_preference(context, "feuille_releve_abs_PM") + NB_CELL_AM = sco_preferences.get_preference("feuille_releve_abs_AM") + NB_CELL_PM = sco_preferences.get_preference("feuille_releve_abs_PM") COLWIDTH = 0.85 * cm - if sco_preferences.get_preference(context, "feuille_releve_abs_samedi"): + if sco_preferences.get_preference("feuille_releve_abs_samedi"): days = sco_abs.DAYNAMES[:6] # Lundi, ..., Samedi else: days = sco_abs.DAYNAMES[:5] # Lundi, ..., Vendredi @@ -308,10 +306,10 @@ def pdf_feuille_releve_absences( context, group_ids, formsemestre_id=formsemestre_id, REQUEST=REQUEST ) - DeptName = sco_preferences.get_preference(context, "DeptName") - DeptFullName = sco_preferences.get_preference(context, "DeptFullName") - UnivName = sco_preferences.get_preference(context, "UnivName") - InstituteName = sco_preferences.get_preference(context, "InstituteName") + DeptName = sco_preferences.get_preference("DeptName") + DeptFullName = sco_preferences.get_preference("DeptFullName") + UnivName = sco_preferences.get_preference("UnivName") + InstituteName = sco_preferences.get_preference("InstituteName") # Generate PDF page StyleSheet = styles.getSampleStyleSheet() objects = [ @@ -458,14 +456,11 @@ def pdf_feuille_releve_absences( # Build document report = io.BytesIO() # in-memory document, no disk file filename = "absences-%s-%s.pdf" % (DeptName, groups_infos.groups_filename) - if sco_preferences.get_preference(context, "feuille_releve_abs_taille") == "A3": + if sco_preferences.get_preference("feuille_releve_abs_taille") == "A3": taille = A3 - elif sco_preferences.get_preference(context, "feuille_releve_abs_taille") == "A4": + elif sco_preferences.get_preference("feuille_releve_abs_taille") == "A4": taille = A4 - if ( - sco_preferences.get_preference(context, "feuille_releve_abs_format") - == "Paysage" - ): + if sco_preferences.get_preference("feuille_releve_abs_format") == "Paysage": document = BaseDocTemplate(report, pagesize=landscape(taille)) else: document = BaseDocTemplate(report, pagesize=taille) @@ -473,9 +468,7 @@ def pdf_feuille_releve_absences( ScolarsPageTemplate( document, context=context, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) ) document.build(objects) diff --git a/app/scodoc/sco_ue_external.py b/app/scodoc/sco_ue_external.py index 3b40dc1a..ee5ad943 100644 --- a/app/scodoc/sco_ue_external.py +++ b/app/scodoc/sco_ue_external.py @@ -152,7 +152,11 @@ def external_ue_inscrit_et_note( ) # Inscription des étudiants sco_moduleimpl.do_moduleimpl_inscrit_etuds( - context, moduleimpl_id, formsemestre_id, list(notes_etuds.keys()), REQUEST=REQUEST + context, + moduleimpl_id, + formsemestre_id, + list(notes_etuds.keys()), + REQUEST=REQUEST, ) # Création d'une évaluation si il n'y en a pas déjà: @@ -164,7 +168,8 @@ def external_ue_inscrit_et_note( evaluation_id = ModEvals[0]["evaluation_id"] else: # crée une évaluation: - evaluation_id = sco_evaluations.do_evaluation_create(context, + evaluation_id = sco_evaluations.do_evaluation_create( + context, REQUEST=REQUEST, moduleimpl_id=moduleimpl_id, note_max=20.0, @@ -194,7 +199,6 @@ def get_existing_external_ue(context, formation_id): def get_external_moduleimpl_id(context, formsemestre_id, ue_id): "moduleimpl correspondant à l'UE externe indiquée de ce formsemestre" r = ndb.SimpleDictFetch( - context, """ SELECT moduleimpl_id FROM notes_moduleimpl mi, notes_modules mo WHERE mi.formsemestre_id = %(formsemestre_id)s diff --git a/app/scodoc/sco_undo_notes.py b/app/scodoc/sco_undo_notes.py index a41047ea..54d891af 100644 --- a/app/scodoc/sco_undo_notes.py +++ b/app/scodoc/sco_undo_notes.py @@ -165,7 +165,7 @@ def evaluation_list_operations(context, REQUEST, evaluation_id): html_sortable=False, html_title="

    Opérations sur l'évaluation %s du %s

    " % (E["description"], E["jour"]), - preferences=sco_preferences.SemPreferences(context, M["formsemestre_id"]), + preferences=sco_preferences.SemPreferences(M["formsemestre_id"]), ) return tab.make_page(context, REQUEST=REQUEST) @@ -176,7 +176,6 @@ def formsemestre_list_saisies_notes( """Table listant toutes les operations de saisies de notes, dans toutes les evaluations du semestre.""" sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) r = ndb.SimpleDictFetch( - context, """select i.nom, n.*, mod.titre, e.description, e.jour from notes_notes n, notes_evaluation e, notes_moduleimpl m, notes_modules mod, identite i where m.moduleimpl_id = e.moduleimpl_id and m.module_id = mod.module_id and e.evaluation_id=n.evaluation_id and i.etudid=n.etudid and m.formsemestre_id=%(formsemestre_id)s order by date desc""", {"formsemestre_id": formsemestre_id}, ) @@ -208,7 +207,7 @@ def formsemestre_list_saisies_notes( html_class="table_leftalign table_coldate", html_sortable=True, caption="Saisies de notes dans %s" % sem["titreannee"], - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id), origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "", ) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 859dece1..233bbba0 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -788,7 +788,7 @@ def AnneeScolaire(REQUEST=None): # TODO remplacer REQUEST #sco8 return year -def log_unknown_etud(context, REQUEST=None, format="html"): +def log_unknown_etud(REQUEST=None, format="html"): """Log request: cas ou getEtudInfo n'a pas ramene de resultat""" etudid = REQUEST.form.get("etudid", "?") code_nip = REQUEST.form.get("code_nip", "?") @@ -797,13 +797,11 @@ def log_unknown_etud(context, REQUEST=None, format="html"): "unknown student: etudid=%s code_nip=%s code_ine=%s" % (etudid, code_nip, code_ine) ) - return _sco_error_response( - context, "unknown student", format=format, REQUEST=REQUEST - ) + return _sco_error_response("unknown student", format=format, REQUEST=REQUEST) # XXX #sco8 à tester ou ré-écrire -def _sco_error_response(context, msg, format="html", REQUEST=None): +def _sco_error_response(msg, format="html", REQUEST=None): """Send an error message to the client, in html or xml format.""" REQUEST.RESPONSE.setStatus(404, reason=msg) if format == "html" or format == "pdf": diff --git a/app/views/absences.py b/app/views/absences.py index f6e66a68..25a5b7ca 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -152,7 +152,7 @@ def index_html(context, REQUEST=None): H.append( """
    • Afficher l'état des absences (pour tout un groupe)
    • """ ) - if sco_preferences.get_preference(context, "handle_billets_abs"): + if sco_preferences.get_preference("handle_billets_abs"): H.append( """
    • Traitement des billets d'absence en attente
    • """ ) @@ -340,7 +340,7 @@ def SignaleAbsenceGrHebdo( formsemestre_id = groups_infos.formsemestre_id require_module = sco_preferences.get_preference( - context, "abs_require_module", formsemestre_id + "abs_require_module", formsemestre_id ) etuds = [ sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0] @@ -504,7 +504,7 @@ def SignaleAbsenceGrSemestre( ) formsemestre_id = groups_infos.formsemestre_id require_module = sco_preferences.get_preference( - context, "abs_require_module", formsemestre_id + "abs_require_module", formsemestre_id ) etuds = [ sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0] @@ -943,7 +943,7 @@ def EtatAbsencesGr( tab = GenTable( columns_ids=columns_ids, rows=T, - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), titles={ "etatincursem": "Etat", "nomprenom": "Nom", @@ -1106,7 +1106,7 @@ def AddBilletAbsence( etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True ) if not etuds: - return scu.log_unknown_etud(context, REQUEST=REQUEST) + return scu.log_unknown_etud(REQUEST=REQUEST) etud = etuds[0] # check dates begin_date = dateutil.parser.isoparse(begin) # may raises ValueError @@ -1246,9 +1246,7 @@ def _tableBillets(context, billets, etud=None, title=""): columns_ids=columns_ids, page_title=title, html_title="

      %s

      " % title, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), rows=billets, html_sortable=True, ) @@ -1262,7 +1260,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"): """Liste billets pour un etudiant""" etuds = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST) if not etuds: - return scu.log_unknown_etud(context, format=format, REQUEST=REQUEST) + return scu.log_unknown_etud(format=format, REQUEST=REQUEST) etud = etuds[0] cnx = ndb.GetDBConnexion() @@ -1276,7 +1274,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"): @scodoc7func(context) def XMLgetBilletsEtud(context, etudid=False, REQUEST=None): """Liste billets pour un etudiant""" - if not sco_preferences.get_preference(context, "handle_billets_abs"): + if not sco_preferences.get_preference("handle_billets_abs"): return "" t0 = time.time() r = listeBilletsEtud(context, etudid, REQUEST=REQUEST, format="xml") diff --git a/app/views/notes.py b/app/views/notes.py index 90dc463b..374ea3d4 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1035,9 +1035,7 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"): base_url="%s?moduleimpl_id=%s" % (REQUEST.URL0, moduleimpl_id), filename="absmodule_" + scu.make_filename(M["module"]["titre"]), caption="Absences dans le module %s" % M["module"]["titre"], - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) if format != "html": @@ -1197,7 +1195,7 @@ def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="htm ), base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id), caption="Tous les enseignants (responsables ou associés aux modules de ce semestre) apparaissent. Le nombre de saisies d'absences est le nombre d'opérations d'ajout effectuées sur ce semestre, sans tenir compte des annulations ou double saisies.", - preferences=sco_preferences.SemPreferences(context, formsemestre_id), + preferences=sco_preferences.SemPreferences(formsemestre_id), ) return T.make_page( context, page_title=title, title=title, REQUEST=REQUEST, format=format diff --git a/app/views/scolar.py b/app/views/scolar.py index 2ceed0eb..4aa596e1 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -195,9 +195,9 @@ def formsemestre_edit_preferences(context, formsemestre_id, REQUEST): or ((str(authuser) in sem["responsables"]) and sem["resp_can_edit"]) ) and (sem["etat"] == "1") if ok: - return sco_preferences.SemPreferences( - context, formsemestre_id=formsemestre_id - ).edit(REQUEST=REQUEST) + return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit( + REQUEST=REQUEST + ) else: raise AccessDenied("Modification impossible pour %s" % authuser) @@ -248,9 +248,7 @@ def showEtudLog(context, etudid, format="html", REQUEST=None): fiche de {etud['nomprenom']}
    """, - preferences=sco_preferences.SemPreferences( - context, - ), + preferences=sco_preferences.SemPreferences(), ) return tab.make_page(context, format=format, REQUEST=REQUEST) @@ -275,7 +273,7 @@ def rssnews(context, REQUEST=None): REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE) return sco_news.scolar_news_summary_rss( context, - "Nouvelles de " + sco_preferences.get_preference(context, "DeptName"), + "Nouvelles de " + sco_preferences.get_preference("DeptName"), scu.ScoURL(), ) @@ -1207,7 +1205,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit): else: A = """

    Pas d'informations d'Apogée

    """ - require_ine = sco_preferences.get_preference(context, "always_require_ine") + require_ine = sco_preferences.get_preference("always_require_ine") descr += [ ("adm_id", {"input_type": "hidden"}), diff --git a/scotests/test-all-moys.py b/scotests/test-all-moys.py index b94e6190..cc8ca5eb 100644 --- a/scotests/test-all-moys.py +++ b/scotests/test-all-moys.py @@ -27,9 +27,7 @@ for sem in sems: formsemestre_id = sem["formsemestre_id"] nt = sco_cache.NotesTableCache.get(formsemestre_id) etudids = nt.get_etudids() - use_ue_coef = sco_preferences.get_preference( - context, "use_ue_coefs", formsemestre_id - ) + use_ue_coef = sco_preferences.get_preference("use_ue_coefs", formsemestre_id) n += 1 print("%d %s (%d) use_ue_coef=%s" % (n, formsemestre_id, len(etudids), use_ue_coef)) for etudid in etudids: