removed useless context arg from preferences

This commit is contained in:
Emmanuel Viennet 2021-07-28 18:03:54 +03:00
parent 748caf8ada
commit eff9ae59bc
68 changed files with 270 additions and 465 deletions

View File

@ -135,7 +135,7 @@ def sidebar(context, REQUEST=None):
""" """
% params % params
) )
if sco_preferences.get_preference(context, "handle_billets_abs"): if sco_preferences.get_preference("handle_billets_abs"):
H.append( H.append(
"""<li> <a href="%(ScoURL)s/Absences/listeBilletsEtud?etudid=%(etudid)s">Billets</a></li>""" """<li> <a href="%(ScoURL)s/Absences/listeBilletsEtud?etudid=%(etudid)s">Billets</a></li>"""
% params % params
@ -172,11 +172,9 @@ def sidebar_dept(context, REQUEST=None):
"""Partie supérieure de la marge de gauche""" """Partie supérieure de la marge de gauche"""
infos = { infos = {
"BASE0": REQUEST.BASE0, "BASE0": REQUEST.BASE0,
"DeptIntranetTitle": sco_preferences.get_preference( "DeptIntranetTitle": sco_preferences.get_preference("DeptIntranetTitle"),
context, "DeptIntranetTitle" "DeptIntranetURL": sco_preferences.get_preference("DeptIntranetURL"),
), "DeptName": sco_preferences.get_preference("DeptName"),
"DeptIntranetURL": sco_preferences.get_preference(context, "DeptIntranetURL"),
"DeptName": sco_preferences.get_preference(context, "DeptName"),
"ScoURL": scu.ScoURL(), "ScoURL": scu.ScoURL(),
} }

View File

@ -105,7 +105,7 @@ def sendAlarm(context, subj, txt):
msg = MIMEMultipart() msg = MIMEMultipart()
subj = Header(subj, sco_utils.SCO_ENCODING) subj = Header(subj, sco_utils.SCO_ENCODING)
msg["Subject"] = subj 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["To"] = ALARM_DESTINATION
msg.epilogue = "" msg.epilogue = ""
txt = MIMEText(txt, "plain", sco_utils.SCO_ENCODING) txt = MIMEText(txt, "plain", sco_utils.SCO_ENCODING)

View File

@ -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) (nécessaire pour éviter appels récursifs de nt, qui peuvent boucler)
""" """
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
context,
"""SELECT mod.coefficient """SELECT mod.coefficient
FROM notes_modules mod, notes_moduleimpl mi, notes_moduleimpl_inscription ins FROM notes_modules mod, notes_moduleimpl mi, notes_moduleimpl_inscription ins
WHERE mod.module_id = mi.module_id 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._uecoef = {} # { ue_id : coef } cache coef manuels ue cap
self._evaluations_etats = None # liste des evaluations avec état self._evaluations_etats = None # liste des evaluations avec état
self.use_ue_coefs = sco_preferences.get_preference( self.use_ue_coefs = sco_preferences.get_preference(
context, "use_ue_coefs", formsemestre_id "use_ue_coefs", formsemestre_id
) )
# Infos sur les etudiants # Infos sur les etudiants
self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(

View File

@ -78,7 +78,7 @@ class ScoDocCursor(psycopg2.extensions.cursor):
return {} return {}
def SimpleQuery(context, query, args, cursor=None): def SimpleQuery(query, args, cursor=None):
if not cursor: if not cursor:
cnx = GetDBConnexion() cnx = GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor) cursor = cnx.cursor(cursor_factory=ScoDocCursor)
@ -87,8 +87,8 @@ def SimpleQuery(context, query, args, cursor=None):
return cursor return cursor
def SimpleDictFetch(context, query, args, cursor=None): def SimpleDictFetch(query, args, cursor=None):
cursor = SimpleQuery(context, query, args, cursor=cursor) cursor = SimpleQuery(query, args, cursor=cursor)
return cursor.dictfetchall() return cursor.dictfetchall()

View File

@ -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 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 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 "" return template_latex or ""

View File

@ -91,7 +91,7 @@ def pe_view_sem_recap(
""" """
if REQUEST and REQUEST.REQUEST_METHOD == "GET": if REQUEST and REQUEST.REQUEST_METHOD == "GET":
return _pe_view_sem_recap_form(context, formsemestre_id, REQUEST=REQUEST) 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) semBase = sco_formsemestre.get_formsemestre(context, formsemestre_id)

View File

@ -68,7 +68,7 @@ def _toboolean(x):
def is_work_saturday(context): def is_work_saturday(context):
"Vrai si le samedi est travaillé" "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): def MonthNbDays(month, year):

View File

@ -73,9 +73,7 @@ def do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust):
formsemestre_id = sem["formsemestre_id"] formsemestre_id = sem["formsemestre_id"]
else: else:
formsemestre_id = None formsemestre_id = None
prefs = sco_preferences.SemPreferences( prefs = sco_preferences.SemPreferences(formsemestre_id=sem["formsemestre_id"])
context, formsemestre_id=sem["formsemestre_id"]
)
destinations = abs_notify_get_destinations( destinations = abs_notify_get_destinations(
context, sem, prefs, etudid, date, nbabs, nbabsjust context, sem, prefs, etudid, date, nbabs, nbabsjust
@ -85,7 +83,7 @@ def do_abs_notify(context, sem, etudid, date, nbabs, nbabsjust):
return # abort return # abort
# Vérification fréquence (pour ne pas envoyer de mails trop souvent) # 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 = [] destinations_filtered = []
for email_addr in destinations: for email_addr in destinations:
nbdays_since_last_notif = user_nbdays_since_last_notif( nbdays_since_last_notif = user_nbdays_since_last_notif(
@ -120,7 +118,6 @@ def abs_notify_send(
msg["To"] = email msg["To"] = email
sco_emails.sendEmail(context, msg) sco_emails.sendEmail(context, msg)
ndb.SimpleQuery( 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)""", """insert into absences_notifications (etudid, email, nbabs, nbabsjust, formsemestre_id) values (%(etudid)s, %(email)s, %(nbabs)s, %(nbabsjust)s, %(formsemestre_id)s)""",
vars(), vars(),
cursor=cursor, 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 (nbabs - nbabs_last_notified) > abs_notify_abs_increment
""" """
abs_notify_abs_threshold = sco_preferences.get_preference( 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( 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) 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 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)""" 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: if not r:
return None return None
# s'il y a plusieurs semestres, prend le premier (rarissime et non significatif): # 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 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 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""" 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 return r

View File

@ -169,7 +169,7 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
disabled = False disabled = False
if not etud["cursem"]: if not etud["cursem"]:
require_module = sco_preferences.get_preference( require_module = sco_preferences.get_preference(
context, "abs_require_module" "abs_require_module"
) # on utilise la pref globale car pas de sem courant ) # on utilise la pref globale car pas de sem courant
if require_module: if require_module:
menu_module = """<div class="ue_warning">Pas inscrit dans un semestre courant, menu_module = """<div class="ue_warning">Pas inscrit dans un semestre courant,
@ -180,7 +180,7 @@ def SignaleAbsenceEtud(context, REQUEST=None): # etudid implied
else: else:
formsemestre_id = etud["cursem"]["formsemestre_id"] formsemestre_id = etud["cursem"]["formsemestre_id"]
require_module = sco_preferences.get_preference( require_module = sco_preferences.get_preference(
context, "abs_require_module", formsemestre_id "abs_require_module", formsemestre_id
) )
nt = sco_cache.NotesTableCache.get(formsemestre_id) nt = sco_cache.NotesTableCache.get(formsemestre_id)
ues = nt.get_ues(etudid=etudid) ues = nt.get_ues(etudid=etudid)
@ -839,9 +839,7 @@ def ListeAbsEtud(
base_url=base_url_nj, base_url=base_url_nj,
filename="abs_" + scu.make_filename(etud["nomprenom"]), filename="abs_" + scu.make_filename(etud["nomprenom"]),
caption="Absences non justifiées de %(nomprenom)s" % etud, caption="Absences non justifiées de %(nomprenom)s" % etud,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
tab_absjust = GenTable( tab_absjust = GenTable(
titles=titles, titles=titles,
@ -852,9 +850,7 @@ def ListeAbsEtud(
base_url=base_url_j, base_url=base_url_j,
filename="absjust_" + scu.make_filename(etud["nomprenom"]), filename="absjust_" + scu.make_filename(etud["nomprenom"]),
caption="Absences justifiées de %(nomprenom)s" % etud, caption="Absences justifiées de %(nomprenom)s" % etud,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
# Formats non HTML et demande d'une seule table: # Formats non HTML et demande d'une seule table:

View File

@ -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"), columns_ids=("nip", "nom", "prenom", "elt_code", "type_res", "val_A", "val_B"),
html_class="table_leftalign", html_class="table_leftalign",
html_with_td_classes=True, html_with_td_classes=True,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return T return T

View File

@ -100,7 +100,7 @@ def make_context_dict(context, sem, etud):
# copie preferences # copie preferences
# XXX devrait acceder directement à un dict de preferences, à revoir # XXX devrait acceder directement à un dict de preferences, à revoir
for name in sco_preferences.get_base_preferences(context).prefs_name: 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, ... # ajoute groupes et group_0, group_1, ...
sco_groups.etud_add_group_infos(context, etud, sem) sco_groups.etud_add_group_infos(context, etud, sem)
@ -133,7 +133,7 @@ def formsemestre_bulletinetud_dict(
if not version in scu.BULLETINS_VERSIONS: if not version in scu.BULLETINS_VERSIONS:
raise ValueError("invalid version code !") 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 nt = sco_cache.NotesTableCache.get(formsemestre_id) # > toutes notes
I = scu.DictDefault(defaultvalue="") 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). 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( 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( 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: if bul_show_abs_modules:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) 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
'<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">' '<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">'
% (modimpl["moduleimpl_id"], mod["mod_descr_txt"]) % (modimpl["moduleimpl_id"], mod["mod_descr_txt"])
) )
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id):
context, "bul_show_codemodules", formsemestre_id
):
mod["code"] = modimpl["module"]["code"] mod["code"] = modimpl["module"]["code"]
mod["code_html"] = link_mod + mod["code"] + "</a>" mod["code_html"] = link_mod + mod["code"] + "</a>"
else: else:
@ -502,9 +500,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
'<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">' '<a class="bull_link" href="moduleimpl_status?moduleimpl_id=%s" title="%s">'
% (modimpl["moduleimpl_id"], mod_descr) % (modimpl["moduleimpl_id"], mod_descr)
) )
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_codemodules", formsemestre_id):
context, "bul_show_codemodules", formsemestre_id
):
mod["code_txt"] = modimpl["module"]["code"] mod["code_txt"] = modimpl["module"]["code"]
mod["code_html"] = link_mod + mod["code_txt"] + "</a>" mod["code_html"] = link_mod + mod["code_txt"] + "</a>"
else: else:
@ -565,9 +561,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
# Evaluations incomplètes ou futures: # Evaluations incomplètes ou futures:
mod["evaluations_incompletes"] = [] mod["evaluations_incompletes"] = []
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_all_evals", formsemestre_id):
context, "bul_show_all_evals", formsemestre_id
):
complete_eval_ids = set([e["evaluation_id"] for e in evals]) complete_eval_ids = set([e["evaluation_id"] for e in evals])
all_evals = sco_evaluations.do_evaluation_list( all_evals = sco_evaluations.do_evaluation_list(
context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} 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] etud = sco_etud.get_etud_info(filled=1, REQUEST=REQUEST)[0]
etudid = etud["etudid"] etudid = etud["etudid"]
except: except:
return scu.log_unknown_etud(context, REQUEST, format=format) return scu.log_unknown_etud(REQUEST, format=format)
bulletin = do_formsemestre_bulletinetud( bulletin = do_formsemestre_bulletinetud(
context, context,
@ -848,9 +842,7 @@ def can_send_bulletin_by_mail(context, formsemestre_id, REQUEST):
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
return ( return (
sco_preferences.get_preference( sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id)
context, "bul_mail_allowed_for_all", formsemestre_id
)
or authuser.has_permission(Permission.ScoImplement) or authuser.has_permission(Permission.ScoImplement)
or str(authuser) in sem["responsables"] 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). If bul_mail_list_abs pref is true, put list of absences in mail body (text).
""" """
etud = I["etud"] etud = I["etud"]
webmaster = sco_preferences.get_preference( webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id)
context, "bul_mail_contact_addr", formsemestre_id
)
dept = scu.unescape_html( dept = scu.unescape_html(
sco_preferences.get_preference(context, "DeptName", formsemestre_id) sco_preferences.get_preference("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
) )
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: if intro_mail:
hea = intro_mail % { hea = intro_mail % {
@ -1000,7 +986,7 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr
else: else:
hea = "" 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( hea += "\n\n" + sco_abs_views.ListeAbsEtud(
context, etud["etudid"], with_evals=False, format="text" 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) subj = Header("Relevé de notes de %s" % etud["nomprenom"], scu.SCO_ENCODING)
recipients = [recipient_addr] recipients = [recipient_addr]
msg["Subject"] = subj msg["Subject"] = subj
msg["From"] = sco_preferences.get_preference( msg["From"] = sco_preferences.get_preference("email_from_addr", formsemestre_id)
context, "email_from_addr", formsemestre_id
)
msg["To"] = " ,".join(recipients) msg["To"] = " ,".join(recipients)
if copy_addr: if copy_addr:
msg["Bcc"] = copy_addr.strip() msg["Bcc"] = copy_addr.strip()

View File

@ -89,9 +89,7 @@ def bulletin_get_class_name_displayed(context, formsemestre_id):
"""Le nom du générateur utilisé, en clair""" """Le nom du générateur utilisé, en clair"""
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
bul_class_name = sco_preferences.get_preference( bul_class_name = sco_preferences.get_preference("bul_class_name", formsemestre_id)
context, "bul_class_name", formsemestre_id
)
try: try:
gen_class = bulletin_get_class(bul_class_name) gen_class = bulletin_get_class(bul_class_name)
return gen_class.description return gen_class.description
@ -127,7 +125,7 @@ class BulletinGenerator(object):
self.server_name = server_name self.server_name = server_name
# Store preferences for convenience: # Store preferences for convenience:
formsemestre_id = self.infos["formsemestre_id"] 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 self.diagnostic = None # error message if any problem
# Common PDF styles: # Common PDF styles:
# - Pour tous les champs du bulletin sauf les cellules de table: # - Pour tous les champs du bulletin sauf les cellules de table:
@ -285,9 +283,7 @@ def make_formsemestre_bulletinetud(
raise ValueError("invalid version code !") raise ValueError("invalid version code !")
formsemestre_id = infos["formsemestre_id"] formsemestre_id = infos["formsemestre_id"]
bul_class_name = sco_preferences.get_preference( bul_class_name = sco_preferences.get_preference("bul_class_name", formsemestre_id)
context, "bul_class_name", formsemestre_id
)
try: try:
gen_class = bulletin_get_class(bul_class_name) gen_class = bulletin_get_class(bul_class_name)
except: except:

View File

@ -158,8 +158,7 @@ def formsemestre_bulletinetud_published_dict(
mg = scu.fmt_note(nt.get_etud_moy_gen(etudid)) mg = scu.fmt_note(nt.get_etud_moy_gen(etudid))
if ( if (
nt.get_moduleimpls_attente() nt.get_moduleimpls_attente()
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) or sco_preferences.get_preference("bul_show_rangs", formsemestre_id) == 0
== 0
): ):
# n'affiche pas le rang sur le bulletin s'il y a des # n'affiche pas le rang sur le bulletin s'il y a des
# notes en attente dans ce semestre # notes en attente dans ce semestre
@ -254,9 +253,7 @@ def formsemestre_bulletinetud_published_dict(
m["note"][k] = scu.fmt_note(m["note"][k]) m["note"][k] = scu.fmt_note(m["note"][k])
u["module"].append(m) u["module"].append(m)
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_mod_rangs", formsemestre_id):
context, "bul_show_mod_rangs", formsemestre_id
):
m["rang"] = dict( m["rang"] = dict(
value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid] value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid]
) )
@ -293,7 +290,7 @@ def formsemestre_bulletinetud_published_dict(
# Evaluations incomplètes ou futures: # Evaluations incomplètes ou futures:
complete_eval_ids = set([e["evaluation_id"] for e in evals]) complete_eval_ids = set([e["evaluation_id"] for e in evals])
if sco_preferences.get_preference( 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( all_evals = sco_evaluations.do_evaluation_list(
context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} context, args={"moduleimpl_id": modimpl["moduleimpl_id"]}
@ -338,13 +335,13 @@ def formsemestre_bulletinetud_published_dict(
) )
# --- Absences # --- 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) nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust) d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust)
# --- Decision Jury # --- Decision Jury
if ( if (
sco_preferences.get_preference(context, "bul_show_decision", formsemestre_id) sco_preferences.get_preference("bul_show_decision", formsemestre_id)
or xml_with_decisions or xml_with_decisions
): ):
infos, dpv = sco_bulletins.etud_descr_situation_semestre( infos, dpv = sco_bulletins.etud_descr_situation_semestre(
@ -353,7 +350,7 @@ def formsemestre_bulletinetud_published_dict(
formsemestre_id, formsemestre_id,
format="xml", format="xml",
show_uevalid=sco_preferences.get_preference( 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"]) d["situation"] = scu.quote_xml_attr(infos["situation"])
@ -377,7 +374,7 @@ def formsemestre_bulletinetud_published_dict(
d["decision_ue"] = [] d["decision_ue"] = []
if decision[ if decision[
"decisions_ue" "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(): for ue_id in decision["decisions_ue"].keys():
ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0] ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0]
d["decision_ue"].append( d["decision_ue"].append(

View File

@ -88,7 +88,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
context = self.context context = self.context
bul_show_abs_modules = sco_preferences.get_preference( 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) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
@ -103,7 +103,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
H = ['<table class="notes_bulletin" style="background-color: %s;">' % bgcolor] H = ['<table class="notes_bulletin" style="background-color: %s;">' % bgcolor]
if sco_preferences.get_preference(context, "bul_show_minmax", formsemestre_id): if sco_preferences.get_preference("bul_show_minmax", formsemestre_id):
minmax = ( minmax = (
'<span class="bul_minmax" title="[min, max] promo">[%s, %s]</span>' '<span class="bul_minmax" title="[min, max] promo">[%s, %s]</span>'
% (I["moy_min"], I["moy_max"]) % (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 continue # saute les modules où on n'est pas inscrit
H.append('<tr class="notes_bulletin_row_mod%s">' % rowstyle) H.append('<tr class="notes_bulletin_row_mod%s">' % rowstyle)
if sco_preferences.get_preference( if sco_preferences.get_preference(
context, "bul_show_minmax_mod", formsemestre_id "bul_show_minmax_mod", formsemestre_id
): ):
rang_minmax = '%s <span class="bul_minmax" title="[min, max] UE">[%s, %s]</span>' % ( rang_minmax = '%s <span class="bul_minmax" title="[min, max] UE">[%s, %s]</span>' % (
mod["mod_rang_txt"], mod["mod_rang_txt"],
@ -178,7 +178,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
plusminus = minuslink # plusminus = minuslink #
if ue["ue_status"]["is_capitalized"]: if ue["ue_status"]["is_capitalized"]:
if sco_preferences.get_preference( if sco_preferences.get_preference(
context, "bul_show_ue_cap_details", formsemestre_id "bul_show_ue_cap_details", formsemestre_id
): ):
plusminus = minuslink plusminus = minuslink
hide = "" hide = ""
@ -209,9 +209,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
) )
H.append('<tr class="notes_bulletin_row_ue">') H.append('<tr class="notes_bulletin_row_ue">')
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_minmax", formsemestre_id):
context, "bul_show_minmax", formsemestre_id
):
moy_txt = ( moy_txt = (
'%s <span class="bul_minmax" title="[min, max] UE">[%s, %s]</span>' '%s <span class="bul_minmax" title="[min, max] UE">[%s, %s]</span>'
% ( % (
@ -448,10 +446,10 @@ def _bulletin_pdf_table_legacy(context, I, version="long"):
P = [] # elems pour gen. pdf P = [] # elems pour gen. pdf
formsemestre_id = I["formsemestre_id"] formsemestre_id = I["formsemestre_id"]
bul_show_abs_modules = sco_preferences.get_preference( 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 = ' <font size="8">[%s, %s]</font>' % (I["moy_min"], I["moy_max"]) minmax = ' <font size="8">[%s, %s]</font>' % (I["moy_min"], I["moy_max"])
else: else:
minmax = "" minmax = ""
@ -473,9 +471,7 @@ def _bulletin_pdf_table_legacy(context, I, version="long"):
if mod["mod_moy_txt"] == "NI": if mod["mod_moy_txt"] == "NI":
continue # saute les modules où on n'est pas inscrit continue # saute les modules où on n'est pas inscrit
S.modline(ue_type=ue_type) S.modline(ue_type=ue_type)
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_minmax_mod", formsemestre_id):
context, "bul_show_minmax_mod", formsemestre_id
):
rang_minmax = '%s <font size="8">[%s, %s]</font>' % ( rang_minmax = '%s <font size="8">[%s, %s]</font>' % (
mod["mod_rang_txt"], mod["mod_rang_txt"],
scu.fmt_note(mod["stats"]["min"]), 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)" ue_descr = "(en cours, non prise en compte)"
S.ueline() S.ueline()
if sco_preferences.get_preference( 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"]) list_modules(ue["modules_capitalized"])
ue_type = "cur" 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 <font size="8">[%s, %s]</font>' % ( moy_txt = '%s <font size="8">[%s, %s]</font>' % (
ue["cur_moy_ue_txt"], ue["cur_moy_ue_txt"],
ue["min"], ue["min"],

View File

@ -86,10 +86,10 @@ def pdfassemblebulletins(
return "" return ""
# Paramètres de mise en page # Paramètres de mise en page
margins = ( margins = (
sco_preferences.get_preference(context, "left_margin", formsemestre_id), sco_preferences.get_preference("left_margin", formsemestre_id),
sco_preferences.get_preference(context, "top_margin", formsemestre_id), sco_preferences.get_preference("top_margin", formsemestre_id),
sco_preferences.get_preference(context, "right_margin", formsemestre_id), sco_preferences.get_preference("right_margin", formsemestre_id),
sco_preferences.get_preference(context, "bottom_margin", formsemestre_id), sco_preferences.get_preference("bottom_margin", formsemestre_id),
) )
report = StringIO.StringIO() # in-memory document, no disk file report = StringIO.StringIO() # in-memory document, no disk file
@ -105,7 +105,7 @@ def pdfassemblebulletins(
margins=margins, margins=margins,
pagesbookmarks=pagesbookmarks, pagesbookmarks=pagesbookmarks,
filigranne=filigranne, filigranne=filigranne,
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
) )
) )
document.build(objects) document.build(objects)
@ -194,9 +194,7 @@ def get_formsemestre_bulletins_pdf(
bookmarks[i] = scu.suppress_accents(nt.get_sexnom(etudid)) bookmarks[i] = scu.suppress_accents(nt.get_sexnom(etudid))
i = i + 1 i = i + 1
# #
infos = { infos = {"DeptName": sco_preferences.get_preference("DeptName", formsemestre_id)}
"DeptName": sco_preferences.get_preference(context, "DeptName", formsemestre_id)
}
if REQUEST: if REQUEST:
server_name = REQUEST.BASE0 server_name = REQUEST.BASE0
else: else:
@ -248,7 +246,7 @@ def get_etud_bulletins_pdf(context, etudid, REQUEST, version="selectedevals"):
filigrannes[i] = filigranne filigrannes[i] = filigranne
bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015 bookmarks[i] = sem["session_id"] # eg RT-DUT-FI-S1-2015
i = i + 1 i = i + 1
infos = {"DeptName": sco_preferences.get_preference(context, "DeptName")} infos = {"DeptName": sco_preferences.get_preference("DeptName")}
if REQUEST: if REQUEST:
server_name = REQUEST.BASE0 server_name = REQUEST.BASE0
else: else:

View File

@ -278,7 +278,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
context = self.context context = self.context
P = [] # elems pour générer table avec gen_table (liste de dicts) P = [] # elems pour générer table avec gen_table (liste de dicts)
formsemestre_id = I["formsemestre_id"] formsemestre_id = I["formsemestre_id"]
prefs = sco_preferences.SemPreferences(context, formsemestre_id) prefs = sco_preferences.SemPreferences(formsemestre_id)
# Colonnes à afficher: # Colonnes à afficher:
with_col_abs = prefs["bul_show_abs_modules"] with_col_abs = prefs["bul_show_abs_modules"]

View File

@ -72,7 +72,7 @@ class BulletinGeneratorUCAC(sco_bulletins_standard.BulletinGeneratorStandard):
I = self.infos I = self.infos
context = self.context context = self.context
formsemestre_id = I["formsemestre_id"] 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) 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: # --- UE capitalisée:
if ue["ue_status"]["is_capitalized"]: if ue["ue_status"]["is_capitalized"]:
if sco_preferences.get_preference( 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"]) nb_modules = len(ue["modules_capitalized"])
hidden = False hidden = False

View File

@ -151,8 +151,7 @@ def make_xml_formsemestre_bulletinetud(
mg = scu.fmt_note(nt.get_etud_moy_gen(etudid)) mg = scu.fmt_note(nt.get_etud_moy_gen(etudid))
if ( if (
nt.get_moduleimpls_attente() nt.get_moduleimpls_attente()
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) or sco_preferences.get_preference("bul_show_rangs", formsemestre_id) == 0
== 0
): ):
# n'affiche pas le rang sur le bulletin s'il y a des # n'affiche pas le rang sur le bulletin s'il y a des
# notes en attente dans ce semestre # notes en attente dans ce semestre
@ -255,9 +254,7 @@ def make_xml_formsemestre_bulletinetud(
moy=scu.fmt_note(modstat["moy"]), moy=scu.fmt_note(modstat["moy"]),
) )
) )
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_show_mod_rangs", formsemestre_id):
context, "bul_show_mod_rangs", formsemestre_id
):
x_mod.append( x_mod.append(
Element( Element(
"rang", "rang",
@ -298,7 +295,7 @@ def make_xml_formsemestre_bulletinetud(
# Evaluations incomplètes ou futures: # Evaluations incomplètes ou futures:
complete_eval_ids = set([e["evaluation_id"] for e in evals]) complete_eval_ids = set([e["evaluation_id"] for e in evals])
if sco_preferences.get_preference( 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( all_evals = sco_evaluations.do_evaluation_list(
context, args={"moduleimpl_id": modimpl["moduleimpl_id"]} context, args={"moduleimpl_id": modimpl["moduleimpl_id"]}
@ -349,12 +346,12 @@ def make_xml_formsemestre_bulletinetud(
) )
# --- Absences # --- 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) nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
doc.append(Element("absences", nbabs=nbabs, nbabsjust=nbabsjust)) doc.append(Element("absences", nbabs=nbabs, nbabsjust=nbabsjust))
# --- Decision Jury # --- Decision Jury
if ( if (
sco_preferences.get_preference(context, "bul_show_decision", formsemestre_id) sco_preferences.get_preference("bul_show_decision", formsemestre_id)
or xml_with_decisions or xml_with_decisions
): ):
infos, dpv = sco_bulletins.etud_descr_situation_semestre( infos, dpv = sco_bulletins.etud_descr_situation_semestre(
@ -363,7 +360,7 @@ def make_xml_formsemestre_bulletinetud(
formsemestre_id, formsemestre_id,
format="xml", format="xml",
show_uevalid=sco_preferences.get_preference( show_uevalid=sco_preferences.get_preference(
context, "bul_show_uevalid", formsemestre_id "bul_show_uevalid", formsemestre_id
), ),
) )
x_situation = Element("situation") x_situation = Element("situation")
@ -395,7 +392,7 @@ def make_xml_formsemestre_bulletinetud(
if decision[ if decision[
"decisions_ue" "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(): for ue_id in decision["decisions_ue"].keys():
ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0] ue = sco_edit_ue.do_ue_list(context, {"ue_id": ue_id})[0]
doc.append( doc.append(

View File

@ -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; WHERE s.formsemestre_id = %(formsemestre_id)s and s.formsemestre_id=m.formsemestre_id and e.moduleimpl_id=m.moduleimpl_id;
""" """
evaluation_ids = [ evaluation_ids = [
x[0] x[0] for x in ndb.SimpleQuery(req, {"formsemestre_id": formsemestre_id})
for x in ndb.SimpleQuery(None, req, {"formsemestre_id": formsemestre_id})
] ]
cls.delete_many(evaluation_ids) cls.delete_many(evaluation_ids)
@ -142,9 +141,7 @@ class EvaluationCache(ScoDocCache):
"delete all evaluations from cache" "delete all evaluations from cache"
evaluation_ids = [ evaluation_ids = [
x[0] x[0]
for x in ndb.SimpleQuery( for x in ndb.SimpleQuery("SELECT evaluation_id FROM notes_evaluation", "")
None, "SELECT evaluation_id FROM notes_evaluation", ""
)
] ]
cls.delete_many(evaluation_ids) cls.delete_many(evaluation_ids)
@ -224,7 +221,8 @@ class NotesTableCache(ScoDocCache):
from app.scodoc import notes_table from app.scodoc import notes_table
t0 = time.time() 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 dt = time.time() - t0
log("caching formsemestre_id=%s (%gs)" % (formsemestre_id, dt)) log("caching formsemestre_id=%s (%gs)" % (formsemestre_id, dt))
_ = cls.set(formsemestre_id, nt) _ = cls.set(formsemestre_id, nt)
@ -247,7 +245,7 @@ def invalidate_formsemestre( # was inval_cache( context, formsemestre_id=None,
formsemestre_ids = [ formsemestre_ids = [
x[0] x[0]
for x in ndb.SimpleQuery( for x in ndb.SimpleQuery(
None, "SELECT formsemestre_id FROM notes_formsemestre", "" "SELECT formsemestre_id FROM notes_formsemestre", ""
) )
] ]
else: else:

View File

@ -121,7 +121,7 @@ def formsemestre_table_estim_cost(
), ),
rows=T, rows=T,
html_sortable=True, html_sortable=True,
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
html_class="table_leftalign table_listegroupe", html_class="table_leftalign table_listegroupe",
xls_before_table=[ xls_before_table=[
["%(titre)s %(num_sem)s %(modalitestr)s" % sem], ["%(titre)s %(num_sem)s %(modalitestr)s" % sem],

View File

@ -82,7 +82,7 @@ def get_etudids_with_debouche(context, start_year):
start_date = str(start_year) + "-01-01" start_date = str(start_year) + "-01-01"
# Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre # Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre
# posterieur à la date de depart: # posterieur à la date de depart:
# r = ndb.SimpleDictFetch(context, # r = ndb.SimpleDictFetch(
# """SELECT DISTINCT i.etudid # """SELECT DISTINCT i.etudid
# FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s # FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s
# WHERE adm.debouche is not NULL # WHERE adm.debouche is not NULL
@ -92,7 +92,6 @@ def get_etudids_with_debouche(context, start_year):
# {'start_date' : start_date }) # {'start_date' : start_date })
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT DISTINCT i.etudid """SELECT DISTINCT i.etudid
FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it
WHERE i.etudid = it.etudid WHERE i.etudid = it.etudid
@ -189,9 +188,7 @@ def table_debouche_etudids(context, etudids, keep_numeric=True):
# html_col_width='4em', # html_col_width='4em',
html_sortable=True, html_sortable=True,
html_class="table_leftalign table_listegroupe", html_class="table_leftalign table_listegroupe",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab return tab
@ -338,7 +335,6 @@ def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None):
def itemsuivi_tag_list(context, itemsuivi_id): def itemsuivi_tag_list(context, itemsuivi_id):
"""les noms de tags associés à cet item""" """les noms de tags associés à cet item"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT t.title """SELECT t.title
FROM itemsuivi_tags_assoc a, itemsuivi_tags t FROM itemsuivi_tags_assoc a, itemsuivi_tags t
WHERE a.tag_id = t.tag_id WHERE a.tag_id = t.tag_id
@ -356,7 +352,6 @@ def itemsuivi_tag_search(context, term, REQUEST=None):
data = [] data = []
else: else:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s", "SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s",
{"term": term + "%"}, {"term": term + "%"},
) )

View File

@ -125,7 +125,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
"""<hr/> """<hr/>
<h2>Semestres de %s</h2> <h2>Semestres de %s</h2>
""" """
% sco_preferences.get_preference(context, "DeptName") % sco_preferences.get_preference("DeptName")
) )
H.append(_sem_table_gt(context, sems).html()) H.append(_sem_table_gt(context, sems).html())
H.append("</table>") H.append("</table>")
@ -250,9 +250,7 @@ def _sem_table_gt(context, sems, showcodes=False):
html_sortable=True, html_sortable=True,
# base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id), # base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id),
# caption='Maquettes enregistrées', # caption='Maquettes enregistrées',
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab return tab

View File

@ -70,7 +70,7 @@ def sco_dump_and_send_db(context, REQUEST=None):
html_sco_header.sco_header(context, REQUEST, page_title="Assistance technique") html_sco_header.sco_header(context, REQUEST, page_title="Assistance technique")
] ]
# get currect (dept) DB name: # get currect (dept) DB name:
cursor = ndb.SimpleQuery(context, "SELECT current_database()", {}) cursor = ndb.SimpleQuery("SELECT current_database()", {})
db_name = cursor.fetchone()[0] db_name = cursor.fetchone()[0]
ano_db_name = "ANO" + db_name ano_db_name = "ANO" + db_name
# Lock # Lock
@ -190,7 +190,7 @@ def _send_db(context, REQUEST, ano_db_name):
scu.SCO_DUMP_UP_URL, scu.SCO_DUMP_UP_URL,
files=files, files=files,
data={ data={
"dept_name": sco_preferences.get_preference(context, "DeptName"), "dept_name": sco_preferences.get_preference("DeptName"),
"serial": _get_scodoc_serial(context), "serial": _get_scodoc_serial(context),
"sco_user": str(REQUEST.AUTHENTICATED_USER), "sco_user": str(REQUEST.AUTHENTICATED_USER),
"sent_by": sco_users.user_info(str(REQUEST.AUTHENTICATED_USER))[ "sent_by": sco_users.user_info(str(REQUEST.AUTHENTICATED_USER))[

View File

@ -314,7 +314,6 @@ associé.
if tf[2]["ue_id"] != F["ue_id"]: if tf[2]["ue_id"] != F["ue_id"]:
log("attaching mat %s to new UE %s" % (matiere_id, tf[2]["ue_id"])) log("attaching mat %s to new UE %s" % (matiere_id, tf[2]["ue_id"]))
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"UPDATE notes_modules SET ue_id = %(ue_id)s WHERE matiere_id=%(matiere_id)s", "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}, {"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) (contains modules used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT ma.* from notes_matieres ma, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """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 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 AND ma.matiere_id = %(matiere_id)s AND sem.etat = 0

View File

@ -359,7 +359,6 @@ def module_edit(context, module_id=None, REQUEST=None):
)[0] )[0]
parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"]) parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"])
M = ndb.SimpleDictFetch( 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", "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"]}, {"formation_id": Mod["formation_id"]},
) )
@ -571,7 +570,6 @@ def module_is_locked(context, module_id):
(used in a locked formsemestre) (used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT mi.* from notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """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 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 AND mi.module_id = %(module_id)s AND sem.etat = 0

View File

@ -144,7 +144,6 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
if delete_validations: if delete_validations:
log("deleting all validations of UE %s" % ue_id) log("deleting all validations of UE %s" % ue_id)
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s", "DELETE FROM scolar_formsemestre_validation WHERE ue_id=%(ue_id)s",
{"ue_id": ue_id}, {"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) sco_edit_matiere.do_matiere_delete(context, mat["matiere_id"], REQUEST)
# delete uecoef and events # delete uecoef and events
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM notes_formsemestre_uecoef WHERE ue_id=%(ue_id)s", "DELETE FROM notes_formsemestre_uecoef WHERE ue_id=%(ue_id)s",
{"ue_id": ue_id}, {"ue_id": ue_id},
) )
ndb.SimpleQuery( ndb.SimpleQuery("DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id})
context, "DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}
)
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
_ueEditor.delete(cnx, ue_id) _ueEditor.delete(cnx, ue_id)
# > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?): # > 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) (contains modules used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT ue.* FROM notes_ue ue, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """SELECT ue.* FROM notes_ue ue, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi
WHERE ue.ue_id = mod.ue_id WHERE ue.ue_id = mod.ue_id
AND mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_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, page_title=title,
html_title="<h2>" + title + "</h2>", html_title="<h2>" + title + "</h2>",
pdf_title=title, pdf_title=title,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab.make_page(context, format=format, REQUEST=REQUEST) return tab.make_page(context, format=format, REQUEST=REQUEST)

View File

@ -55,7 +55,7 @@ def formsemestre_get_ics_url(context, sem):
https://example.fr/agenda/{sem[etapes][0]} https://example.fr/agenda/{sem[etapes][0]}
""" """
ics_url_tmpl = sco_preferences.get_preference( 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: if not ics_url_tmpl:
return None return None
@ -102,7 +102,7 @@ def get_edt_transcodage_groups(context, formsemestre_id):
edt2sco = {} edt2sco = {}
sco2edt = {} sco2edt = {}
msg = "" # message erreur, '' si ok 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: if not txt:
return edt2sco, sco2edt, msg return edt2sco, sco2edt, msg

View File

@ -82,9 +82,7 @@ def apo_semset_maq_status(
block_export_res_modules = int(block_export_res_modules) block_export_res_modules = int(block_export_res_modules)
block_export_res_sdj = int(block_export_res_sdj) block_export_res_sdj = int(block_export_res_sdj)
prefs = sco_preferences.SemPreferences( prefs = sco_preferences.SemPreferences()
context,
)
tab_archives = table_apo_csv_list(context, semset, REQUEST=REQUEST) 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, html_sortable=True,
# base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id), # base_url = '%s?formsemestre_id=%s' % (REQUEST.URL0, formsemestre_id),
# caption='Maquettes enregistrées', # caption='Maquettes enregistrées',
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab return tab
@ -597,9 +593,7 @@ def _view_etuds_page(
html_sortable=True, html_sortable=True,
html_class="table_leftalign", html_class="table_leftalign",
filename="students_apo", filename="students_apo",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
if format != "html": if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST) 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), base_url="%s?etape_apo=%s&semset_id=%s" % (REQUEST.URL0, etape_apo, semset_id),
filename="students_" + etape_apo, filename="students_" + etape_apo,
caption="Etudiants Apogée en " + etape_apo, caption="Etudiants Apogée en " + etape_apo,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
if format != "html": 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 # 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 # 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 # Les fichiers résultats ne sont pas stockés: pas besoin de permission particulière
prefs = sco_preferences.SemPreferences( prefs = sco_preferences.SemPreferences()
context,
)
export_res_etape = prefs["export_res_etape"] and not int(block_export_res_etape) 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_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) export_res_ues = prefs["export_res_ues"] and not int(block_export_res_ues)
@ -866,7 +856,7 @@ def apo_csv_export_results(
) )
basename = ( basename = (
sco_preferences.get_preference(context, "DeptName") sco_preferences.get_preference("DeptName")
+ str(annee_scolaire) + str(annee_scolaire)
+ "-%s-" % periode + "-%s-" % periode
+ "-".join(etapes_apo) + "-".join(etapes_apo)

View File

@ -377,9 +377,7 @@ def identite_edit(cnx, args, context=None, REQUEST=None):
notify_to = None notify_to = None
if context: if context:
try: try:
notify_to = sco_preferences.get_preference( notify_to = sco_preferences.get_preference("notify_etud_changes_to")
context, "notify_etud_changes_to"
)
except: except:
pass pass
@ -446,7 +444,7 @@ def notify_etud_change(context, email_addr, etud, before, after, subject):
msg = MIMEMultipart() msg = MIMEMultipart()
subj = Header("[ScoDoc] " + subject, SCO_ENCODING) subj = Header("[ScoDoc] " + subject, SCO_ENCODING)
msg["Subject"] = subj 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 msg["To"] = email_addr
mime_txt = MIMEText(txt, "plain", SCO_ENCODING) mime_txt = MIMEText(txt, "plain", SCO_ENCODING)
msg.attach(mime_txt) msg.attach(mime_txt)
@ -492,9 +490,7 @@ def adresse_edit(cnx, args, context=None):
notify_to = None notify_to = None
if context: if context:
try: try:
notify_to = sco_preferences.get_preference( notify_to = sco_preferences.get_preference("notify_etud_changes_to")
context, "notify_etud_changes_to"
)
except: except:
pass pass
if notify_to: if notify_to:

View File

@ -930,7 +930,7 @@ def formsemestre_evaluations_delai_correction(
html_sortable=True, html_sortable=True,
html_title="<h2>Correction des évaluations du semestre</h2>", html_title="<h2>Correction des évaluations du semestre</h2>",
caption="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), base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "", origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]), filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]),

View File

@ -571,7 +571,7 @@ def Excel_feuille_listeappel(
( (
"%s %s (%s - %s)" "%s %s (%s - %s)"
% ( % (
sco_preferences.get_preference(context, "DeptName", formsemestre_id), sco_preferences.get_preference("DeptName", formsemestre_id),
notesdb.unquote(sem["titre_num"]), notesdb.unquote(sem["titre_num"]),
sem["date_debut"], sem["date_debut"],
sem["date_fin"], sem["date_fin"],

View File

@ -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() + "", origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
html_class="table_leftalign", html_class="table_leftalign",
html_sortable=True, html_sortable=True,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab, semlist 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): def get_set_formsemestre_id_dates(context, start_date, end_date):
"""Ensemble des formsemestre_id entre ces dates""" """Ensemble des formsemestre_id entre ces dates"""
s = ndb.SimpleDictFetch( s = ndb.SimpleDictFetch(
context,
"SELECT formsemestre_id FROM notes_formsemestre WHERE date_debut >= %(start_date)s AND date_fin <= %(end_date)s", "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}, {"start_date": start_date, "end_date": end_date},
) )

View File

@ -166,9 +166,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None):
rows=etuds, rows=etuds,
html_sortable=True, html_sortable=True,
html_class="table_leftalign", html_class="table_leftalign",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
H.append(tab.html()) H.append(tab.html())
if len(etuds) > 20: # si la page est grande if len(etuds) > 20: # si la page est grande
@ -224,7 +222,6 @@ def search_etud_by_name(context, term, REQUEST=None):
else: else:
if may_be_nip: if may_be_nip:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT nom, prenom, code_nip FROM identite WHERE code_nip LIKE %(beginning)s ORDER BY nom", "SELECT nom, prenom, code_nip FROM identite WHERE code_nip LIKE %(beginning)s ORDER BY nom",
{"beginning": term + "%"}, {"beginning": term + "%"},
) )
@ -238,7 +235,6 @@ def search_etud_by_name(context, term, REQUEST=None):
] ]
else: else:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT etudid, nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom", "SELECT etudid, nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom",
{"beginning": term + "%"}, {"beginning": term + "%"},
) )
@ -257,20 +253,6 @@ def search_etud_by_name(context, term, REQUEST=None):
# ---------- Recherche sur plusieurs département # ---------- 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 """<form action="table_etud_in_accessible_depts" method="POST">
<b>Chercher étudiant:</b>
<input type="text" name="expnom" width="12" spellcheck="false" value="">
<input type="submit" value="Chercher">
<br/>(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): def search_etud_in_accessible_depts(expnom=None, code_nip=None):
""" """
result is a list of (sorted) etuds, one list per dept. 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: 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 code_nip, nom, prenom, civilite_str, dept, formsemestre_id, date_debut_sem, date_fin_sem
""" """
result, _ = search_etud_in_accessible_depts( result, _ = search_etud_in_accessible_depts(code_nip=code_nip)
context, code_nip=code_nip, REQUEST=REQUEST
)
T = [] T = []
for etuds in result: for etuds in result:

View File

@ -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), base_url="%s?formation_id=%s" % (REQUEST.URL0, formation_id),
page_title=title, page_title=title,
pdf_title=title, pdf_title=title,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )

View File

@ -277,7 +277,6 @@ def read_formsemestre_responsables(context, formsemestre_id):
:returns: liste de chaines :returns: liste de chaines
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT responsable_id FROM notes_formsemestre_responsables WHERE formsemestre_id = %(formsemestre_id)s", "SELECT responsable_id FROM notes_formsemestre_responsables WHERE formsemestre_id = %(formsemestre_id)s",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
@ -340,7 +339,6 @@ def read_formsemestre_etapes(context, formsemestre_id):
:returns: liste d'instance de ApoEtapeVDI :returns: liste d'instance de ApoEtapeVDI
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT etape_apo FROM notes_formsemestre_etapes WHERE formsemestre_id = %(formsemestre_id)s", "SELECT etape_apo FROM notes_formsemestre_etapes WHERE formsemestre_id = %(formsemestre_id)s",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
@ -518,13 +516,9 @@ def table_formsemestres(
"etapes_apo_str": "Apo.", "etapes_apo_str": "Apo.",
} }
if sems: if sems:
preferences = sco_preferences.SemPreferences( preferences = sco_preferences.SemPreferences(sems[0]["formsemestre_id"])
context, sems[0]["formsemestre_id"]
)
else: else:
preferences = sco_preferences.SemPreferences( preferences = sco_preferences.SemPreferences()
context,
)
tab = GenTable( tab = GenTable(
columns_ids=columns_ids, columns_ids=columns_ids,
rows=sems, rows=sems,

View File

@ -412,7 +412,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
"title": "Element(s) Apogée:", "title": "Element(s) Apogée:",
"explanation": "du semestre (ex: VRTW1). Séparés par des virgules.", "explanation": "du semestre (ex: VRTW1). Séparés par des virgules.",
"allow_null": not sco_preferences.get_preference( "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:", "title": "Element(s) Apogée:",
"explanation": "de l'année (ex: VRT1A). Séparés par des virgules.", "explanation": "de l'année (ex: VRT1A). Séparés par des virgules.",
"allow_null": not sco_preferences.get_preference( "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 # check dates
if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]): if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]):
msg = '<ul class="tf-msg"><li class="tf-msg">Dates de début et fin incompatibles !</li></ul>' msg = '<ul class="tf-msg"><li class="tf-msg">Dates de début et fin incompatibles !</li></ul>'
if sco_preferences.get_preference( if sco_preferences.get_preference("always_require_apo_sem_codes") and not any(
context, "always_require_apo_sem_codes"
) and not any(
[tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)] [tf[2]["etape_apo" + str(n)] for n in range(0, scu.EDIT_NB_ETAPES + 1)]
): ):
msg = '<ul class="tf-msg"><li class="tf-msg">Code étape Apogée manquant</li></ul>' msg = '<ul class="tf-msg"><li class="tf-msg">Code étape Apogée manquant</li></ul>'
@ -1085,7 +1083,7 @@ def do_formsemestre_clone(
# NB: don't copy notes_formsemestre_custommenu (usually specific) # NB: don't copy notes_formsemestre_custommenu (usually specific)
# 4- Copy new style preferences # 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: if orig_formsemestre_id in prefs.base_prefs.prefs:
for pname in prefs.base_prefs.prefs[orig_formsemestre_id]: 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. ou bien compensation de ce semestre par d'autre ssemestres.
""" """
r = ndb.SimpleDictFetch( 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", "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}, {"formsemestre_id": formsemestre_id},
) )
@ -1386,17 +1383,14 @@ def do_formsemestre_delete(context, formsemestre_id, REQUEST):
) )
for e in evals: for e in evals:
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM notes_notes WHERE evaluation_id=%(evaluation_id)s", "DELETE FROM notes_notes WHERE evaluation_id=%(evaluation_id)s",
e, e,
) )
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM notes_notes_log WHERE evaluation_id=%(evaluation_id)s", "DELETE FROM notes_notes_log WHERE evaluation_id=%(evaluation_id)s",
e, e,
) )
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM notes_evaluation WHERE evaluation_id=%(evaluation_id)s", "DELETE FROM notes_evaluation WHERE evaluation_id=%(evaluation_id)s",
e, e,
) )
@ -1468,7 +1462,7 @@ def formsemestre_edit_options(context, formsemestre_id, target_url=None, REQUEST
) )
if not ok: if not ok:
return err return err
return sco_preferences.SemPreferences(context, formsemestre_id).edit( return sco_preferences.SemPreferences(formsemestre_id).edit(
REQUEST=REQUEST, categories=["bul"] 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']) # parcours = sco_codes_parcours.get_parcours_from_code(F['type_parcours'])
ImputationDept = sco_preferences.get_preference( ImputationDept = sco_preferences.get_preference(
context, "ImputationDept", sem["formsemestre_id"] "ImputationDept", sem["formsemestre_id"]
) )
if not ImputationDept: if not ImputationDept:
ImputationDept = sco_preferences.get_preference(context, "DeptName") ImputationDept = sco_preferences.get_preference("DeptName")
ImputationDept = ImputationDept.upper() ImputationDept = ImputationDept.upper()
parcours_type = parcours.NAME parcours_type = parcours.NAME
modalite = sem["modalite"] modalite = sem["modalite"]

View File

@ -286,7 +286,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
"endpoint": "notes.formsemestre_synchro_etuds", "endpoint": "notes.formsemestre_synchro_etuds",
"args": {"formsemestre_id": formsemestre_id}, "args": {"formsemestre_id": formsemestre_id},
"enabled": authuser.has_permission(Permission.ScoView) "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"), and (sem["etat"] == "1"),
}, },
{ {
@ -314,7 +314,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
"endpoint": "scolar.formsemestre_import_etud_admission", "endpoint": "scolar.formsemestre_import_etud_admission",
"args": {"formsemestre_id": formsemestre_id}, "args": {"formsemestre_id": formsemestre_id},
"enabled": authuser.has_permission(Permission.ScoEtudChangeAdr) "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", "title": "Exporter table des étudiants",
@ -564,9 +564,7 @@ def fill_formsemestre(context, sem, REQUEST=None):
) )
else: else:
sem["locklink"] = "" sem["locklink"] = ""
if sco_preferences.get_preference( if sco_preferences.get_preference("bul_display_publication", formsemestre_id):
context, "bul_display_publication", formsemestre_id
):
if sem["bul_hide_xml"] != "0": if sem["bul_hide_xml"] != "0":
eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés") eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés")
else: else:
@ -615,9 +613,7 @@ def formsemestre_description_table(
""" """
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations
use_ue_coefs = sco_preferences.get_preference( use_ue_coefs = sco_preferences.get_preference("use_ue_coefs", formsemestre_id)
context, "use_ue_coefs", formsemestre_id
)
F = sco_formations.formation_list( F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]} context, args={"formation_id": sem["formation_id"]}
)[0] )[0]
@ -702,7 +698,7 @@ def formsemestre_description_table(
sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef} sums = {"_css_row_class": "moyenne sortbottom", "ects": sum_ects, "Coef.": sum_coef}
R.append(sums) R.append(sums)
columns_ids = ["UE", "Code", "Module", "Coef."] 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 += ["ects"]
columns_ids += ["Inscrits", "Responsable", "Enseignants"] columns_ids += ["Inscrits", "Responsable", "Enseignants"]
if with_evals: if with_evals:
@ -739,7 +735,7 @@ def formsemestre_description_table(
context, REQUEST, "Description du semestre", sem, with_page_header=False context, REQUEST, "Description du semestre", sem, with_page_header=False
), ),
pdf_title=title, 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( H.append(
'<p class="fontorange"><em>Attention: ce semestre couvre plusieurs années scolaires !</em></p>' '<p class="fontorange"><em>Attention: ce semestre couvre plusieurs années scolaires !</em></p>'
) )
# elif sco_preferences.get_preference(context, 'bul_display_publication', formsemestre_id): # elif sco_preferences.get_preference( 'bul_display_publication', formsemestre_id):
# H.append('<p><em>Bulletins publiés sur le portail</em></p>') # H.append('<p><em>Bulletins publiés sur le portail</em></p>')
return "".join(H) return "".join(H)
@ -1081,7 +1077,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
prev_ue_id = ue["ue_id"] prev_ue_id = ue["ue_id"]
acronyme = ue["acronyme"] acronyme = ue["acronyme"]
titre = ue["titre"] 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 += " <b>(coef. %s)</b>" % (ue["coefficient"] or 0.0) titre += " <b>(coef. %s)</b>" % (ue["coefficient"] or 0.0)
H.append( H.append(
"""<tr class="formsemestre_status_ue"><td colspan="4"> """<tr class="formsemestre_status_ue"><td colspan="4">
@ -1192,7 +1188,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
H.append("</td></tr>") H.append("</td></tr>")
H.append("</table></p>") H.append("</table></p>")
if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id): if sco_preferences.get_preference("use_ue_coefs", formsemestre_id):
H.append( H.append(
""" """
<p class="infop">utilise les coefficients d'UE pour calculer la moyenne générale.</p> <p class="infop">utilise les coefficients d'UE pour calculer la moyenne générale.</p>

View File

@ -664,9 +664,7 @@ def formsemestre_recap_parcours_table(
H.append("</tr>") H.append("</tr>")
# 3eme ligne: ECTS # 3eme ligne: ECTS
if ( if (
sco_preferences.get_preference( sco_preferences.get_preference("bul_show_ects", sem["formsemestre_id"])
context, "bul_show_ects", sem["formsemestre_id"]
)
or nt.parcours.ECTS_ONLY or nt.parcours.ECTS_ONLY
): ):
etud_moy_infos = nt.get_etud_moy_infos(etudid) 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): def _invalidate_etud_formation_caches(context, etudid, formation_id):
"Invalide tous les semestres de cette formation où l'etudiant est inscrit..." "Invalide tous les semestres de cette formation où l'etudiant est inscrit..."
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT sem.* """SELECT sem.*
FROM notes_formsemestre sem, notes_formsemestre_inscription i FROM notes_formsemestre sem, notes_formsemestre_inscription i
WHERE sem.formation_id = %(formation_id)s 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): 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""" """Ramene bout de HTML pour pouvoir supprimer une validation de cette UE"""
valids = ndb.SimpleDictFetch( valids = ndb.SimpleDictFetch(
context,
"""SELECT SFV.* FROM scolar_formsemestre_validation SFV """SELECT SFV.* FROM scolar_formsemestre_validation SFV
WHERE ue_id=%(ue_id)s AND etudid=%(etudid)s""", WHERE ue_id=%(ue_id)s AND etudid=%(etudid)s""",
{"etudid": etudid, "ue_id": ue_id}, {"etudid": etudid, "ue_id": ue_id},
@ -1253,7 +1249,6 @@ def check_formation_ues(context, formation_id):
for ue in ues: for ue in ues:
# formsemestres utilisant cette ue ? # formsemestres utilisant cette ue ?
sems = ndb.SimpleDictFetch( sems = ndb.SimpleDictFetch(
context,
"""SELECT DISTINCT sem.* """SELECT DISTINCT sem.*
FROM notes_formsemestre sem, notes_modules mod, notes_moduleimpl mi FROM notes_formsemestre sem, notes_modules mod, notes_moduleimpl mi
WHERE sem.formation_id = %(formation_id)s WHERE sem.formation_id = %(formation_id)s

View File

@ -95,7 +95,6 @@ group_list = groupEditor.list
def get_group(context, group_id): def get_group(context, group_id):
"""Returns group object, with partition""" """Returns group object, with partition"""
r = ndb.SimpleDictFetch( 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", "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}, {"group_id": group_id},
) )
@ -109,18 +108,13 @@ def group_delete(context, group, force=False):
# if not group['group_name'] and not force: # if not group['group_name'] and not force:
# raise ValueError('cannot suppress this group') # raise ValueError('cannot suppress this group')
# remove memberships: # remove memberships:
ndb.SimpleQuery( ndb.SimpleQuery("DELETE FROM group_membership WHERE group_id=%(group_id)s", group)
context, "DELETE FROM group_membership WHERE group_id=%(group_id)s", group
)
# delete group: # delete group:
ndb.SimpleQuery( ndb.SimpleQuery("DELETE FROM group_descr WHERE group_id=%(group_id)s", group)
context, "DELETE FROM group_descr WHERE group_id=%(group_id)s", group
)
def get_partition(context, partition_id): def get_partition(context, partition_id):
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT p.* FROM partition p WHERE p.partition_id = %(partition_id)s", "SELECT p.* FROM partition p WHERE p.partition_id = %(partition_id)s",
{"partition_id": partition_id}, {"partition_id": partition_id},
) )
@ -132,7 +126,6 @@ def get_partition(context, partition_id):
def get_partitions_list(context, formsemestre_id, with_default=True): def get_partitions_list(context, formsemestre_id, with_default=True):
"""Liste des partitions pour ce semestre (list of dicts)""" """Liste des partitions pour ce semestre (list of dicts)"""
partitions = ndb.SimpleDictFetch( partitions = ndb.SimpleDictFetch(
context,
"SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s order by numero", "SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s order by numero",
{"formsemestre_id": formsemestre_id}, {"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): def get_default_partition(context, formsemestre_id):
"""Get partition for 'all' students (this one always exists, with NULL name)""" """Get partition for 'all' students (this one always exists, with NULL name)"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s AND partition_name is NULL", "SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s AND partition_name is NULL",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
@ -174,7 +166,6 @@ def get_partition_groups(context, partition):
"""List of groups in this partition (list of dicts). """List of groups in this partition (list of dicts).
Some groups may be empty.""" Some groups may be empty."""
return ndb.SimpleDictFetch( 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", "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, partition,
) )
@ -183,7 +174,6 @@ def get_partition_groups(context, partition):
def get_default_group(context, formsemestre_id, fix_if_missing=False, REQUEST=None): def get_default_group(context, formsemestre_id, fix_if_missing=False, REQUEST=None):
"""Returns group_id for default ('tous') group""" """Returns group_id for default ('tous') group"""
r = ndb.SimpleDictFetch( 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", "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}, {"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): def get_sem_groups(context, formsemestre_id):
"""Returns groups for this sem (in all partitions).""" """Returns groups for this sem (in all partitions)."""
return ndb.SimpleDictFetch( 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", "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}, {"formsemestre_id": formsemestre_id},
) )
@ -230,7 +219,7 @@ def get_group_members(context, group_id, etat=None):
if etat is not None: if etat is not None:
req += " and ins.etat = %(etat)s" 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: for etud in r:
sco_etud.format_etud_ident(etud) sco_etud.format_etud_ident(etud)
@ -329,7 +318,6 @@ def get_etud_groups(context, etudid, sem, exclude_default=False):
if exclude_default: if exclude_default:
req += " and p.partition_name is not NULL" req += " and p.partition_name is not NULL"
groups = ndb.SimpleDictFetch( groups = ndb.SimpleDictFetch(
context,
req + " ORDER BY p.numero", req + " ORDER BY p.numero",
{"etudid": etudid, "formsemestre_id": sem["formsemestre_id"]}, {"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) { etudid : { partition_id : group_name }} (attr=group_name or group_id)
""" """
infos = ndb.SimpleDictFetch( 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", "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}, {"formsemestre_id": formsemestre_id},
) )
@ -380,7 +367,6 @@ def etud_add_group_infos(context, etud, sem, sep=" "):
return etud return etud
infos = ndb.SimpleDictFetch( 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", "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"]}, {"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): def get_etud_groups_in_partition(context, partition_id):
"""Returns { etudid : group }, with all students in this partition""" """Returns { etudid : group }, with all students in this partition"""
infos = ndb.SimpleDictFetch( 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", "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}, {"partition_id": partition_id},
) )
@ -535,7 +520,6 @@ def set_group(context, etudid, group_id):
args = {"etudid": etudid, "group_id": group_id} args = {"etudid": etudid, "group_id": group_id}
# déjà inscrit ? # déjà inscrit ?
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT * FROM group_membership gm WHERE etudid=%(etudid)s and group_id=%(group_id)s", "SELECT * FROM group_membership gm WHERE etudid=%(etudid)s and group_id=%(group_id)s",
args, args,
cursor=cursor, cursor=cursor,
@ -544,7 +528,6 @@ def set_group(context, etudid, group_id):
return False return False
# inscrit # inscrit
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"INSERT INTO group_membership (etudid, group_id) VALUES (%(etudid)s, %(group_id)s)", "INSERT INTO group_membership (etudid, group_id) VALUES (%(etudid)s, %(group_id)s)",
args, args,
cursor=cursor, cursor=cursor,
@ -571,7 +554,6 @@ def change_etud_group_in_partition(
partition = get_partition(context, group["partition_id"]) partition = get_partition(context, group["partition_id"])
# 1- Supprime membership dans cette partition # 1- Supprime membership dans cette partition
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"""DELETE FROM group_membership WHERE group_membership_id IN """DELETE FROM group_membership WHERE group_membership_id IN
(SELECT gm.group_membership_id (SELECT gm.group_membership_id
FROM group_membership gm, group_descr gd FROM group_membership gm, group_descr gd
@ -660,7 +642,6 @@ def setGroups(
for etudid in old_members_set: for etudid in old_members_set:
log("removing %s from group %s" % (etudid, group_id)) log("removing %s from group %s" % (etudid, group_id))
ndb.SimpleQuery( ndb.SimpleQuery(
context,
"DELETE FROM group_membership WHERE etudid=%(etudid)s and group_id=%(group_id)s", "DELETE FROM group_membership WHERE etudid=%(etudid)s and group_id=%(group_id)s",
{"etudid": etudid, "group_id": group_id}, {"etudid": etudid, "group_id": group_id},
cursor=cursor, cursor=cursor,
@ -1097,7 +1078,6 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi
# check unicity # check unicity
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT p.* FROM partition p WHERE p.partition_name = %(partition_name)s AND formsemestre_id = %(formsemestre_id)s", "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}, {"partition_name": partition_name, "formsemestre_id": formsemestre_id},
) )

View File

@ -589,7 +589,7 @@ def groups_table(
else: else:
filename = "etudiants_%s" % groups_infos.groups_filename 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( tab = GenTable(
rows=groups_infos.members, rows=groups_infos.members,
columns_ids=columns_ids, columns_ids=columns_ids,
@ -995,7 +995,7 @@ def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None):
elts.append(group_name) elts.append(group_name)
T.append({"email": etud["email"], "semestre_groupe": "-".join(elts)}) T.append({"email": etud["email"], "semestre_groupe": "-".join(elts)})
# Make table # Make table
prefs = sco_preferences.SemPreferences(context, formsemestre_id) prefs = sco_preferences.SemPreferences(formsemestre_id)
tab = GenTable( tab = GenTable(
rows=T, rows=T,
columns_ids=("email", "semestre_groupe"), columns_ids=("email", "semestre_groupe"),

View File

@ -269,7 +269,7 @@ def scolars_import_excel_file(
cnx = ndb.GetDBConnexion(autocommit=False) cnx = ndb.GetDBConnexion(autocommit=False)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
annee_courante = time.localtime()[0] 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() exceldata = datafile.read()
if not exceldata: if not exceldata:
raise ScoValueError("Ficher excel vide ou invalide") raise ScoValueError("Ficher excel vide ou invalide")
@ -822,8 +822,6 @@ def adm_table_description_format(context):
rows=list(Fmt.values()), rows=list(Fmt.values()),
html_sortable=True, html_sortable=True,
html_class="table_leftalign", html_class="table_leftalign",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab return tab

View File

@ -225,7 +225,7 @@ Pour plus d'informations sur ce logiciel, voir %s
msg["Subject"] = Header("Mot de passe ScoDoc", scu.SCO_ENCODING) msg["Subject"] = Header("Mot de passe ScoDoc", scu.SCO_ENCODING)
else: else:
msg["Subject"] = Header("Votre accès ScoDoc", scu.SCO_ENCODING) 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["To"] = u["email"]
msg.epilogue = "" msg.epilogue = ""
txt = MIMEText(txt, "plain", scu.SCO_ENCODING) txt = MIMEText(txt, "plain", scu.SCO_ENCODING)

View File

@ -643,8 +643,6 @@ def etuds_select_box_xls(context, src_cat):
columns_ids=columns_ids, columns_ids=columns_ids,
rows=etuds, rows=etuds,
caption="%(title)s. %(help)s" % src_cat["infos"], caption="%(title)s. %(help)s" % src_cat["infos"],
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab.excel() return tab.excel()

View File

@ -314,9 +314,9 @@ def _make_table_notes(
grc = inscr["etat"] grc = inscr["etat"]
code = "" # code pour listings anonyme, à la place du nom 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"] 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"] code = etud["code_nip"]
if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid
code = etudid code = etudid
@ -485,7 +485,7 @@ def _make_table_notes(
html_title=html_title, html_title=html_title,
pdf_title=pdf_title, pdf_title=pdf_title,
html_class="table_leftalign notes_evaluation", 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 # html_generate_cells=False # la derniere ligne (moyennes) est incomplete
) )

View File

@ -59,7 +59,7 @@ def formsemestre_table_etuds_lycees(
etuds, etuds,
group_lycees, group_lycees,
title, 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, etuds,
False, False,
"Lycées de TOUS les étudiants", "Lycées de TOUS les étudiants",
sco_preferences.SemPreferences( sco_preferences.SemPreferences(),
context,
),
no_links=True, no_links=True,
) )
tab.base_url = REQUEST.URL0 tab.base_url = REQUEST.URL0

View File

@ -521,7 +521,6 @@ def is_inscrit_ue(context, etudid, formsemestre_id, ue_id):
auxquels l'étudiant est inscrit. auxquels l'étudiant est inscrit.
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT mod.* """SELECT mod.*
FROM notes_moduleimpl mi, notes_modules mod, FROM notes_moduleimpl mi, notes_modules mod,
notes_formsemestre sem, notes_moduleimpl_inscription i notes_formsemestre sem, notes_moduleimpl_inscription i

View File

@ -260,7 +260,7 @@ def _send_news_by_mail(context, n):
"""Notify by email""" """Notify by email"""
infos = _get_formsemestre_infos_from_news(context, n) infos = _get_formsemestre_infos_from_news(context, n)
formsemestre_id = infos.get("formsemestre_id", None) 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 = prefs["emails_notifications"] or ""
destinations = [x.strip() for x in destinations.split(",")] destinations = [x.strip() for x in destinations.split(",")]
destinations = [x for x in destinations if x] destinations = [x for x in destinations if x]

View File

@ -352,7 +352,7 @@ def copy_portal_photo_to_fs(context, etud, REQUEST=None):
url = photo_portal_url(context, etud) url = photo_portal_url(context, etud)
if not url: if not url:
return None, "%(nomprenom)s: pas de code NIP" % etud 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 f = None
try: try:
log("copy_portal_photo_to_fs: getting %s" % url) log("copy_portal_photo_to_fs: getting %s" % url)

View File

@ -392,7 +392,7 @@ def do_placement(context, REQUEST):
+ "", + "",
pdf_title=pdf_title, pdf_title=pdf_title,
# pdf_shorttitle = '', # 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 # html_generate_cells=False # la derniere ligne (moyennes) est incomplete
) )
t = tab.make_page( t = tab.make_page(

View File

@ -56,7 +56,7 @@ class PortalInterface(object):
def get_portal_url(self, context): def get_portal_url(self, context):
"URL of portal" "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 not self.warning:
if portal_url: if portal_url:
log("Portal URL=%s" % portal_url) log("Portal URL=%s" % portal_url)
@ -67,7 +67,7 @@ class PortalInterface(object):
def get_etapes_url(self, context): def get_etapes_url(self, context):
"Full URL of service giving list of etapes (in XML)" "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: if not etapes_url:
# Default: # Default:
portal_url = self.get_portal_url(context) portal_url = self.get_portal_url(context)
@ -82,7 +82,7 @@ class PortalInterface(object):
def get_etud_url(self, context): def get_etud_url(self, context):
"Full URL of service giving list of students (in XML)" "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: if not etud_url:
# Default: # Default:
portal_url = self.get_portal_url(context) portal_url = self.get_portal_url(context)
@ -97,7 +97,7 @@ class PortalInterface(object):
def get_photo_url(self, context): def get_photo_url(self, context):
"Full URL of service giving photo of student" "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: if not photo_url:
# Default: # Default:
portal_url = self.get_portal_url(context) portal_url = self.get_portal_url(context)
@ -112,7 +112,7 @@ class PortalInterface(object):
def get_maquette_url(self, context): def get_maquette_url(self, context):
"""Full URL of service giving Apogee maquette pour une étape (fichier "CSV")""" """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: if not maquette_url:
# Default: # Default:
portal_url = self.get_portal_url(context) portal_url = self.get_portal_url(context)
@ -123,7 +123,7 @@ class PortalInterface(object):
def get_portal_api_version(self, context): def get_portal_api_version(self, context):
"API version of the portal software" "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: if not api_ver:
# Default: # Default:
api_ver = 1 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) api_ver = get_portal_api_version(context)
if not etud_url: if not etud_url:
return [] return []
portal_timeout = sco_preferences.get_preference(context, "portal_timeout") portal_timeout = sco_preferences.get_preference("portal_timeout")
if api_ver > 1: if api_ver > 1:
req = ( req = (
etud_url etud_url
@ -208,7 +208,7 @@ def query_apogee_portal(context, **args):
# Ne fonctionne pas avec l'API 2 sur nom et prenom # 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 # XXX TODO : va poser problème pour la page modif données étudiants : A VOIR
return [] 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())) req = etud_url + "?" + six.moves.urllib.parse.urlencode(list(args.items()))
doc = scu.query_portal(req, timeout=portal_timeout) # sco_utils doc = scu.query_portal(req, timeout=portal_timeout) # sco_utils
return xml_to_list_of_dicts(doc, req=req) 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) etud_url = get_etud_url(context)
if not etud_url: if not etud_url:
return {} 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),)) req = etud_url + "?" + six.moves.urllib.parse.urlencode((("nip", code_nip),))
doc = scu.query_portal(req, timeout=portal_timeout) doc = scu.query_portal(req, timeout=portal_timeout)
d = _normalize_apo_fields(xml_to_list_of_dicts(doc, req=req)) 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 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 # parser XML
dom = xml.dom.minidom.parseString(doc) dom = xml.dom.minidom.parseString(doc)
infos = {} infos = {}
@ -382,7 +382,7 @@ def get_etapes_apogee(context):
etapes_url = get_etapes_url(context) etapes_url = get_etapes_url(context)
infos = {} infos = {}
if etapes_url: if etapes_url:
portal_timeout = sco_preferences.get_preference(context, "portal_timeout") portal_timeout = sco_preferences.get_preference("portal_timeout")
log( log(
"get_etapes_apogee: requesting '%s' with timeout=%s" "get_etapes_apogee: requesting '%s' with timeout=%s"
% (etapes_url, portal_timeout) % (etapes_url, portal_timeout)
@ -430,9 +430,9 @@ def get_etapes_apogee_dept(context):
Returns [ ( code, intitule) ], ordonnée 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: 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) log('get_etapes_apogee_dept: portal_dept_name="%s"' % portal_dept_name)
else: else:
portal_dept_name = "" portal_dept_name = ""
@ -556,7 +556,7 @@ def get_maquette_apogee(context, etape="", annee_scolaire=""):
maquette_url = get_maquette_url(context) maquette_url = get_maquette_url(context)
if not maquette_url: if not maquette_url:
return None return None
portal_timeout = sco_preferences.get_preference(context, "portal_timeout") portal_timeout = sco_preferences.get_preference("portal_timeout")
req = ( req = (
maquette_url maquette_url
+ "?" + "?"

View File

@ -206,7 +206,7 @@ def formsemestre_poursuite_report(
html_sortable=True, html_sortable=True,
html_class="table_leftalign table_listegroupe", html_class="table_leftalign table_listegroupe",
pdf_link=False, # pas d'export pdf 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"]) tab.filename = scu.make_filename("poursuite " + sem["titreannee"])

View File

@ -68,18 +68,18 @@ des tuples (name, value, formsemestre_id).
Si formsemestre_id est NULL, la valeur concerne tous les semestres, Si formsemestre_id est NULL, la valeur concerne tous les semestres,
sinon, elle ne concerne que le semestre indiqué. sinon, elle ne concerne que le semestre indiqué.
* Utilisation dans ScoDoc7 * Utilisation dans ScoDoc8
- lire une valeur: - lire une valeur:
get_preference(context, name, formsemestre_id) get_preference(name, formsemestre_id)
nb: les valeurs sont des chaines, sauf: nb: les valeurs sont des chaines, sauf:
. si le type est spécfié (float ou int) . si le type est spécfié (float ou int)
. les boolcheckbox qui sont des entiers 0 ou 1 . les boolcheckbox qui sont des entiers 0 ou 1
- avoir un mapping (read only) de toutes les valeurs: - avoir un mapping (read only) de toutes les valeurs:
sco_preferences.SemPreferences(context,formsemestre_id) sco_preferences.SemPreferences(formsemestre_id)
- editer les preferences globales: - editer les preferences globales:
sco_preferences.get_base_preferences(self).edit(REQUEST=REQUEST) sco_preferences.get_base_preferences(self).edit(REQUEST=REQUEST)
- editer les preferences d'un semestre: - editer les preferences d'un semestre:
SemPreferences(context,formsemestre_id).edit() SemPreferences(formsemestre_id).edit()
* Implémentation: sco_preferences.py * Implémentation: sco_preferences.py
@ -98,7 +98,7 @@ Une instance unique par site (département, repéré par URL).
.deleteformsemestre_id, name) .deleteformsemestre_id, name)
.edit() (HTML dialog) .edit() (HTML dialog)
class SemPreferences(context,formsemestre_id) class SemPreferences(formsemestre_id)
Une instance par semestre, et une instance pour prefs globales. Une instance par semestre, et une instance pour prefs globales.
L'attribut .base_prefs point sur BasePreferences. L'attribut .base_prefs point sur BasePreferences.
.__getitem__ [name] .__getitem__ [name]
@ -106,8 +106,8 @@ L'attribut .base_prefs point sur BasePreferences.
.edit(categories=[]) .edit(categories=[])
get_base_preferences(context, formsemestre_id) get_base_preferences(formsemestre_id)
Return base preferences for this context (instance BasePreferences) Return base preferences for current scodoc_dept (instance BasePreferences)
""" """
from flask import g from flask import g
@ -122,20 +122,20 @@ import app.scodoc.sco_utils as scu
_SCO_BASE_PREFERENCES = {} # { URL: BasePreferences instance } _SCO_BASE_PREFERENCES = {} # { URL: BasePreferences instance }
def get_base_preferences(context): def get_base_preferences():
"""Return global preferences for the current department""" """Return global preferences for the current department"""
dept = g.scodoc_dept dept = g.scodoc_dept
if not dept in _SCO_BASE_PREFERENCES: if not dept in _SCO_BASE_PREFERENCES:
_SCO_BASE_PREFERENCES[dept] = BasePreferences(context) _SCO_BASE_PREFERENCES[dept] = BasePreferences()
return _SCO_BASE_PREFERENCES[dept] 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. """Returns value of named preference.
All preferences have a sensible default value, so this All preferences have a sensible default value, so this
function always returns a usable value for all defined preferences names. 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 = ( PREF_CATEGORIES = (
@ -205,8 +205,7 @@ class BasePreferences(object):
filter_nulls=False, filter_nulls=False,
) )
def __init__(self, context): def __init__(self):
self.context = context
self.init() self.init()
self.load() self.load()
@ -1957,8 +1956,9 @@ class BasePreferences(object):
"""HTML dialog: edit global preferences""" """HTML dialog: edit global preferences"""
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
context = None # XXX TO REMOVE #context
H = [ 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"),
"<h2>Préférences globales pour %s</h2>" % scu.ScoURL(), "<h2>Préférences globales pour %s</h2>" % scu.ScoURL(),
"""<p class="help">Ces paramètres s'appliquent par défaut à tous les semestres, sauf si ceux-ci définissent des valeurs spécifiques.</p> """<p class="help">Ces paramètres s'appliquent par défaut à tous les semestres, sauf si ceux-ci définissent des valeurs spécifiques.</p>
<p class="msg">Attention: cliquez sur "Enregistrer les modifications" en bas de page pour appliquer vos changements !</p> <p class="msg">Attention: cliquez sur "Enregistrer les modifications" en bas de page pour appliquer vos changements !</p>
@ -1973,9 +1973,7 @@ class BasePreferences(object):
submitlabel="Enregistrer les modifications", submitlabel="Enregistrer les modifications",
) )
if tf[0] == 0: if tf[0] == 0:
return ( return "\n".join(H) + tf[1] + html_sco_header.sco_footer(context, REQUEST)
"\n".join(H) + tf[1] + html_sco_header.sco_footer(self.context, REQUEST)
)
elif tf[0] == -1: elif tf[0] == -1:
return REQUEST.RESPONSE.redirect(scu.ScoURL()) # cancel return REQUEST.RESPONSE.redirect(scu.ScoURL()) # cancel
else: else:
@ -2058,10 +2056,9 @@ class BasePreferences(object):
class SemPreferences(object): class SemPreferences(object):
"""Preferences for a formsemestre""" """Preferences for a formsemestre"""
def __init__(self, context, formsemestre_id=None): def __init__(self, formsemestre_id=None):
self.context = context
self.formsemestre_id = formsemestre_id self.formsemestre_id = formsemestre_id
self.base_prefs = get_base_preferences(self.context) self.base_prefs = get_base_preferences()
def __getitem__(self, name): def __getitem__(self, name):
return self.base_prefs.get(self.formsemestre_id, name) return self.base_prefs.get(self.formsemestre_id, name)
@ -2091,10 +2088,11 @@ class SemPreferences(object):
raise ScoValueError( raise ScoValueError(
"sem_preferences.edit doit etre appele sur un semestre !" "sem_preferences.edit doit etre appele sur un semestre !"
) # a bug ! ) # 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 = [ H = [
html_sco_header.html_sem_header( html_sco_header.html_sem_header(
self.context, REQUEST, "Préférences du semestre", sem context, REQUEST, "Préférences du semestre", sem
), ),
""" """
<p class="help">Les paramètres définis ici ne s'appliqueront qu'à ce semestre.</p> <p class="help">Les paramètres définis ici ne s'appliqueront qu'à ce semestre.</p>
@ -2149,10 +2147,9 @@ function set_global_pref(el, pref_name) {
scu.NotesURL() scu.NotesURL()
+ "/formsemestre_status?formsemestre_id=%s" % self.formsemestre_id + "/formsemestre_status?formsemestre_id=%s" % self.formsemestre_id
) )
context = None # XXX TO REMOVE
if tf[0] == 0: if tf[0] == 0:
return ( return "\n".join(H) + tf[1] + html_sco_header.sco_footer(context, REQUEST)
"\n".join(H) + tf[1] + html_sco_header.sco_footer(self.context, REQUEST)
)
elif tf[0] == -1: elif tf[0] == -1:
return REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
dest_url + "&head_message=Annulé" 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""" """ Liste les preferences en MarkDown, pour la documentation"""
L = [] L = []
for cat, cat_descr in PREF_CATEGORIES: for cat, cat_descr in PREF_CATEGORIES:
@ -2211,7 +2208,7 @@ def doc_preferences(context):
L.append([""]) L.append([""])
L.append(["Nom", "&nbsp;", "&nbsp;"]) L.append(["Nom", "&nbsp;", "&nbsp;"])
L.append(["----", "----", "----"]) 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: if pref["category"] == cat:
L.append( L.append(
["`" + pref_name + "`", pref["title"], pref.get("explanation", "")] ["`" + pref_name + "`", pref["title"], pref.get("explanation", "")]

View File

@ -158,9 +158,9 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
L.append([]) # empty line L.append([]) # empty line
titles = ["Rang"] titles = ["Rang"]
if sco_preferences.get_preference(context, "prepa_jury_nip"): if sco_preferences.get_preference("prepa_jury_nip"):
titles.append("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.append("INE")
titles += [ titles += [
"etudid", "etudid",
@ -220,9 +220,9 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
for etudid in etudids: for etudid in etudids:
etud = nt.identdict[etudid] etud = nt.identdict[etudid]
l = [str(i)] 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"]) 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.append(etud["code_ine"])
l += [ l += [
etudid, etudid,

View File

@ -419,10 +419,10 @@ def pvjury_table(
columns_ids += ["prev_decision"] columns_ids += ["prev_decision"]
columns_ids += ["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 += ["mention"]
columns_ids += ["ue_cap"] 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"] columns_ids += ["ects"]
# XXX if not dpv["semestre_non_terminal"]: # XXX if not dpv["semestre_non_terminal"]:
@ -459,13 +459,13 @@ def pvjury_table(
if with_paragraph_nom: if with_paragraph_nom:
cell_style = styles.ParagraphStyle({}) cell_style = styles.ParagraphStyle({})
cell_style.fontSize = sco_preferences.get_preference( 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( 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( cell_style.leading = 1.0 * sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id "SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space ) # vertical space
i = e["identite"] i = e["identite"]
l["nomprenom"] = [ l["nomprenom"] = [
@ -540,7 +540,7 @@ def formsemestre_pvjury(
caption="Décisions jury pour " + sem["titreannee"], caption="Décisions jury pour " + sem["titreannee"],
html_class="table_leftalign", html_class="table_leftalign",
html_sortable=True, html_sortable=True,
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
) )
if format != "html": if format != "html":
return tab.make_page( return tab.make_page(
@ -602,7 +602,7 @@ def formsemestre_pvjury(
columns_ids=("code", "count", "expl"), columns_ids=("code", "count", "expl"),
html_class="table_leftalign", html_class="table_leftalign",
html_sortable=True, html_sortable=True,
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
).html() ).html()
) )
H.append("<p></p>") # force space at bottom H.append("<p></p>") # force space at bottom

View File

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

View File

@ -85,9 +85,7 @@ def formsemestre_recapcomplet(
) # cache les colonnes des modules ) # cache les colonnes des modules
pref_override = int(pref_override) pref_override = int(pref_override)
if pref_override: if pref_override:
hidebac = int( hidebac = int(sco_preferences.get_preference("recap_hidebac", formsemestre_id))
sco_preferences.get_preference(context, "recap_hidebac", formsemestre_id)
)
else: else:
hidebac = int(hidebac) hidebac = int(hidebac)
xml_with_decisions = int(xml_with_decisions) xml_with_decisions = int(xml_with_decisions)
@ -188,7 +186,7 @@ def formsemestre_recapcomplet(
% formsemestre_id % formsemestre_id
) )
H.append("</p>") H.append("</p>")
if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id): if sco_preferences.get_preference("use_ue_coefs", formsemestre_id):
H.append( H.append(
""" """
<p class="infop">utilise les coefficients d'UE pour calculer la moyenne générale.</p> <p class="infop">utilise les coefficients d'UE pour calculer la moyenne générale.</p>
@ -497,9 +495,7 @@ def make_formsemestre_recapcomplet(
if key == "nb_valid_evals": if key == "nb_valid_evals":
l.append("") l.append("")
elif key == "coef": elif key == "coef":
if sco_preferences.get_preference( if sco_preferences.get_preference("use_ue_coefs", formsemestre_id):
context, "use_ue_coefs", formsemestre_id
):
l.append("%2.3f" % ue["coefficient"]) l.append("%2.3f" % ue["coefficient"])
else: else:
l.append("") l.append("")

View File

@ -202,7 +202,7 @@ def _results_by_category(
bottom_titles=bottom_titles, bottom_titles=bottom_titles,
html_col_width="4em", html_col_width="4em",
html_sortable=True, 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, caption="Suivi cohorte " + pp + sem["titreannee"] + dbac,
page_title="Suivi cohorte " + sem["titreannee"], page_title="Suivi cohorte " + sem["titreannee"],
html_class="table_cohorte", 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 # Explication: liste des semestres associés à chaque date
if not P: if not P:
@ -1168,7 +1168,7 @@ def table_suivi_parcours(
"nb": len(etuds), "nb": len(etuds),
"codeparcours": len(etuds), "codeparcours": len(etuds),
}, },
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
) )
return tab return tab

View File

@ -86,7 +86,6 @@ class SemSet(dict):
self["annee_scolaire"] = L[0]["annee_scolaire"] self["annee_scolaire"] = L[0]["annee_scolaire"]
self["sem_id"] = L[0]["sem_id"] self["sem_id"] = L[0]["sem_id"]
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT formsemestre_id FROM notes_semset_formsemestre WHERE semset_id = %(semset_id)s", "SELECT formsemestre_id FROM notes_semset_formsemestre WHERE semset_id = %(semset_id)s",
{"semset_id": semset_id}, {"semset_id": semset_id},
) )
@ -460,9 +459,7 @@ def semset_page(context, format="html", REQUEST=None):
html_sortable=True, html_sortable=True,
html_class="table_leftalign", html_class="table_leftalign",
filename="semsets", filename="semsets",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
if format != "html": if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST) return tab.make_page(context, format=format, REQUEST=REQUEST)

View File

@ -73,7 +73,6 @@ class ScoTag(object):
if not self.title: if not self.title:
raise ScoValueError("invalid empty tag") raise ScoValueError("invalid empty tag")
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT * FROM " + self.tag_table + " WHERE title = %(title)s", "SELECT * FROM " + self.tag_table + " WHERE title = %(title)s",
{"title": self.title}, {"title": self.title},
) )
@ -87,7 +86,6 @@ class ScoTag(object):
cnx, self.tag_table, {"title": self.title}, commit=True cnx, self.tag_table, {"title": self.title}, commit=True
) )
self.tag_id = ndb.SimpleDictFetch( self.tag_id = ndb.SimpleDictFetch(
context,
"SELECT tag_id FROM " + self.tag_table + " WHERE oid=%(oid)s", "SELECT tag_id FROM " + self.tag_table + " WHERE oid=%(oid)s",
{"oid": oid}, {"oid": oid},
)[0]["tag_id"] )[0]["tag_id"]
@ -206,7 +204,6 @@ def module_tag_search(context, term, REQUEST=None):
data = [] data = []
else: else:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"SELECT title FROM notes_tags WHERE title LIKE %(term)s", "SELECT title FROM notes_tags WHERE title LIKE %(term)s",
{"term": term + "%"}, {"term": term + "%"},
) )
@ -218,7 +215,6 @@ def module_tag_search(context, term, REQUEST=None):
def module_tag_list(context, module_id=""): def module_tag_list(context, module_id=""):
"""les noms de tags associés à ce module""" """les noms de tags associés à ce module"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
"""SELECT t.title """SELECT t.title
FROM notes_modules_tags mt, notes_tags t FROM notes_modules_tags mt, notes_tags t
WHERE mt.tag_id = t.tag_id WHERE mt.tag_id = t.tag_id

View File

@ -391,7 +391,7 @@ def _trombino_pdf(context, groups_infos, REQUEST):
sco_pdf.ScolarsPageTemplate( sco_pdf.ScolarsPageTemplate(
document, document,
context=context, context=context,
preferences=sco_preferences.SemPreferences(context, sem["formsemestre_id"]), preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
) )
) )
document.build(objects) document.build(objects)
@ -468,7 +468,7 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST):
sco_pdf.ScolarsPageTemplate( sco_pdf.ScolarsPageTemplate(
document, document,
context, context,
preferences=sco_preferences.SemPreferences(context, sem["formsemestre_id"]), preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
) )
) )
document.build(objects) document.build(objects)

View File

@ -65,10 +65,10 @@ def pdf_trombino_tours(
context, group_ids, formsemestre_id=formsemestre_id, REQUEST=REQUEST context, group_ids, formsemestre_id=formsemestre_id, REQUEST=REQUEST
) )
DeptName = sco_preferences.get_preference(context, "DeptName") DeptName = sco_preferences.get_preference("DeptName")
DeptFullName = sco_preferences.get_preference(context, "DeptFullName") DeptFullName = sco_preferences.get_preference("DeptFullName")
UnivName = sco_preferences.get_preference(context, "UnivName") UnivName = sco_preferences.get_preference("UnivName")
InstituteName = sco_preferences.get_preference(context, "InstituteName") InstituteName = sco_preferences.get_preference("InstituteName")
# Generate PDF page # Generate PDF page
StyleSheet = styles.getSampleStyleSheet() StyleSheet = styles.getSampleStyleSheet()
objects = [] objects = []
@ -272,9 +272,7 @@ def pdf_trombino_tours(
ScolarsPageTemplate( ScolarsPageTemplate(
document, document,
context=context, context=context,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
) )
document.build(objects) document.build(objects)
@ -294,10 +292,10 @@ def pdf_feuille_releve_absences(
): ):
"""Generation de la feuille d'absence en fichier PDF, avec photos""" """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_AM = sco_preferences.get_preference("feuille_releve_abs_AM")
NB_CELL_PM = sco_preferences.get_preference(context, "feuille_releve_abs_PM") NB_CELL_PM = sco_preferences.get_preference("feuille_releve_abs_PM")
COLWIDTH = 0.85 * cm 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 days = sco_abs.DAYNAMES[:6] # Lundi, ..., Samedi
else: else:
days = sco_abs.DAYNAMES[:5] # Lundi, ..., Vendredi 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 context, group_ids, formsemestre_id=formsemestre_id, REQUEST=REQUEST
) )
DeptName = sco_preferences.get_preference(context, "DeptName") DeptName = sco_preferences.get_preference("DeptName")
DeptFullName = sco_preferences.get_preference(context, "DeptFullName") DeptFullName = sco_preferences.get_preference("DeptFullName")
UnivName = sco_preferences.get_preference(context, "UnivName") UnivName = sco_preferences.get_preference("UnivName")
InstituteName = sco_preferences.get_preference(context, "InstituteName") InstituteName = sco_preferences.get_preference("InstituteName")
# Generate PDF page # Generate PDF page
StyleSheet = styles.getSampleStyleSheet() StyleSheet = styles.getSampleStyleSheet()
objects = [ objects = [
@ -458,14 +456,11 @@ def pdf_feuille_releve_absences(
# Build document # Build document
report = io.BytesIO() # in-memory document, no disk file report = io.BytesIO() # in-memory document, no disk file
filename = "absences-%s-%s.pdf" % (DeptName, groups_infos.groups_filename) 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 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 taille = A4
if ( if sco_preferences.get_preference("feuille_releve_abs_format") == "Paysage":
sco_preferences.get_preference(context, "feuille_releve_abs_format")
== "Paysage"
):
document = BaseDocTemplate(report, pagesize=landscape(taille)) document = BaseDocTemplate(report, pagesize=landscape(taille))
else: else:
document = BaseDocTemplate(report, pagesize=taille) document = BaseDocTemplate(report, pagesize=taille)
@ -473,9 +468,7 @@ def pdf_feuille_releve_absences(
ScolarsPageTemplate( ScolarsPageTemplate(
document, document,
context=context, context=context,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
) )
document.build(objects) document.build(objects)

View File

@ -152,7 +152,11 @@ def external_ue_inscrit_et_note(
) )
# Inscription des étudiants # Inscription des étudiants
sco_moduleimpl.do_moduleimpl_inscrit_etuds( 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à: # 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"] evaluation_id = ModEvals[0]["evaluation_id"]
else: else:
# crée une évaluation: # crée une évaluation:
evaluation_id = sco_evaluations.do_evaluation_create(context, evaluation_id = sco_evaluations.do_evaluation_create(
context,
REQUEST=REQUEST, REQUEST=REQUEST,
moduleimpl_id=moduleimpl_id, moduleimpl_id=moduleimpl_id,
note_max=20.0, 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): def get_external_moduleimpl_id(context, formsemestre_id, ue_id):
"moduleimpl correspondant à l'UE externe indiquée de ce formsemestre" "moduleimpl correspondant à l'UE externe indiquée de ce formsemestre"
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
context,
""" """
SELECT moduleimpl_id FROM notes_moduleimpl mi, notes_modules mo SELECT moduleimpl_id FROM notes_moduleimpl mi, notes_modules mo
WHERE mi.formsemestre_id = %(formsemestre_id)s WHERE mi.formsemestre_id = %(formsemestre_id)s

View File

@ -165,7 +165,7 @@ def evaluation_list_operations(context, REQUEST, evaluation_id):
html_sortable=False, html_sortable=False,
html_title="<h2>Opérations sur l'évaluation %s du %s</h2>" html_title="<h2>Opérations sur l'évaluation %s du %s</h2>"
% (E["description"], E["jour"]), % (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) 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.""" """Table listant toutes les operations de saisies de notes, dans toutes les evaluations du semestre."""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
r = ndb.SimpleDictFetch( 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""", """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}, {"formsemestre_id": formsemestre_id},
) )
@ -208,7 +207,7 @@ def formsemestre_list_saisies_notes(
html_class="table_leftalign table_coldate", html_class="table_leftalign table_coldate",
html_sortable=True, html_sortable=True,
caption="Saisies de notes dans %s" % sem["titreannee"], 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), base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "", origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
) )

View File

@ -788,7 +788,7 @@ def AnneeScolaire(REQUEST=None): # TODO remplacer REQUEST #sco8
return year 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""" """Log request: cas ou getEtudInfo n'a pas ramene de resultat"""
etudid = REQUEST.form.get("etudid", "?") etudid = REQUEST.form.get("etudid", "?")
code_nip = REQUEST.form.get("code_nip", "?") 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" "unknown student: etudid=%s code_nip=%s code_ine=%s"
% (etudid, code_nip, code_ine) % (etudid, code_nip, code_ine)
) )
return _sco_error_response( return _sco_error_response("unknown student", format=format, REQUEST=REQUEST)
context, "unknown student", format=format, REQUEST=REQUEST
)
# XXX #sco8 à tester ou ré-écrire # 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.""" """Send an error message to the client, in html or xml format."""
REQUEST.RESPONSE.setStatus(404, reason=msg) REQUEST.RESPONSE.setStatus(404, reason=msg)
if format == "html" or format == "pdf": if format == "html" or format == "pdf":

View File

@ -152,7 +152,7 @@ def index_html(context, REQUEST=None):
H.append( H.append(
"""<ul><li><a href="EtatAbsences">Afficher l'état des absences (pour tout un groupe)</a></li>""" """<ul><li><a href="EtatAbsences">Afficher l'état des absences (pour tout un groupe)</a></li>"""
) )
if sco_preferences.get_preference(context, "handle_billets_abs"): if sco_preferences.get_preference("handle_billets_abs"):
H.append( H.append(
"""<li><a href="listeBillets">Traitement des billets d'absence en attente</a></li>""" """<li><a href="listeBillets">Traitement des billets d'absence en attente</a></li>"""
) )
@ -340,7 +340,7 @@ def SignaleAbsenceGrHebdo(
formsemestre_id = groups_infos.formsemestre_id formsemestre_id = groups_infos.formsemestre_id
require_module = sco_preferences.get_preference( require_module = sco_preferences.get_preference(
context, "abs_require_module", formsemestre_id "abs_require_module", formsemestre_id
) )
etuds = [ etuds = [
sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0] sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
@ -504,7 +504,7 @@ def SignaleAbsenceGrSemestre(
) )
formsemestre_id = groups_infos.formsemestre_id formsemestre_id = groups_infos.formsemestre_id
require_module = sco_preferences.get_preference( require_module = sco_preferences.get_preference(
context, "abs_require_module", formsemestre_id "abs_require_module", formsemestre_id
) )
etuds = [ etuds = [
sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0] sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
@ -943,7 +943,7 @@ def EtatAbsencesGr(
tab = GenTable( tab = GenTable(
columns_ids=columns_ids, columns_ids=columns_ids,
rows=T, rows=T,
preferences=sco_preferences.SemPreferences(context, formsemestre_id), preferences=sco_preferences.SemPreferences(formsemestre_id),
titles={ titles={
"etatincursem": "Etat", "etatincursem": "Etat",
"nomprenom": "Nom", "nomprenom": "Nom",
@ -1106,7 +1106,7 @@ def AddBilletAbsence(
etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True etudid=etudid, code_nip=code_nip, REQUEST=REQUEST, filled=True
) )
if not etuds: if not etuds:
return scu.log_unknown_etud(context, REQUEST=REQUEST) return scu.log_unknown_etud(REQUEST=REQUEST)
etud = etuds[0] etud = etuds[0]
# check dates # check dates
begin_date = dateutil.parser.isoparse(begin) # may raises ValueError begin_date = dateutil.parser.isoparse(begin) # may raises ValueError
@ -1246,9 +1246,7 @@ def _tableBillets(context, billets, etud=None, title=""):
columns_ids=columns_ids, columns_ids=columns_ids,
page_title=title, page_title=title,
html_title="<h2>%s</h2>" % title, html_title="<h2>%s</h2>" % title,
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
rows=billets, rows=billets,
html_sortable=True, html_sortable=True,
) )
@ -1262,7 +1260,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
"""Liste billets pour un etudiant""" """Liste billets pour un etudiant"""
etuds = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST) etuds = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)
if not etuds: 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] etud = etuds[0]
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -1276,7 +1274,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
@scodoc7func(context) @scodoc7func(context)
def XMLgetBilletsEtud(context, etudid=False, REQUEST=None): def XMLgetBilletsEtud(context, etudid=False, REQUEST=None):
"""Liste billets pour un etudiant""" """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 "" return ""
t0 = time.time() t0 = time.time()
r = listeBilletsEtud(context, etudid, REQUEST=REQUEST, format="xml") r = listeBilletsEtud(context, etudid, REQUEST=REQUEST, format="xml")

View File

@ -1035,9 +1035,7 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
base_url="%s?moduleimpl_id=%s" % (REQUEST.URL0, moduleimpl_id), base_url="%s?moduleimpl_id=%s" % (REQUEST.URL0, moduleimpl_id),
filename="absmodule_" + scu.make_filename(M["module"]["titre"]), filename="absmodule_" + scu.make_filename(M["module"]["titre"]),
caption="Absences dans le module %s" % M["module"]["titre"], caption="Absences dans le module %s" % M["module"]["titre"],
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
if format != "html": 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), 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.", 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( return T.make_page(
context, page_title=title, title=title, REQUEST=REQUEST, format=format context, page_title=title, title=title, REQUEST=REQUEST, format=format

View File

@ -195,9 +195,9 @@ def formsemestre_edit_preferences(context, formsemestre_id, REQUEST):
or ((str(authuser) in sem["responsables"]) and sem["resp_can_edit"]) or ((str(authuser) in sem["responsables"]) and sem["resp_can_edit"])
) and (sem["etat"] == "1") ) and (sem["etat"] == "1")
if ok: if ok:
return sco_preferences.SemPreferences( return sco_preferences.SemPreferences(formsemestre_id=formsemestre_id).edit(
context, formsemestre_id=formsemestre_id REQUEST=REQUEST
).edit(REQUEST=REQUEST) )
else: else:
raise AccessDenied("Modification impossible pour %s" % authuser) raise AccessDenied("Modification impossible pour %s" % authuser)
@ -248,9 +248,7 @@ def showEtudLog(context, etudid, format="html", REQUEST=None):
<a href="{url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)}"> <a href="{url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)}">
fiche de {etud['nomprenom']}</a></li> fiche de {etud['nomprenom']}</a></li>
</ul>""", </ul>""",
preferences=sco_preferences.SemPreferences( preferences=sco_preferences.SemPreferences(),
context,
),
) )
return tab.make_page(context, format=format, REQUEST=REQUEST) 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) REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
return sco_news.scolar_news_summary_rss( return sco_news.scolar_news_summary_rss(
context, context,
"Nouvelles de " + sco_preferences.get_preference(context, "DeptName"), "Nouvelles de " + sco_preferences.get_preference("DeptName"),
scu.ScoURL(), scu.ScoURL(),
) )
@ -1207,7 +1205,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
else: else:
A = """<div class="infoapogee"><p>Pas d'informations d'Apogée</p></div>""" A = """<div class="infoapogee"><p>Pas d'informations d'Apogée</p></div>"""
require_ine = sco_preferences.get_preference(context, "always_require_ine") require_ine = sco_preferences.get_preference("always_require_ine")
descr += [ descr += [
("adm_id", {"input_type": "hidden"}), ("adm_id", {"input_type": "hidden"}),

View File

@ -27,9 +27,7 @@ for sem in sems:
formsemestre_id = sem["formsemestre_id"] formsemestre_id = sem["formsemestre_id"]
nt = sco_cache.NotesTableCache.get(formsemestre_id) nt = sco_cache.NotesTableCache.get(formsemestre_id)
etudids = nt.get_etudids() etudids = nt.get_etudids()
use_ue_coef = sco_preferences.get_preference( use_ue_coef = sco_preferences.get_preference("use_ue_coefs", formsemestre_id)
context, "use_ue_coefs", formsemestre_id
)
n += 1 n += 1
print("%d %s (%d) use_ue_coef=%s" % (n, formsemestre_id, len(etudids), use_ue_coef)) print("%d %s (%d) use_ue_coef=%s" % (n, formsemestre_id, len(etudids), use_ue_coef))
for etudid in etudids: for etudid in etudids: