1
0
forked from ScoDoc/ScoDoc

WIP refactoring: caches

This commit is contained in:
Emmanuel Viennet 2021-06-13 23:37:14 +02:00
parent 09a65b48ef
commit 23477faa3b
44 changed files with 504 additions and 303 deletions

View File

@ -698,7 +698,7 @@ def scolars_import_admission(
nline += 1
diag.append("%d lignes importées" % n_import)
if n_import > 0:
context._inval_cache(formsemestre_id=formsemestre_id)
sco_core.inval_cache(context, formsemestre_id=formsemestre_id)
return diag

View File

@ -60,7 +60,7 @@ import sco_bulletins_xml
def go(app, n=0, verbose=True):
context = app.ScoDoc.objectValues("Folder")[n].Scolarite
if verbose:
print("context in dept ", context.DeptId())
print("context in dept ", sco_core.get_dept_id())
return context
@ -72,9 +72,9 @@ def go_dept(app, dept, verbose=True):
except AttributeError:
# ignore other folders, like old "icons"
continue
if context.DeptId() == dept:
if sco_core.get_dept_id() == dept:
if verbose:
print("context in dept ", context.DeptId())
print("context in dept ", sco_core.get_dept_id())
return context
raise ValueError("dep %s not found" % dept)

View File

@ -32,7 +32,7 @@ import time
import pdb
import inspect
import sco_core
import scolars
import sco_groups
from notes_log import log, logCallStack
@ -173,7 +173,9 @@ class NotesTable:
self.moduleimpl_stats = {} # { moduleimpl_id : {stats} }
self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap
self._evaluations_etats = None # liste des evaluations avec état
self.use_ue_coefs = sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id)
self.use_ue_coefs = sco_preferences.get_preference(
context, "use_ue_coefs", formsemestre_id
)
# Infos sur les etudiants
self.inscrlist = context.do_formsemestre_inscription_list(
args={"formsemestre_id": formsemestre_id}
@ -1173,7 +1175,7 @@ class NotesTable:
"comp_ue_capitalisees: recomputing UE moy (etudid=%s, ue_id=%s formsemestre_id=%s)"
% (etudid, ue_cap["ue_id"], ue_cap["formsemestre_id"])
)
nt_cap = self.context._getNotesCache().get_NotesTable(
nt_cap = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, ue_cap["formsemestre_id"]
) # > UE capitalisees par un etud
moy_ue_cap = nt_cap.get_etud_ue_status(etudid, ue_cap["ue_id"])[
@ -1421,7 +1423,9 @@ class CacheNotesTable:
self.cache = {}
self.pdfcache = {}
self._call_all_listeners()
context.get_evaluations_cache().inval_cache()
sco_core.get_evaluations_cache(
context,
).inval_cache()
else:
# formsemestre_id modifié:
# on doit virer formsemestre_id et tous les semestres
@ -1438,7 +1442,9 @@ class CacheNotesTable:
)
del self.cache[formsemestre_id]
self._call_listeners(formsemestre_id)
context.get_evaluations_cache().inval_cache()
sco_core.get_evaluations_cache(
context,
).inval_cache()
for formsemestre_id in to_trash:
for (

View File

@ -379,7 +379,9 @@ class ApoEtud(dict):
dict: with N, B, J, R keys, ou None si elt non trouvé
"""
etudid = self.etud["etudid"]
nt = context._getNotesCache().get_NotesTable(context, sem["formsemestre_id"])
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
if etudid not in nt.identdict:
return None # etudiant non inscrit dans ce semestre
@ -487,9 +489,9 @@ class ApoEtud(dict):
# l'étudiant n'a pas de semestre courant ?!
log("comp_elt_annuel: %s no cur_sem" % etudid)
return VOID_APO_RES
cur_nt = context._getNotesCache().get_NotesTable(
context, cur_sem["formsemestre_id"]
)
cur_nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, cur_sem["formsemestre_id"])
cur_decision = cur_nt.get_etud_decision_sem(etudid)
if not cur_decision:
# pas de decision => pas de résultat annuel
@ -506,9 +508,9 @@ class ApoEtud(dict):
decision_apo = code_scodoc_to_apo(cur_decision["code"])
autre_nt = context._getNotesCache().get_NotesTable(
context, autre_sem["formsemestre_id"]
)
autre_nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, autre_sem["formsemestre_id"])
autre_decision = autre_nt.get_etud_decision_sem(etudid)
if not autre_decision:
# pas de decision dans l'autre => pas de résultat annuel
@ -571,9 +573,9 @@ class ApoEtud(dict):
# prend le plus recent avec decision
cur_sem = None
for sem in cur_sems:
nt = context._getNotesCache().get_NotesTable(
context, sem["formsemestre_id"]
)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
decision = nt.get_etud_decision_sem(self.etud["etudid"])
if decision:
cur_sem = sem
@ -633,9 +635,9 @@ class ApoEtud(dict):
else:
autre_sem = None
for sem in autres_sems:
nt = context._getNotesCache().get_NotesTable(
context, sem["formsemestre_id"]
)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
decision = nt.get_etud_decision_sem(self.etud["etudid"])
if decision:
autre_sem = sem
@ -968,9 +970,9 @@ class ApoData:
s.add(code)
continue
# associé à une UE:
nt = self.context._getNotesCache().get_NotesTable(
self.context, sem["formsemestre_id"]
)
nt = self.sco_core.get_notes_cache(
context,
).get_NotesTable(self.context, sem["formsemestre_id"])
for ue in nt.get_ues():
if ue["code_apogee"] == code:
s.add(code)

View File

@ -93,7 +93,7 @@ class BaseArchiver:
:return: path to directory of archives for this object (eg formsemestre_id or etudid).
If directory does not yet exist, create it.
"""
dept_dir = os.path.join(self.root, context.DeptId())
dept_dir = os.path.join(self.root, sco_core.get_dept_id())
try:
scu.GSL.acquire()
if not os.path.isdir(dept_dir):
@ -111,7 +111,7 @@ class BaseArchiver:
"""
:return: list of archive oids
"""
base = os.path.join(self.root, context.DeptId()) + os.path.sep
base = os.path.join(self.root, sco_core.get_dept_id()) + os.path.sep
dirs = glob.glob(base + "*")
return [os.path.split(x)[1] for x in dirs]
@ -299,7 +299,8 @@ def do_formsemestre_archive(
if data:
data = "\n".join(
[
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Moyennes archivées le %s" % date,
head_message="Moyennes archivées le %s" % date,
@ -381,7 +382,8 @@ def formsemestre_archive(context, REQUEST, formsemestre_id, group_ids=[]):
)
H = [
html_sco_header.html_sem_header(context,
html_sco_header.html_sem_header(
context,
REQUEST,
"Archiver les PV et résultats du semestre",
sem=sem,
@ -503,7 +505,11 @@ def formsemestre_list_archives(context, REQUEST, formsemestre_id):
L.append(a)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
H = [html_sco_header.html_sem_header(context, REQUEST, "Archive des PV et résultats ", sem)]
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Archive des PV et résultats ", sem
)
]
if not L:
H.append("<p>aucune archive enregistrée</p>")
else:

View File

@ -117,7 +117,7 @@ def formsemestre_bulletinetud_dict(
raise ValueError("invalid version code !")
prefs = sco_preferences.SemPreferences(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > toutes notes
@ -337,7 +337,7 @@ def formsemestre_bulletinetud_dict(
# log('cap details %s' % ue_status['moy'])
if ue_status["moy"] != "NA" and ue_status["formsemestre_id"]:
# detail des modules de l'UE capitalisee
nt_cap = context._getNotesCache().get_NotesTable(
nt_cap = sco_core.get_notes_cache(context).get_NotesTable(
context, ue_status["formsemestre_id"]
) # > toutes notes
@ -403,9 +403,11 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
(ajoute les informations aux modimpls)
Result: liste de modules de l'UE avec les infos dans chacun (seulement ceux où l'étudiant est inscrit).
"""
bul_show_mod_rangs = sco_preferences.get_preference(context, "bul_show_mod_rangs", formsemestre_id)
bul_show_abs_modules = sco_preferences.get_preference(context,
"bul_show_abs_modules", formsemestre_id
bul_show_mod_rangs = sco_preferences.get_preference(
context, "bul_show_mod_rangs", formsemestre_id
)
bul_show_abs_modules = sco_preferences.get_preference(
context, "bul_show_abs_modules", formsemestre_id
)
if bul_show_abs_modules:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
@ -478,7 +480,9 @@ 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">'
% (modimpl["moduleimpl_id"], mod["mod_descr_txt"])
)
if sco_preferences.get_preference(context, "bul_show_codemodules", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_codemodules", formsemestre_id
):
mod["code"] = modimpl["module"]["code"]
mod["code_html"] = link_mod + mod["code"] + "</a>"
else:
@ -497,7 +501,9 @@ 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">'
% (modimpl["moduleimpl_id"], mod_descr)
)
if sco_preferences.get_preference(context, "bul_show_codemodules", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_codemodules", formsemestre_id
):
mod["code_txt"] = modimpl["module"]["code"]
mod["code_html"] = link_mod + mod["code_txt"] + "</a>"
else:
@ -558,7 +564,9 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
# Evaluations incomplètes ou futures:
mod["evaluations_incompletes"] = []
if sco_preferences.get_preference(context, "bul_show_all_evals", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_all_evals", formsemestre_id
):
complete_eval_ids = set([e["evaluation_id"] for e in evals])
all_evals = context.do_evaluation_list(
args={"moduleimpl_id": modimpl["moduleimpl_id"]}
@ -842,7 +850,9 @@ def can_send_bulletin_by_mail(context, formsemestre_id, REQUEST):
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
return (
sco_preferences.get_preference(context, "bul_mail_allowed_for_all", formsemestre_id)
sco_preferences.get_preference(
context, "bul_mail_allowed_for_all", formsemestre_id
)
or authuser.has_permission(Permission.ScoImplement, context)
or str(authuser) in sem["responsables"]
)
@ -971,10 +981,18 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr
If bul_mail_list_abs pref is true, put list of absences in mail body (text).
"""
etud = I["etud"]
webmaster = sco_preferences.get_preference(context, "bul_mail_contact_addr", formsemestre_id)
dept = scu.unescape_html(sco_preferences.get_preference(context, "DeptName", formsemestre_id))
copy_addr = sco_preferences.get_preference(context, "email_copy_bulletins", formsemestre_id)
intro_mail = sco_preferences.get_preference(context, "bul_intro_mail", formsemestre_id)
webmaster = sco_preferences.get_preference(
context, "bul_mail_contact_addr", formsemestre_id
)
dept = scu.unescape_html(
sco_preferences.get_preference(context, "DeptName", formsemestre_id)
)
copy_addr = sco_preferences.get_preference(
context, "email_copy_bulletins", formsemestre_id
)
intro_mail = sco_preferences.get_preference(
context, "bul_intro_mail", formsemestre_id
)
if intro_mail:
hea = intro_mail % {
@ -994,7 +1012,9 @@ def mail_bulletin(context, formsemestre_id, I, pdfdata, filename, recipient_addr
subj = Header("Relevé de notes de %s" % etud["nomprenom"], scu.SCO_ENCODING)
recipients = [recipient_addr]
msg["Subject"] = subj
msg["From"] = sco_preferences.get_preference(context, "email_from_addr", formsemestre_id)
msg["From"] = sco_preferences.get_preference(
context, "email_from_addr", formsemestre_id
)
msg["To"] = " ,".join(recipients)
if copy_addr:
msg["Bcc"] = copy_addr.strip()

View File

@ -147,7 +147,7 @@ def formsemestre_bulletinetud_published_dict(
context, pid
)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > toutes notes
ues = nt.get_ues()
@ -156,7 +156,8 @@ def formsemestre_bulletinetud_published_dict(
mg = scu.fmt_note(nt.get_etud_moy_gen(etudid))
if (
nt.get_moduleimpls_attente()
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) == 0
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id)
== 0
):
# n'affiche pas le rang sur le bulletin s'il y a des
# notes en attente dans ce semestre
@ -209,7 +210,9 @@ def formsemestre_bulletinetud_published_dict(
value=scu.fmt_note(ue_status["cur_moy_ue"]),
min=scu.fmt_note(ue["min"]),
max=scu.fmt_note(ue["max"]),
moy=scu.fmt_note(ue["moy"]), # CM : ajout pour faire apparaitre la moyenne des UE
moy=scu.fmt_note(
ue["moy"]
), # CM : ajout pour faire apparaitre la moyenne des UE
),
rang=str(nt.ue_rangs[ue["ue_id"]][0][etudid]),
effectif=str(nt.ue_rangs[ue["ue_id"]][1]),
@ -249,7 +252,9 @@ def formsemestre_bulletinetud_published_dict(
m["note"][k] = scu.fmt_note(m["note"][k])
u["module"].append(m)
if sco_preferences.get_preference(context, "bul_show_mod_rangs", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_mod_rangs", formsemestre_id
):
m["rang"] = dict(
value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid]
)
@ -276,14 +281,18 @@ def formsemestre_bulletinetud_published_dict(
),
coefficient=e["coefficient"],
evaluation_type=e["evaluation_type"],
evaluation_id=e["evaluation_id"], # CM : ajout pour permettre de faire le lien sur les bulletins en ligne avec l'évaluation
evaluation_id=e[
"evaluation_id"
], # CM : ajout pour permettre de faire le lien sur les bulletins en ligne avec l'évaluation
description=scu.quote_xml_attr(e["description"]),
note=val,
)
)
# Evaluations incomplètes ou futures:
complete_eval_ids = set([e["evaluation_id"] for e in evals])
if sco_preferences.get_preference(context, "bul_show_all_evals", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_all_evals", formsemestre_id
):
all_evals = context.do_evaluation_list(
args={"moduleimpl_id": modimpl["moduleimpl_id"]}
)
@ -344,7 +353,9 @@ def formsemestre_bulletinetud_published_dict(
etudid,
formsemestre_id,
format="xml",
show_uevalid=sco_preferences.get_preference(context, "bul_show_uevalid", formsemestre_id),
show_uevalid=sco_preferences.get_preference(
context, "bul_show_uevalid", formsemestre_id
),
)
d["situation"] = scu.quote_xml_attr(infos["situation"])
if dpv:

View File

@ -143,7 +143,7 @@ def process_field(
return text
# --- PDF format:
# handle logos:
image_dir = scu.SCODOC_LOGOS_DIR + "/logos_" + context.DeptId() + "/"
image_dir = scu.SCODOC_LOGOS_DIR + "/logos_" + sco_core.get_dept_id() + "/"
if not os.path.exists(image_dir):
image_dir = scu.SCODOC_LOGOS_DIR + "/" # use global logos
text = re.sub(
@ -165,13 +165,15 @@ def get_formsemestre_bulletins_pdf(
context, formsemestre_id, REQUEST, version="selectedevals"
):
"document pdf et filename"
cached = context._getNotesCache().get_bulletins_pdf(formsemestre_id, version)
cached = sco_core.get_notes_cache(
context,
).get_bulletins_pdf(formsemestre_id, version)
if cached:
return cached[1], cached[0]
fragments = []
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# Make each bulletin
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_sexnom
bookmarks = {}
@ -191,7 +193,9 @@ def get_formsemestre_bulletins_pdf(
bookmarks[i] = scu.suppress_accents(nt.get_sexnom(etudid))
i = i + 1
#
infos = {"DeptName": sco_preferences.get_preference(context, "DeptName", formsemestre_id)}
infos = {
"DeptName": sco_preferences.get_preference(context, "DeptName", formsemestre_id)
}
if REQUEST:
server_name = REQUEST.BASE0
else:
@ -215,9 +219,9 @@ def get_formsemestre_bulletins_pdf(
filename = "bul-%s-%s.pdf" % (sem["titre_num"], dt)
filename = scu.unescape_html(filename).replace(" ", "_").replace("&", "")
# fill cache
context._getNotesCache().store_bulletins_pdf(
formsemestre_id, version, filename, pdfdoc
)
sco_core.get_notes_cache(
context,
).store_bulletins_pdf(formsemestre_id, version, filename, pdfdoc)
return pdfdoc, filename

View File

@ -85,7 +85,7 @@ et sur page "réglages bulletin" (avec formsemestre_id)
# def _sig_filename(context, side, formsemestre_id=None):
# if not side in ("left", "right"):
# raise ValueError("side must be left or right")
# dirs = [SCODOC_LOGOS_DIR, context.DeptId()]
# dirs = [SCODOC_LOGOS_DIR, sco_core.get_dept_id()]
# if formsemestre_id:
# dirs.append(formsemestre_id)
# dirs.append("bul_sig_{}".format(side))

View File

@ -130,7 +130,7 @@ def make_xml_formsemestre_bulletinetud(
context, pid
)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > toutes notes
ues = nt.get_ues()
@ -139,7 +139,8 @@ def make_xml_formsemestre_bulletinetud(
mg = scu.fmt_note(nt.get_etud_moy_gen(etudid))
if (
nt.get_moduleimpls_attente()
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id) == 0
or sco_preferences.get_preference(context, "bul_show_rangs", formsemestre_id)
== 0
):
# n'affiche pas le rang sur le bulletin s'il y a des
# notes en attente dans ce semestre
@ -247,7 +248,9 @@ def make_xml_formsemestre_bulletinetud(
moy=scu.fmt_note(modstat["moy"]),
)
doc._pop()
if sco_preferences.get_preference(context, "bul_show_mod_rangs", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_mod_rangs", formsemestre_id
):
doc._push()
doc.rang(value=nt.mod_rangs[modimpl["moduleimpl_id"]][0][etudid])
doc._pop()
@ -283,7 +286,9 @@ def make_xml_formsemestre_bulletinetud(
doc._pop()
# Evaluations incomplètes ou futures:
complete_eval_ids = set([e["evaluation_id"] for e in evals])
if sco_preferences.get_preference(context, "bul_show_all_evals", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_show_all_evals", formsemestre_id
):
all_evals = context.do_evaluation_list(
args={"moduleimpl_id": modimpl["moduleimpl_id"]}
)
@ -353,7 +358,9 @@ def make_xml_formsemestre_bulletinetud(
etudid,
formsemestre_id,
format="xml",
show_uevalid=sco_preferences.get_preference(context, "bul_show_uevalid", formsemestre_id),
show_uevalid=sco_preferences.get_preference(
context, "bul_show_uevalid", formsemestre_id
),
)
doc.situation(scu.quote_xml_attr(infos["situation"]))
if dpv:

View File

@ -7,6 +7,9 @@
import types
import sco_utils as scu
from notes_table import NOTES_CACHE_INST, CacheNotesTable
from scodoc_manager import sco_mgr
from sco_exceptions import ScoInvalidDept
def sco_get_version(context, REQUEST=None):
@ -17,10 +20,75 @@ def sco_get_version(context, REQUEST=None):
def test_refactor(context, x=1):
x = context.toto()
y = ("context=" + sco_edit_module.module_is_locked(context, "alpha")) + "23"
z = html_sco_header.sco_header(context,
z = html_sco_header.sco_header(
context,
a_long_argument_hahahahaha=1,
another_very_long_arggggggggggggg=2,
z=6,
u=99,
kkkkkk=1,
)
def get_dept_id():
if g.scodoc_dept in sco_mgr.get_dept_ids():
return g.scodoc_dept
raise ScoInvalidDept("département invalide: %s" % g.scodoc_dept)
#
# Cache global: chaque instance, repérée par sa connexion db, a un cache
# qui est recréé à la demande
#
CACHE_formsemestre_inscription = {}
CACHE_evaluations = {}
# cache notes evaluations
def get_evaluations_cache(context):
"""returns cache for evaluations"""
u = context.GetDBConnexionString()
if CACHE_evaluations.has_key(u):
return CACHE_evaluations[u]
else:
log("get_evaluations_cache: new simpleCache")
CACHE_evaluations[u] = sco_cache.simpleCache()
return CACHE_evaluations[u]
def get_notes_cache(context):
"returns CacheNotesTable instance for us"
u = sco_mgr.get_db_uri() # identifie le dept de facon unique
if not NOTES_CACHE_INST.has_key(u):
log("getNotesCache: creating cache for %s" % u)
NOTES_CACHE_INST[u] = CacheNotesTable()
return NOTES_CACHE_INST[u]
def inval_cache(
context, formsemestre_id=None, pdfonly=False, formsemestre_id_list=None
): # >
"expire cache pour un semestre (ou tous si pas d'argument)"
if formsemestre_id_list:
for formsemestre_id in formsemestre_id_list:
get_notes_cache(context).inval_cache(
context, formsemestre_id=formsemestre_id, pdfonly=pdfonly
)
# Affecte aussi cache inscriptions
get_formsemestre_inscription_cache(context).inval_cache(key=formsemestre_id)
else:
get_notes_cache(context).inval_cache(
context, formsemestre_id=formsemestre_id, pdfonly=pdfonly
)
# Affecte aussi cache inscriptions
get_formsemestre_inscription_cache(context).inval_cache(key=formsemestre_id)
# Cache inscriptions semestres
def get_formsemestre_inscription_cache(context, format=None):
u = context.GetDBConnexionString()
if CACHE_formsemestre_inscription.has_key(u):
return CACHE_formsemestre_inscription[u]
else:
log("get_formsemestre_inscription_cache: new simpleCache")
CACHE_formsemestre_inscription[u] = sco_cache.simpleCache()
return CACHE_formsemestre_inscription[u]

View File

@ -110,9 +110,9 @@ def table_debouche_etudids(context, etudids, keep_numeric=True):
es = [(sems[i]["date_fin_iso"], i) for i in range(len(sems))]
imax = max(es)[1]
last_sem = sems[imax]
nt = context._getNotesCache().get_NotesTable(
context, last_sem["formsemestre_id"]
)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, last_sem["formsemestre_id"])
row = {
"etudid": etudid,
"civilite": etud["civilite"],

View File

@ -46,7 +46,9 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST
F = F[0]
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Suppression d'une formation"),
html_sco_header.sco_header(
context, REQUEST, page_title="Suppression d'une formation"
),
"""<h2>Suppression de la formation %(titre)s (%(acronyme)s)</h2>""" % F,
]
@ -99,7 +101,9 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
"""Edit or create a formation"""
if create:
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Création d'une formation"),
html_sco_header.sco_header(
context, REQUEST, page_title="Création d'une formation"
),
"""<h2>Création d'une formation</h2>
<p class="help">Une "formation" décrit une filière, comme un DUT ou une Licence. La formation se subdivise en unités pédagogiques (UE, matières, modules). Elle peut se diviser en plusieurs semestres (ou sessions), qui seront mis en place séparément.
@ -121,7 +125,9 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
is_locked = context.formation_has_locked_sems(formation_id)
submitlabel = "Modifier les valeurs"
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Modification d'une formation"),
html_sco_header.sco_header(
context, REQUEST, page_title="Modification d'une formation"
),
"""<h2>Modification de la formation %(acronyme)s</h2>""" % initvalues,
]
if is_locked:
@ -271,6 +277,6 @@ def do_formation_edit(context, args):
for sem in sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": args["formation_id"]}
):
context._inval_cache(
formsemestre_id=sem["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=sem["formsemestre_id"]
) # > formation modif.

View File

@ -760,8 +760,8 @@ def do_ue_edit(context, args, bypass_lock=False, dont_invalidate_cache=False):
for sem in sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": ue["formation_id"]}
):
context._inval_cache(
formsemestre_id=sem["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=sem["formsemestre_id"]
) # > formation (ue) modif.

View File

@ -104,7 +104,7 @@ def do_evaluation_delete(context, REQUEST, evaluation_id):
context._evaluationEditor.delete(cnx, evaluation_id)
# inval cache pour ce semestre
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
context._inval_cache(formsemestre_id=M["formsemestre_id"]) # > eval delete
sco_core.inval_cache(context, formsemestre_id=M["formsemestre_id"]) # > eval delete
# news
mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
mod["moduleimpl_id"] = M["moduleimpl_id"]
@ -406,7 +406,7 @@ def _eval_etat(evals):
def do_evaluation_etat_in_sem(context, formsemestre_id, REQUEST=None):
"""-> nb_eval_completes, nb_evals_en_cours, nb_evals_vides,
date derniere modif, attente"""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > liste evaluations et moduleimpl en attente
evals = nt.get_sem_evaluation_etat_list()
@ -429,7 +429,7 @@ def do_evaluation_etat_in_mod(context, nt, moduleimpl_id):
def formsemestre_evaluations_cal(context, formsemestre_id, REQUEST=None):
"""Page avec calendrier de toutes les evaluations de ce semestre"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > liste evaluations
@ -565,7 +565,7 @@ def formsemestre_evaluations_delai_correction(
N'indique pas les évaluations de ratrapage ni celles des modules de bonus/malus.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > liste evaluations

View File

@ -77,7 +77,7 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours
{}
) # etudid : { formsemestre_id d'inscription le plus recent dans les dates considérées, etud }
for formsemestre_id in formsemestre_ids_parcours:
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids
etudids = nt.get_etudids()
@ -198,7 +198,7 @@ def _build_results_list(context, dpv_by_sem, etuds_infos):
int(sem["annee_debut"]), sem["mois_debut_ord"]
)
r["sid"] = "{} {} {}".format(
sem["sem_id_txt"], context.DeptId(), sem["modalite"]
sem["sem_id_txt"], sco_core.get_dept_id(), sem["modalite"]
)
rows.append(r)

View File

@ -226,7 +226,9 @@ def do_formsemestre_edit(context, sem, cnx=None, **kw):
write_formsemestre_etapes(context, sem)
write_formsemestre_responsables(context, sem)
context._inval_cache(formsemestre_id=sem["formsemestre_id"]) # > modif formsemestre
sco_core.inval_cache(
context, formsemestre_id=sem["formsemestre_id"]
) # > modif formsemestre
def read_formsemestre_responsables(context, formsemestre_id):

View File

@ -30,6 +30,7 @@
import notesdb as ndb
import sco_utils as scu
import sco_core
import sco_groups
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
@ -384,8 +385,8 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
"size": 32,
"title": "Element(s) Apogée:",
"explanation": "du semestre (ex: VRTW1). Séparés par des virgules.",
"allow_null": not sco_preferences.get_preference(context,
"always_require_apo_sem_codes"
"allow_null": not sco_preferences.get_preference(
context, "always_require_apo_sem_codes"
),
},
)
@ -397,8 +398,8 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
"size": 32,
"title": "Element(s) Apogée:",
"explanation": "de l'année (ex: VRT1A). Séparés par des virgules.",
"allow_null": not sco_preferences.get_preference(context,
"always_require_apo_sem_codes"
"allow_null": not sco_preferences.get_preference(
context, "always_require_apo_sem_codes"
),
},
)
@ -643,7 +644,9 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
# check dates
if ndb.DateDMYtoISO(tf[2]["date_debut"]) > ndb.DateDMYtoISO(tf[2]["date_fin"]):
msg = '<ul class="tf-msg"><li class="tf-msg">Dates de début et fin incompatibles !</li></ul>'
if sco_preferences.get_preference(context, "always_require_apo_sem_codes") and not any(
if sco_preferences.get_preference(
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)]
):
msg = '<ul class="tf-msg"><li class="tf-msg">Code étape Apogée manquant</li></ul>'
@ -1341,7 +1344,9 @@ def do_formsemestre_delete(context, formsemestre_id, REQUEST):
"DELETE FROM notes_evaluation WHERE evaluation_id=%(evaluation_id)s",
e,
)
context.get_evaluations_cache().inval_cache(key=e["evaluation_id"])
sco_core.get_evaluations_cache(
context,
).inval_cache(key=e["evaluation_id"])
sco_moduleimpl.do_moduleimpl_delete(
context, mod["moduleimpl_id"], formsemestre_id=formsemestre_id
@ -1638,8 +1643,8 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
z.append("</ul>")
else:
z = ["""<h3>Aucune modification</h3>"""]
context._inval_cache(
formsemestre_id=formsemestre_id
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif coef UE cap (modifs notes de _certains_ etudiants)
header = html_sco_header.html_sem_header(
@ -1673,7 +1678,9 @@ def get_formsemestre_session_id(context, sem, F, parcours):
# F = context.formation_list( args={ 'formation_id' : sem['formation_id'] } )[0]
# parcours = sco_codes_parcours.get_parcours_from_code(F['type_parcours'])
ImputationDept = sco_preferences.get_preference(context, "ImputationDept", sem["formsemestre_id"])
ImputationDept = sco_preferences.get_preference(
context, "ImputationDept", sem["formsemestre_id"]
)
if not ImputationDept:
ImputationDept = sco_preferences.get_preference(context, "DeptName")
ImputationDept = ImputationDept.upper()

View File

@ -256,10 +256,13 @@ def formsemestre_ext_edit_ue_validations(
def _make_page(context, etud, sem, tf, message="", REQUEST=None):
nt = context._getNotesCache().get_NotesTable(context, sem["formsemestre_id"])
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
moy_gen = nt.get_etud_moy_gen(etud["etudid"])
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Validation des UE d'un semestre extérieur",
javascripts=["js/formsemestre_ext_edit_ue_validations.js"],

View File

@ -120,7 +120,10 @@ def formsemestre_inscription_with_modules_form(
Si only_ext, ne montre que les semestre extérieurs.
"""
etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
H = [html_sco_header.sco_header(context, REQUEST), "<h2>Inscription de %s" % etud["nomprenom"]]
H = [
html_sco_header.sco_header(context, REQUEST),
"<h2>Inscription de %s" % etud["nomprenom"],
]
if only_ext:
H.append(" dans un semestre extérieur")
H.append(
@ -177,8 +180,11 @@ def formsemestre_inscription_with_modules(
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
H = [
html_sco_header.html_sem_header(context,
REQUEST, "Inscription de %s dans ce semestre" % etud["nomprenom"], sem
html_sco_header.html_sem_header(
context,
REQUEST,
"Inscription de %s dans ce semestre" % etud["nomprenom"],
sem,
)
]
F = html_sco_header.sco_footer(context, REQUEST)
@ -273,7 +279,7 @@ def formsemestre_inscription_option(context, etudid, formsemestre_id, REQUEST=No
raise ScoValueError("Modification impossible: semestre verrouille")
etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_ue_status
@ -584,7 +590,7 @@ def list_inscrits_ailleurs(context, formsemestre_id):
Pour chacun, donne la liste des semestres.
{ etudid : [ liste de sems ] }
"""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids
etudids = nt.get_etudids()
@ -600,8 +606,11 @@ def formsemestre_inscrits_ailleurs(context, formsemestre_id, REQUEST=None):
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
H = [
html_sco_header.html_sem_header(context,
REQUEST, "Inscriptions multiples parmi les étudiants du semestre ", sem
html_sco_header.html_sem_header(
context,
REQUEST,
"Inscriptions multiples parmi les étudiants du semestre ",
sem,
)
]
insd = list_inscrits_ailleurs(context, formsemestre_id)

View File

@ -518,7 +518,9 @@ def fill_formsemestre(context, sem, REQUEST=None):
)
else:
sem["locklink"] = ""
if sco_preferences.get_preference(context, "bul_display_publication", formsemestre_id):
if sco_preferences.get_preference(
context, "bul_display_publication", formsemestre_id
):
if sem["bul_hide_xml"] != "0":
eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés")
else:
@ -565,10 +567,12 @@ def formsemestre_description_table(
Liste des modules et de leurs coefficients
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > liste evaluations
use_ue_coefs = sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id)
use_ue_coefs = sco_preferences.get_preference(
context, "use_ue_coefs", formsemestre_id
)
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
@ -960,7 +964,9 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
),
"""<p><b style="font-size: 130%">Tableau de bord: </b><span class="help">cliquez sur un module pour saisir des notes</span></p>""",
]
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, formsemestre_id)
if nt.expr_diagnostics:
H.append(html_expr_diagnostic(context, nt.expr_diagnostics))
H.append(

View File

@ -58,7 +58,7 @@ def formsemestre_validation_etud_form(
readonly=True,
REQUEST=None,
):
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_table_moyennes_triees, get_etud_decision_sem
T = nt.get_table_moyennes_triees()
@ -97,7 +97,8 @@ def formsemestre_validation_etud_form(
raise ScoValueError("validation: semestre verrouille")
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Parcours %(nomprenom)s" % etud,
javascripts=["js/recap_parcours.js"],
@ -401,9 +402,9 @@ def formsemestre_validation_etud_manu(
def _redirect_valid_choice(
formsemestre_id, etudid, Se, choice, desturl, sortcol, REQUEST
):
adr = (
"formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1"
% (formsemestre_id, etudid)
adr = "formsemestre_validation_etud_form?formsemestre_id=%s&etudid=%s&check=1" % (
formsemestre_id,
etudid,
)
if sortcol:
adr += "&sortcol=" + sortcol
@ -522,7 +523,7 @@ def formsemestre_recap_parcours_table(
else:
ass = ""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, sem["formsemestre_id"]
) # > get_ues, get_etud_moy_gen, get_etud_ue_status
if is_cur:
@ -656,7 +657,9 @@ def formsemestre_recap_parcours_table(
H.append("</tr>")
# 3eme ligne: ECTS
if (
sco_preferences.get_preference(context, "bul_show_ects", sem["formsemestre_id"])
sco_preferences.get_preference(
context, "bul_show_ects", sem["formsemestre_id"]
)
or nt.parcours.ECTS_ONLY
):
etud_moy_infos = nt.get_etud_moy_infos(etudid)
@ -822,8 +825,8 @@ def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
"Formulaire saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
H = [
html_sco_header.html_sem_header(context,
REQUEST, "Saisie automatique des décisions du semestre", sem
html_sco_header.html_sem_header(
context, REQUEST, "Saisie automatique des décisions du semestre", sem
),
"""
<ul>
@ -852,7 +855,7 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
"Saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
next_semestre_id = sem["semestre_id"] + 1
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_etud_decision_sem,
etudids = nt.get_etudids()
@ -954,7 +957,7 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
N'affecte que le semestre indiqué, pas les précédents.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_etud_decision_sem, get_ues, get_etud_decision_ues, get_etud_ue_status
etudids = nt.get_etudids()
@ -1011,7 +1014,9 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
cnx.commit()
#
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Réparation des codes UE"),
html_sco_header.sco_header(
context, REQUEST, page_title="Réparation des codes UE"
),
sco_formsemestre_status.formsemestre_status_head(
context, REQUEST=REQUEST, formsemestre_id=formsemestre_id
),
@ -1023,7 +1028,9 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
"</li><li>".join(modifs),
"</li></ul>",
]
context._inval_cache(formsemestre_id=formsemestre_id) # > modif decision UE
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif decision UE
else:
H.append("<h2>Aucune modification: codes UE corrects ou inexistants</h2>")
H.append(html_sco_header.sco_footer(context, REQUEST))
@ -1069,7 +1076,8 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
Fo = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Validation UE",
javascripts=["js/validate_previous_ue.js"],
@ -1160,7 +1168,13 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
<div id="ue_list_code"><!-- filled by ue_sharing_code --></div>
"""
warn, ue_multiples = check_formation_ues(context, Fo["formation_id"])
return "\n".join(H) + tf[1] + X + warn + html_sco_header.sco_footer(context, REQUEST)
return (
"\n".join(H)
+ tf[1]
+ X
+ warn
+ html_sco_header.sco_footer(context, REQUEST)
)
elif tf[0] == -1:
return REQUEST.RESPONSE.redirect(
context.NotesURL()
@ -1207,7 +1221,7 @@ def do_formsemestre_validate_previous_ue(
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
cnx = context.GetDBConnexion(autocommit=False)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_ue_status
if ue_coefficient != None:
@ -1256,8 +1270,8 @@ def _invalidate_etud_formation_caches(context, etudid, formation_id):
{"etudid": etudid, "formation_id": formation_id},
)
for fsid in [s["formsemestre_id"] for s in r]:
context._inval_cache(
formsemestre_id=fsid
sco_core.inval_cache(
context, formsemestre_id=fsid
) # > modif decision UE (inval tous semestres avec cet etudiant, ok mais conservatif)

View File

@ -818,8 +818,11 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
)
#
H = [
html_sco_header.sco_header(context,
REQUEST, page_title="Partitions...", javascripts=["js/editPartitionForm.js"]
html_sco_header.sco_header(
context,
REQUEST,
page_title="Partitions...",
javascripts=["js/editPartitionForm.js"],
),
r"""<script type="text/javascript">
function checkname() {
@ -1207,7 +1210,9 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
]
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Répartition des groupes"),
html_sco_header.sco_header(
context, REQUEST, page_title="Répartition des groupes"
),
"<h2>Répartition des groupes de %s</h2>" % partition["partition_name"],
"<p>Semestre %s</p>" % sem["titreannee"],
"""<p class="help">Les groupes existants seront <b>effacés</b> et remplacés par
@ -1227,7 +1232,9 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
name="tf",
)
if tf[0] == 0:
return "\n".join(H) + "\n" + tf[1] + html_sco_header.sco_footer(context, REQUEST)
return (
"\n".join(H) + "\n" + tf[1] + html_sco_header.sco_footer(context, REQUEST)
)
elif tf[0] == -1:
return REQUEST.RESPONSE.redirect(dest_url)
else:
@ -1298,7 +1305,7 @@ def get_prev_moy(context, etudid, formsemestre_id):
etud = info[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
if Se.prev:
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, Se.prev["formsemestre_id"]
) # > get_etud_moy_gen
return nt.get_etud_moy_gen(etudid)

View File

@ -645,7 +645,7 @@ def _add_moymod_column(
):
"""Ajoute la colonne moymod à rows"""
col_id = "moymod"
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_mod_moy
nb_notes = 0

View File

@ -64,8 +64,8 @@ def do_moduleimpl_create(context, args):
"create a moduleimpl"
cnx = context.GetDBConnexion()
r = _moduleimplEditor.create(cnx, args)
context._inval_cache(
formsemestre_id=args["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=args["formsemestre_id"]
) # > creation moduleimpl
return r
@ -91,7 +91,9 @@ def do_moduleimpl_delete(context, oid, formsemestre_id=None):
)
# --- destruction du moduleimpl
_moduleimplEditor.delete(cnx, oid)
context._inval_cache(formsemestre_id=formsemestre_id) # > moduleimpl_delete
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > moduleimpl_delete
def do_moduleimpl_list(
@ -113,7 +115,7 @@ def do_moduleimpl_edit(context, args, formsemestre_id=None, cnx=None):
cnx = context.GetDBConnexion()
_moduleimplEditor.edit(cnx, args)
context._inval_cache(formsemestre_id=formsemestre_id) # > modif moduleimpl
sco_core.inval_cache(context, formsemestre_id=formsemestre_id) # > modif moduleimpl
def do_moduleimpl_withmodule_list(
@ -197,7 +199,9 @@ def do_moduleimpl_inscription_create(context, args, REQUEST=None, formsemestre_i
cnx = context.GetDBConnexion()
log("do_moduleimpl_inscription_create: " + str(args))
r = _moduleimpl_inscriptionEditor.create(cnx, args)
context._inval_cache(formsemestre_id=formsemestre_id) # > moduleimpl_inscription
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > moduleimpl_inscription
if REQUEST:
scolog.logdb(
REQUEST,
@ -214,7 +218,9 @@ def do_moduleimpl_inscription_delete(context, oid, formsemestre_id=None):
"delete moduleimpl_inscription"
cnx = context.GetDBConnexion()
_moduleimpl_inscriptionEditor.delete(cnx, oid)
context._inval_cache(formsemestre_id=formsemestre_id) # > moduleimpl_inscription
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > moduleimpl_inscription
def do_moduleimpl_inscrit_etuds(
@ -259,7 +265,9 @@ def do_moduleimpl_inscrit_etuds(
formsemestre_id=formsemestre_id,
)
context._inval_cache(formsemestre_id=formsemestre_id) # > moduleimpl_inscrit_etuds
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > moduleimpl_inscrit_etuds
def do_ens_list(context, *args, **kw):

View File

@ -62,7 +62,8 @@ def moduleimpl_inscriptions_edit(
# -- check lock
if sem["etat"] != "1":
raise ScoValueError("opération impossible: semestre verrouille")
header = html_sco_header.sco_header(context,
header = html_sco_header.sco_header(
context,
REQUEST,
page_title="Inscription au module",
init_qtip=True,
@ -273,7 +274,11 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
mod["nb_inscrits"] = nb_inscrits
options.append(mod)
# Page HTML:
H = [html_sco_header.html_sem_header(context, REQUEST, "Inscriptions aux modules du semestre")]
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Inscriptions aux modules du semestre"
)
]
H.append("<h3>Inscrits au semestre: %d étudiants</h3>" % len(inscrits))
@ -458,7 +463,7 @@ def get_etuds_with_capitalized_ue(context, formsemestre_id):
returns { ue_id : [ { infos } ] }
"""
UECaps = scu.DictDefault(defaultvalue=[])
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_ues, get_etud_ue_status
inscrits = context.do_formsemestre_inscription_list(
@ -532,8 +537,8 @@ def do_etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None)
msg="desinscription UE %s" % ue_id,
commit=False,
)
context._inval_cache(
formsemestre_id=formsemestre_id
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > desinscription etudiant des modules

View File

@ -148,7 +148,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
context, moduleimpl_id=M["moduleimpl_id"]
)
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, formsemestre_id)
ModEvals = context.do_evaluation_list({"moduleimpl_id": moduleimpl_id})
ModEvals.sort(
key=lambda x: (x["numero"], x["jour"], x["heure_debut"]), reverse=True
@ -162,7 +164,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
#
H = [
html_sco_header.sco_header(context, REQUEST, page_title="Module %(titre)s" % Mod),
html_sco_header.sco_header(
context, REQUEST, page_title="Module %(titre)s" % Mod
),
"""<h2 class="formsemestre">Module <tt>%(code)s</tt> %(titre)s</h2>""" % Mod,
# XXX """caneditevals=%s caneditnotes=%s""" % (caneditevals,caneditnotes),
"""<div class="moduleimpl_tableaubord">

View File

@ -104,7 +104,7 @@ class DecisionSem:
def SituationEtudParcours(context, etud, formsemestre_id):
"""renvoie une instance de SituationEtudParcours (ou sous-classe spécialisée)"""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_decision_sem, get_etud_moy_gen, get_ues, get_etud_ue_status, etud_check_conditions_ues
parcours = nt.parcours
@ -295,7 +295,7 @@ class SituationEtudParcoursGeneric:
sem["semestre_id"] == n1
and sem["formation_code"] == self.formation["formation_code"]
):
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -311,7 +311,7 @@ class SituationEtudParcoursGeneric:
sont validés. En sortie, sem_idx_set contient ceux qui n'ont pas été validés."""
for sem in self.get_semestres():
if sem["formation_code"] == self.formation["formation_code"]:
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -329,7 +329,7 @@ class SituationEtudParcoursGeneric:
ue_acros = {} # acronyme ue : 1
nb_max_ue = 0
for sem in sems:
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_ues
ues = nt.get_ues(filter_sport=True)
@ -399,7 +399,7 @@ class SituationEtudParcoursGeneric:
if not sem:
code = "" # non inscrit à ce semestre
else:
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -471,7 +471,7 @@ class SituationEtudParcoursGeneric:
# Verifications basiques:
# ?
# Code etat du semestre precedent:
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, prev["formsemestre_id"]
) # > get_etud_decision_sem, get_etud_moy_gen, etud_check_conditions_ues
self.prev_decision = nt.get_etud_decision_sem(self.etudid)
@ -530,7 +530,7 @@ class SituationEtudParcoursGeneric:
sem["formation_code"] == self.formation["formation_code"]
and sem["semestre_id"] == s
):
nt = self.context._getNotesCache().get_NotesTable(
nt = self.sco_core.get_notes_cache(context).get_NotesTable(
self.context, sem["formsemestre_id"]
) # > get_etud_decision_sem
decision = nt.get_etud_decision_sem(self.etudid)
@ -629,8 +629,8 @@ class SituationEtudParcoursGeneric:
REQUEST=REQUEST,
)
self.context._inval_cache(
formsemestre_id=self.prev["formsemestre_id"]
self.sco_core.inval_cache(
context, formsemestre_id=self.prev["formsemestre_id"]
) # > modif decisions jury (sem, UE)
# -- supprime autorisations venant de ce formsemestre
@ -659,17 +659,17 @@ class SituationEtudParcoursGeneric:
except:
cnx.rollback()
raise
self.context._inval_cache(
formsemestre_id=self.formsemestre_id
self.sco_core.inval_cache(
context, formsemestre_id=self.formsemestre_id
) # > modif decisions jury et autorisations inscription
if decision.formsemestre_id_utilise_pour_compenser:
# inval aussi le semestre utilisé pour compenser:
self.context._inval_cache(
formsemestre_id=decision.formsemestre_id_utilise_pour_compenser
self.sco_core.inval_cache(
context, formsemestre_id=decision.formsemestre_id_utilise_pour_compenser
) # > modif decision jury
for formsemestre_id in to_invalidate:
self.context._inval_cache(
formsemestre_id=formsemestre_id
self.sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif decision jury
@ -908,7 +908,7 @@ def formsemestre_validate_ues(
"""
valid_semestre = CODES_SEM_VALIDES.get(code_etat_sem, False)
cnx = context.GetDBConnexion(autocommit=False)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_ues, get_etud_ue_status
ue_ids = [x["ue_id"] for x in nt.get_ues(etudid=etudid, filter_sport=True)]

View File

@ -200,7 +200,7 @@ class ScolarsPageTemplate(PageTemplate):
# XXX COPIED from sco_pvpdf, to be refactored (no time now)
# Search background in dept specific dir, then in global config dir
for image_dir in (
SCODOC_LOGOS_DIR + "/logos_" + context.DeptId() + "/",
SCODOC_LOGOS_DIR + "/logos_" + sco_core.get_dept_id() + "/",
SCODOC_LOGOS_DIR + "/", # global logos
):
for suffix in LOGOS_IMAGES_ALLOWED_TYPES:

View File

@ -315,7 +315,7 @@ def get_new_filename(context, etudid):
"""Constructs a random filename to store a new image.
The path is constructed as: Fxx/etudid
"""
dept = context.DeptId()
dept = sco_core.get_dept_id()
return find_new_dir() + dept + "_" + etudid

View File

@ -54,9 +54,9 @@ def etud_get_poursuite_info(context, sem, etud):
for s in etud["sems"]:
if s["semestre_id"] == sem_id:
etudid = etud["etudid"]
nt = context._getNotesCache().get_NotesTable(
context, s["formsemestre_id"]
)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, s["formsemestre_id"])
dec = nt.get_etud_decision_sem(etudid)
# Moyennes et rangs des UE
ues = nt.get_ues(filter_sport=True)

View File

@ -44,7 +44,7 @@ import VERSION
def feuille_preparation_jury(context, formsemestre_id, REQUEST):
"Feuille excel pour preparation des jurys"
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_etud_moy_gen, get_ues, get_etud_ue_status, get_etud_decision_sem, identdict,
etudids = nt.get_etudids(sorted=True) # tri par moy gen
@ -77,7 +77,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
etud = info[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
if Se.prev:
ntp = context._getNotesCache().get_NotesTable(
ntp = sco_core.get_notes_cache(context).get_NotesTable(
context, Se.prev["formsemestre_id"]
) # > get_ues, get_etud_ue_status, get_etud_moy_gen, get_etud_decision_sem
for ue in ntp.get_ues(filter_sport=True):

View File

@ -210,7 +210,7 @@ def dict_pvjury(
'decisions_dict' : { etudid : decision (comme ci-dessus) },
}
"""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_etud_etat, get_etud_decision_sem, get_etud_decision_ues
if etudids is None:
@ -448,12 +448,14 @@ def pvjury_table(
}
if with_paragraph_nom:
cell_style = styles.ParagraphStyle({})
cell_style.fontSize = sco_preferences.get_preference(context,
"SCOLAR_FONT_SIZE", formsemestre_id
cell_style.fontSize = sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id
)
cell_style.fontName = sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id)
cell_style.leading = 1.0 * sco_preferences.get_preference(context,
"SCOLAR_FONT_SIZE", formsemestre_id
cell_style.fontName = sco_preferences.get_preference(
context, "PV_FONTNAME", formsemestre_id
)
cell_style.leading = 1.0 * sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space
i = e["identite"]
l["nomprenom"] = [

View File

@ -201,7 +201,7 @@ class CourrierIndividuelTemplate(PageTemplate):
self.logo_header = None
# Search logos in dept specific dir, then in global scu.CONFIG dir
for image_dir in (
scu.SCODOC_LOGOS_DIR + "/logos_" + context.DeptId() + "/",
scu.SCODOC_LOGOS_DIR + "/logos_" + sco_core.get_dept_id() + "/",
scu.SCODOC_LOGOS_DIR + "/", # global logos
):
for suffix in scu.LOGOS_IMAGES_ALLOWED_TYPES:
@ -358,7 +358,9 @@ def pdf_lettres_individuelles(
}
# copie preferences
for name in sco_preferences.PREFS_NAMES:
params[name] = sco_preferences.get_preference(context, name, sem["formsemestre_id"])
params[name] = sco_preferences.get_preference(
context, name, sem["formsemestre_id"]
)
bookmarks = {}
objects = [] # list of PLATYPUS objects
@ -429,7 +431,9 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context
objects = []
style = reportlab.lib.styles.ParagraphStyle({})
style.fontSize = 14
style.fontName = sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id)
style.fontName = sco_preferences.get_preference(
context, "PV_FONTNAME", formsemestre_id
)
style.leading = 18
style.alignment = TA_JUSTIFY
@ -443,8 +447,8 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context
else:
params["decisions_ue_descr_plural"] = ""
params["INSTITUTION_CITY"] = sco_preferences.get_preference(context,
"INSTITUTION_CITY", formsemestre_id
params["INSTITUTION_CITY"] = sco_preferences.get_preference(
context, "INSTITUTION_CITY", formsemestre_id
)
if decision["prev_decision_sem"]:
params["prev_semestre_id"] = decision["prev"]["semestre_id"]
@ -512,7 +516,9 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context
# Corps de la lettre:
objects += sco_bulletins_pdf.process_field(
context,
sco_preferences.get_preference(context, "PV_LETTER_TEMPLATE", sem["formsemestre_id"]),
sco_preferences.get_preference(
context, "PV_LETTER_TEMPLATE", sem["formsemestre_id"]
),
params,
style,
suppress_empty_pars=True,
@ -523,7 +529,9 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context
# chef de département.
if Se.semestre_non_terminal:
sig = (
sco_preferences.get_preference(context, "PV_LETTER_PASSAGE_SIGNATURE", formsemestre_id)
sco_preferences.get_preference(
context, "PV_LETTER_PASSAGE_SIGNATURE", formsemestre_id
)
% params
)
sig = _simulate_br(sig, '<para leftindent="%(htab1)s">')
@ -538,7 +546,9 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None, context
)
else:
sig = (
sco_preferences.get_preference(context, "PV_LETTER_DIPLOMA_SIGNATURE", formsemestre_id)
sco_preferences.get_preference(
context, "PV_LETTER_DIPLOMA_SIGNATURE", formsemestre_id
)
% params
)
sig = _simulate_br(sig, '<para leftindent="%(htab1)s">')
@ -580,13 +590,17 @@ def _make_signature_image(signature, leftindent, formsemestre_id, context=None):
im = PILImage.open(f)
width, height = im.size
pdfheight = (
1.0 * sco_preferences.get_preference(context, "pv_sig_image_height", formsemestre_id) * mm
1.0
* sco_preferences.get_preference(
context, "pv_sig_image_height", formsemestre_id
)
* mm
)
f.seek(0, 0)
style = styles.ParagraphStyle({})
style.leading = 1.0 * sco_preferences.get_preference(context,
"SCOLAR_FONT_SIZE", formsemestre_id
style.leading = 1.0 * sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space
style.leftIndent = leftindent
return Table(
@ -702,14 +716,18 @@ def _pvjury_pdf_type(
style = reportlab.lib.styles.ParagraphStyle({})
style.fontSize = 12
style.fontName = sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id)
style.fontName = sco_preferences.get_preference(
context, "PV_FONTNAME", formsemestre_id
)
style.leading = 18
style.alignment = TA_JUSTIFY
indent = 1 * cm
bulletStyle = reportlab.lib.styles.ParagraphStyle({})
bulletStyle.fontSize = 12
bulletStyle.fontName = sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id)
bulletStyle.fontName = sco_preferences.get_preference(
context, "PV_FONTNAME", formsemestre_id
)
bulletStyle.leading = 12
bulletStyle.alignment = TA_JUSTIFY
bulletStyle.firstLineIndent = 0
@ -761,7 +779,9 @@ def _pvjury_pdf_type(
% {
"Decnum": numeroArrete,
"VDICode": VDICode,
"UnivName": sco_preferences.get_preference(context, "UnivName", formsemestre_id),
"UnivName": sco_preferences.get_preference(
context, "UnivName", formsemestre_id
),
"Type": titre_jury,
"Date": date_commission, # deprecated
"date_commission": date_commission,
@ -787,10 +807,14 @@ def _pvjury_pdf_type(
titles = [titles.get(x, "") for x in columns_ids]
# Make a new cell style and put all cells in paragraphs
cell_style = styles.ParagraphStyle({})
cell_style.fontSize = sco_preferences.get_preference(context, "SCOLAR_FONT_SIZE", formsemestre_id)
cell_style.fontName = sco_preferences.get_preference(context, "PV_FONTNAME", formsemestre_id)
cell_style.leading = 1.0 * sco_preferences.get_preference(context,
"SCOLAR_FONT_SIZE", formsemestre_id
cell_style.fontSize = sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id
)
cell_style.fontName = sco_preferences.get_preference(
context, "PV_FONTNAME", formsemestre_id
)
cell_style.leading = 1.0 * sco_preferences.get_preference(
context, "SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space
LINEWIDTH = 0.5
table_style = [
@ -826,8 +850,10 @@ def _pvjury_pdf_type(
"""<para spaceBefore="10mm" align="right">
%s, %s</para>"""
% (
sco_preferences.get_preference(context, "DirectorName", formsemestre_id) or "",
sco_preferences.get_preference(context, "DirectorTitle", formsemestre_id) or "",
sco_preferences.get_preference(context, "DirectorName", formsemestre_id)
or "",
sco_preferences.get_preference(context, "DirectorTitle", formsemestre_id)
or "",
),
style,
)

View File

@ -75,7 +75,9 @@ def formsemestre_recapcomplet(
) # cache les colonnes des modules
pref_override = int(pref_override)
if pref_override:
hidebac = int(sco_preferences.get_preference(context, "recap_hidebac", formsemestre_id))
hidebac = int(
sco_preferences.get_preference(context, "recap_hidebac", formsemestre_id)
)
else:
hidebac = int(hidebac)
xml_with_decisions = int(xml_with_decisions)
@ -84,7 +86,8 @@ def formsemestre_recapcomplet(
H = []
if not isFile:
H += [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title="Récapitulatif",
no_side_bar=True,
@ -271,7 +274,7 @@ def make_formsemestre_recapcomplet(
sem = sco_formsemestre.do_formsemestre_list(
context, args={"formsemestre_id": formsemestre_id}
)[0]
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_modimpls, get_ues, get_table_moyennes_triees, get_etud_decision_sem, get_etud_etat, get_etud_rang, get_nom_short, get_mod_stats, nt.moy_moy, get_etud_decision_sem,
modimpls = nt.get_modimpls()
@ -486,7 +489,9 @@ def make_formsemestre_recapcomplet(
if key == "nb_valid_evals":
l.append("")
elif key == "coef":
if sco_preferences.get_preference(context, "use_ue_coefs", formsemestre_id):
if sco_preferences.get_preference(
context, "use_ue_coefs", formsemestre_id
):
l.append("%2.3f" % ue["coefficient"])
else:
l.append("")
@ -853,7 +858,7 @@ def _formsemestre_recapcomplet_xml(
):
"XML export: liste tous les bulletins XML."
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_table_moyennes_triees
T = nt.get_table_moyennes_triees()
@ -920,7 +925,7 @@ def _formsemestre_recapcomplet_json(
"bulletins": [],
}
bulletins = J["bulletins"]
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_table_moyennes_triees
T = nt.get_table_moyennes_triees()

View File

@ -55,7 +55,7 @@ MAX_ETUD_IN_DESCR = 20
def formsemestre_etuds_stats(context, sem, only_primo=False):
"""Récupère liste d'etudiants avec etat et decision."""
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, sem["formsemestre_id"]
) # > get_table_moyennes_triees, identdict, get_etud_decision_sem, get_etud_etat,
T = nt.get_table_moyennes_triees()
@ -404,7 +404,7 @@ def table_suivi_cohorte(
logt("table_suivi_cohorte: start")
# 1-- Liste des semestres posterieurs dans lesquels ont été les etudiants de sem
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids, get_etud_decision_sem
etudids = nt.get_etudids()
@ -458,7 +458,7 @@ def table_suivi_cohorte(
s["members"] = orig_set.intersection(inset)
nb_dipl = 0 # combien de diplomes dans ce semestre ?
if s["semestre_id"] == nt.parcours.NB_SEM:
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, s["formsemestre_id"]
) # > get_etud_decision_sem
for etudid in s["members"]:
@ -908,7 +908,7 @@ def _descr_etud_set(context, etudids):
def _count_dem_reo(context, formsemestre_id, etudids):
"count nb of demissions and reorientation in this etud set"
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_etat, get_etud_decision_sem
dems = set()
@ -974,7 +974,7 @@ def get_codeparcoursetud(context, etud, prefix="", separator=""):
i = len(sems) - 1
while i >= 0:
s = sems[i] # 'sems' est a l'envers, du plus recent au plus ancien
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, s["formsemestre_id"]
) # > get_etud_etat, get_etud_decision_sem
p.append(_codesem(s, prefix=prefix))
@ -1021,7 +1021,7 @@ def tsp_etud_list(
"""
# log('tsp_etud_list(%s, bac="%s")' % (formsemestre_id,bac))
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids,
etudids = nt.get_etudids()
@ -1273,7 +1273,7 @@ def graph_parcours(
nxt = {}
etudid = etud["etudid"]
for s in etud["sems"]: # du plus recent au plus ancien
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, s["formsemestre_id"]
) # > get_etud_decision_sem, get_etud_etat
dec = nt.get_etud_decision_sem(etudid)

View File

@ -44,6 +44,7 @@ from sco_exceptions import (
ScoValueError,
)
from sco_permissions import ScoEditAllNotes
import sco_core
import sco_formsemestre
import sco_moduleimpl
import sco_groups
@ -458,7 +459,11 @@ def evaluation_suppress_alln(context, evaluation_id, REQUEST, dialog_confirmed=F
url=mod["url"],
)
return html_sco_header.sco_header(context, REQUEST) + "\n".join(H) + html_sco_header.sco_footer(context, REQUEST)
return (
html_sco_header.sco_header(context, REQUEST)
+ "\n".join(H)
+ html_sco_header.sco_footer(context, REQUEST)
)
def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
@ -577,15 +582,19 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
log("*** exception in _notes_add")
if do_it:
# inval cache
context._inval_cache(
formsemestre_id=M["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=M["formsemestre_id"]
) # > modif notes (exception)
cnx.rollback() # abort
raise # re-raise exception
if do_it:
cnx.commit()
context._inval_cache(formsemestre_id=M["formsemestre_id"]) # > modif notes
context.get_evaluations_cache().inval_cache(key=evaluation_id)
sco_core.inval_cache(
context, formsemestre_id=M["formsemestre_id"]
) # > modif notes
sco_core.get_evaluations_cache(
context,
).inval_cache(key=evaluation_id)
return nb_changed, nb_suppress, existing_decisions
@ -627,7 +636,8 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
)
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title=page_title,
javascripts=sco_groups_view.JAVASCRIPTS,
@ -845,7 +855,7 @@ def has_existing_decision(context, M, E, etudid):
Si oui, return True
"""
formsemestre_id = M["formsemestre_id"]
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_decision_sem, get_etud_decision_ues
if nt.get_etud_decision_sem(etudid):
@ -908,7 +918,8 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
# HTML page:
H = [
html_sco_header.sco_header(context,
html_sco_header.sco_header(
context,
REQUEST,
page_title=page_title,
javascripts=sco_groups_view.JAVASCRIPTS + ["js/saisie_notes.js"],

View File

@ -229,9 +229,9 @@ class SemSet(dict):
self["etuds_without_nip"] = set() # etudids
self["jury_ok"] = True
for sem in self.sems:
nt = context._getNotesCache().get_NotesTable(
context, sem["formsemestre_id"]
)
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
sem["etuds"] = nt.identdict.values()
sem["nips"] = {e["code_nip"] for e in sem["etuds"] if e["code_nip"]}
sem["etuds_without_nip"] = {

View File

@ -105,7 +105,9 @@ def formsemestre_synchro_etuds(
"""
% sem
)
header = html_sco_header.sco_header(context, REQUEST, page_title="Synchronisation étudiants")
header = html_sco_header.sco_header(
context, REQUEST, page_title="Synchronisation étudiants"
)
footer = html_sco_header.sco_footer(context, REQUEST)
base_url = "%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id)
if anneeapogee:
@ -667,7 +669,8 @@ def do_import_etuds_from_portal(context, sem, a_importer, etudsapo_ident, REQUES
)
cnx.commit()
log("do_import_etuds_from_portal: re-raising exception")
context._inval_cache() # > import: modif identite, adresses, inscriptions
# > import: modif identite, adresses, inscriptions
sco_core.inval_cache(context)
raise
sco_news.add(
@ -846,7 +849,7 @@ def formsemestre_import_etud_admission(
changed_mails.append((info, etud["mail"]))
else:
unknowns.append(code_nip)
context._inval_cache(formsemestre_id=sem["formsemestre_id"])
sco_core.inval_cache(context, formsemestre_id=sem["formsemestre_id"])
return no_nip, unknowns, changed_mails

View File

@ -273,7 +273,9 @@ def get_etud_tagged_modules(context, etudid, tagname):
etud = context.getEtudInfo(etudid=etudid, filled=True)[0]
R = []
for sem in etud["sems"]:
nt = context._getNotesCache().get_NotesTable(context, sem["formsemestre_id"])
nt = sco_core.get_notes_cache(
context,
).get_NotesTable(context, sem["formsemestre_id"])
modimpls = nt.get_modimpls()
for modimpl in modimpls:
tags = module_tag_list(context, module_id=modimpl["module_id"])
@ -341,5 +343,5 @@ sem = etud['sems'][0]
[ tm['moy'] for tm in get_etud_tagged_modules(context, etudid, 'allo') ]
# si besoin après modif par le Web:
# context._inval_cache()
# sco_core.inval_cache(context)
"""

View File

@ -52,6 +52,7 @@ import sco_utils as scu
import notesdb as ndb
from notes_log import log
from gen_tables import GenTable
import sco_core
import sco_formsemestre
import sco_moduleimpl
import VERSION
@ -95,7 +96,7 @@ class NotesOperation(dict):
# # il y a-t-il une modif plus recente ?
# if self['current_notes_by_etud']['date'] <= self['date'] + OPERATION_DATE_TOLERANCE:
#
# + invalider cache context.get_evaluations_cache().inval_cache(key=evaluation_id)
# + invalider cache sco_core.get_evaluations_cache(context, ).inval_cache(key=evaluation_id)
def list_operations(context, evaluation_id):

View File

@ -385,7 +385,9 @@ def identite_edit(cnx, args, context=None, REQUEST=None):
notify_to = None
if context:
try:
notify_to = sco_preferences.get_preference(context, "notify_etud_changes_to")
notify_to = sco_preferences.get_preference(
context, "notify_etud_changes_to"
)
except:
pass
@ -498,7 +500,9 @@ def adresse_edit(cnx, args, context=None):
notify_to = None
if context:
try:
notify_to = sco_preferences.get_preference(context, "notify_etud_changes_to")
notify_to = sco_preferences.get_preference(
context, "notify_etud_changes_to"
)
except:
pass
if notify_to:
@ -890,7 +894,7 @@ def fillEtudsInfo(context, etuds):
# open('/tmp/t','w').write( str(etuds) )
for etud in etuds:
etudid = etud["etudid"]
etud["dept"] = context.DeptId()
etud["dept"] = sco_core.get_dept_id()
adrs = adresse_list(cnx, {"etudid": etudid})
if not adrs:
# certains "vieux" etudiants n'ont pas d'adresse

View File

@ -68,13 +68,12 @@ from app.scodoc.sco_exceptions import (
AccessDenied,
)
from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.notes_table import NOTES_CACHE_INST, CacheNotesTable
import app.scodoc.VERSION as VERSION
from app.scodoc.sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_permissions import Permission, ScoImplement
from app.scodoc.TrivialFormulator import TrivialFormulator
from app.scodoc import sco_core
from app.scodoc import htmlutils
from app.scodoc import notes_table
from app.scodoc import pe_view
@ -163,42 +162,8 @@ sco_publish("/essai2", essai2, Permission.ScoImplement)
# ---------------------
#
# Cache global: chaque instance, repérée par sa connexion db, a un cache
# qui est recréé à la demande
#
CACHE_formsemestre_inscription = {}
CACHE_evaluations = {}
# ---------------
def _getNotesCache(context):
"returns CacheNotesTable instance for us"
u = sco_mgr.get_db_uri() # identifie le dept de facon unique
if not NOTES_CACHE_INST.has_key(u):
log("getNotesCache: creating cache for %s" % u)
NOTES_CACHE_INST[u] = CacheNotesTable()
return NOTES_CACHE_INST[u]
def _inval_cache(
context, formsemestre_id=None, pdfonly=False, formsemestre_id_list=None
): # >
"expire cache pour un semestre (ou tous si pas d'argument)"
if formsemestre_id_list:
for formsemestre_id in formsemestre_id_list:
context._getNotesCache().inval_cache(
context, formsemestre_id=formsemestre_id, pdfonly=pdfonly
)
# Affecte aussi cache inscriptions
context.get_formsemestre_inscription_cache().inval_cache(
key=formsemestre_id
)
else:
context._getNotesCache().inval_cache(
context, formsemestre_id=formsemestre_id, pdfonly=pdfonly
)
# Affecte aussi cache inscriptions
context.get_formsemestre_inscription_cache().inval_cache(key=formsemestre_id)
@bp.route("/clearcache")
@ -210,7 +175,7 @@ def clearcache(context, REQUEST=None):
# Debugging code: compare results before and after cache reconstruction
# (_should_ be identicals !)
# Compare XML representation
cache = context._getNotesCache()
cache = sco_core.get_notes_cache(context)
formsemestre_ids = cache.get_cached_formsemestre_ids()
docs_before = []
for formsemestre_id in formsemestre_ids:
@ -686,7 +651,8 @@ def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=
)
cnx = context.GetDBConnexion()
context._ueEditor.delete(cnx, ue_id)
context._inval_cache() # > 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 ?):
sco_core.inval_cache(context)
# news
F = context.formation_list(args={"formation_id": ue["formation_id"]})[0]
sco_news.add(
@ -801,7 +767,7 @@ def do_matiere_edit(context, *args, **kw):
raise ScoLockedFormError()
# edit
context._matiereEditor.edit(cnx, *args, **kw)
context._inval_cache() # > modif matiere
sco_core.inval_cache(context) # > modif matiere
@bp.route("/do_matiere_formation_id")
@ -941,8 +907,8 @@ def do_module_edit(context, val):
context, args={"formation_id": mod["formation_id"]}
)
if sems:
context._inval_cache(
formsemestre_id_list=[s["formsemestre_id"] for s in sems]
sco_core.inval_cache(
context, formsemestre_id_list=[s["formsemestre_id"] for s in sems]
) # > modif module
@ -1498,8 +1464,8 @@ def edit_moduleimpl_expr(context, REQUEST, moduleimpl_id):
},
formsemestre_id=sem["formsemestre_id"],
)
context._inval_cache(
formsemestre_id=sem["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=sem["formsemestre_id"]
) # > modif regle calcul
return REQUEST.RESPONSE.redirect(
"moduleimpl_status?moduleimpl_id="
@ -1649,7 +1615,9 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
else:
sco_compute_moy.formsemestre_ue_computation_expr_create(cnx, tf[2])
context._inval_cache(formsemestre_id=formsemestre_id) # > modif regle calcul
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif regle calcul
return REQUEST.RESPONSE.redirect(
"formsemestre_status?formsemestre_id="
+ formsemestre_id
@ -1808,8 +1776,8 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
commit=False,
)
#
context._inval_cache(
formsemestre_id=args["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=args["formsemestre_id"]
) # > inscription au semestre
return r
@ -1822,8 +1790,8 @@ def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
cnx = context.GetDBConnexion()
context._formsemestre_inscriptionEditor.delete(cnx, oid)
context._inval_cache(
formsemestre_id=formsemestre_id
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > desinscription du semestre
@ -1843,7 +1811,7 @@ def do_formsemestre_inscription_listinscrits(
context, formsemestre_id, format=None, REQUEST=None
):
"""Liste les inscrits (état I) à ce semestre et cache le résultat"""
cache = context.get_formsemestre_inscription_cache()
cache = sco_core.get_formsemestre_inscription_cache(context, )
r = cache.get(formsemestre_id)
if r is None:
# retreive list
@ -1861,8 +1829,8 @@ def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
"edit a formsemestre_inscription"
cnx = context.GetDBConnexion()
context._formsemestre_inscriptionEditor.edit(cnx, args)
context._inval_cache(
formsemestre_id=formsemestre_id
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
) # > modif inscription semestre (demission ?)
@ -1894,7 +1862,7 @@ def formsemestre_desinscription(
raise ScoValueError("desinscription impossible: semestre verrouille")
# -- Si décisions de jury, désinscription interdite
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
nt = sco_core.get_notes_cache(context).get_NotesTable(context, formsemestre_id)
if nt.etud_has_decision(etudid):
raise ScoValueError(
"""Désinscription impossible: l'étudiant a une décision de jury
@ -1969,7 +1937,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
raise ScoValueError("desinscription impossible: semestre verrouille")
# -- Si decisions de jury, desinscription interdite
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
nt = sco_core.get_notes_cache(context).get_NotesTable(context, formsemestre_id)
if nt.etud_has_decision(etudid):
raise ScoValueError(
"desinscription impossible: l'étudiant a une décision de jury (la supprimer avant si nécessaire)"
@ -2453,8 +2421,8 @@ def do_evaluation_edit(context, REQUEST, args):
context._evaluationEditor.edit(cnx, args)
# inval cache pour ce semestre
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
context._inval_cache(
formsemestre_id=M["formsemestre_id"]
sco_core.inval_cache(
context, formsemestre_id=M["formsemestre_id"]
) # > evaluation_edit (coef, ...)
@ -2552,17 +2520,6 @@ sco_publish(
)
# cache notes evaluations
def get_evaluations_cache(context):
u = context.GetDBConnexionString()
if CACHE_evaluations.has_key(u):
return CACHE_evaluations[u]
else:
log("get_evaluations_cache: new simpleCache")
CACHE_evaluations[u] = sco_cache.simpleCache()
return CACHE_evaluations[u]
def _notes_getall(
context, evaluation_id, table="notes_notes", filter_suppressed=True, by_uid=None
):
@ -2574,7 +2531,7 @@ def _notes_getall(
filter_suppressed and table == "notes_notes" and (by_uid is None)
) # pas de cache pour (rares) appels via undo_notes ou specifiant un enseignant
if do_cache:
cache = context.get_evaluations_cache()
cache = sco_core.get_evaluations_cache(context)
r = cache.get(evaluation_id)
if r != None:
return r
@ -2652,7 +2609,7 @@ def formsemestre_bulletins_mailetuds(
):
"envoi a chaque etudiant (inscrit et ayant un mail) son bulletin"
prefer_mail_perso = int(prefer_mail_perso)
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etudids
etudids = nt.get_etudids()
@ -2809,8 +2766,8 @@ def appreciation_add_form(
msg=tf[2]["comment"],
)
# ennuyeux mais necessaire (pour le PDF seulement)
context._inval_cache(
pdfonly=True, formsemestre_id=formsemestre_id
sco_core.inval_cache(
context, pdfonly=True, formsemestre_id=formsemestre_id
) # > appreciation_add
return REQUEST.RESPONSE.redirect(bull_url)
@ -3096,7 +3053,7 @@ def formsemestre_validation_suppress_etud(
if not dialog_confirmed:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
etud = context.getEtudInfo(etudid=etudid, filled=1)[0]
nt = context._getNotesCache().get_NotesTable(
nt = sco_core.get_notes_cache(context).get_NotesTable(
context, formsemestre_id
) # > get_etud_decision_sem
decision_jury = nt.get_etud_decision_sem(etudid)

View File

@ -164,13 +164,6 @@ log("ScoDoc8 restarting...")
#
# --------------------------------------------------------------------
# ? à déplacer ?
def DeptId():
if g.scodoc_dept in sco_mgr.get_dept_ids():
return g.scodoc_dept
raise ScoInvalidDept("département invalide: %s" % g.scodoc_dept)
# sco_publish(
# "/formsemestre_evaluations_delai_correction",
# sco_evaluations.formsemestre_evaluations_delai_correction,
@ -304,7 +297,9 @@ def rssnews(context, REQUEST=None):
"rss feed"
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
return sco_news.scolar_news_summary_rss(
context, "Nouvelles de " + sco_preferences.get_preference(context, "DeptName"), context.ScoURL()
context,
"Nouvelles de " + sco_preferences.get_preference(context, "DeptName"),
context.ScoURL(),
)