1
0
forked from ScoDoc/ScoDoc

WIP migration / cnx

This commit is contained in:
Emmanuel Viennet 2021-06-15 13:59:56 +02:00
parent 3af2c460b7
commit f4611af10e
46 changed files with 246 additions and 237 deletions

View File

@ -606,7 +606,7 @@ def scolars_import_admission(
if not data:
raise ScoException("scolars_import_admission: empty file !")
diag += diag2
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
titles = data[0]
# idx -> ('field', convertor)

View File

@ -168,7 +168,7 @@ class NotesTable:
raise ScoValueError("invalid formsemestre_id (%s)" % formsemestre_id)
self.context = context
self.formsemestre_id = formsemestre_id
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
self.moduleimpl_stats = {} # { moduleimpl_id : {stats} }
self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap
@ -1034,7 +1034,7 @@ class NotesTable:
Si la decision n'a pas été prise, la clé etudid n'est pas présente.
Si l'étudiant est défaillant, met un code DEF sur toutes les UE
"""
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select etudid, code, assidu, compense_formsemestre_id, event_date from scolar_formsemestre_validation where formsemestre_id=%(formsemestre_id)s and ue_id is NULL;",
@ -1295,7 +1295,7 @@ class NotesTable:
"""Vrai si cet etudiant a au moins une note en attente dans ce semestre.
(ne compte que les notes en attente dans des évaluation avec coef. non nul).
"""
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select n.* from notes_notes n, notes_evaluation e, notes_moduleimpl m, notes_moduleimpl_inscription i where n.etudid = %(etudid)s and n.value = %(code_attente)s and n.evaluation_id=e.evaluation_id and e.moduleimpl_id=m.moduleimpl_id and m.formsemestre_id=%(formsemestre_id)s and e.coefficient != 0 and m.moduleimpl_id=i.moduleimpl_id and i.etudid=%(etudid)s",

View File

@ -39,12 +39,13 @@ def unquote(s):
_pools = {}
def GetDBConnexion(context, autocommit=True):
pool = _pools.get(context._db_cnx_string, None)
def GetDBConnexion(autocommit=True):
"""connexion to the DB of a departement"""
pool = _pools.get(scu.get_db_cnx_string(), None)
if not pool:
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=context._db_cnx_string)
_pools[context._db_cnx_string] = pool
# log('GetDBConnexion: created pool for "%s"' % context._db_cnx_string)
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=scu.get_db_cnx_string())
_pools[scu.get_db_cnx_string()] = pool
# log('GetDBConnexion: created pool for "%s"' % scu.get_db_cnx_string())
cnx = pool.getconn(key=(thread.get_ident(), autocommit))
# log('GetDBConnexion: autocommit=%s cnx=%s' % (autocommit,cnx))
if cnx.autocommit != autocommit:
@ -57,11 +58,11 @@ _users_pools = {}
def GetUsersDBConnexion(context, autocommit=True):
pool = _users_pools.get(context._db_cnx_string, None)
pool = _users_pools.get(scu.get_db_cnx_string(), None)
if not pool:
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=context._db_cnx_string)
_users_pools[context._db_cnx_string] = pool
log('GetUsersDBConnexion: created pool for "%s"' % context._db_cnx_string)
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=scu.get_db_cnx_string())
_users_pools[scu.get_db_cnx_string()] = pool
log('GetUsersDBConnexion: created pool for "%s"' % scu.get_db_cnx_string())
cnx = pool.getconn(key=(thread.get_ident(), autocommit))
if cnx.autocommit != autocommit:
cnx.autocommit = autocommit
@ -87,7 +88,7 @@ class ScoDocCursor(psycopg2.extensions.cursor):
def SimpleQuery(context, query, args, cursor=None):
if not cursor:
cnx = context.GetDBConnexion()
cnx = GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
# log( 'SimpleQuery(%s)' % (query % args) )
cursor.execute(query, args)

View File

@ -37,6 +37,7 @@ import scolars
import pe_jurype, pe_tagtable, pe_tools
import sco_utils as scu
import notesdb as ndb
from notes_log import log
import scolars
@ -240,7 +241,7 @@ def get_annotation_PE(context, etudid, tag_annotation_pe):
Result: chaine unicode
"""
if tag_annotation_pe:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
annotations = scolars.etud_annotations_list(
cnx, args={"etudid": etudid}
) # Les annotations de l'étudiant

View File

@ -110,7 +110,7 @@ def abs_notify_send(
context, destinations, etudid, msg, nbabs, nbabsjust, formsemestre_id
):
"""Actually send the notification by email, and register it in database"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
log("abs_notify: sending notification to %s" % destinations)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for email in destinations:
@ -203,7 +203,7 @@ def abs_notify_is_above_threshold(context, etudid, nbabs, nbabsjust, formsemestr
def etud_nbabs_last_notified(context, etudid, formsemestre_id=None):
"""nbabs lors de la dernière notification envoyée pour cet étudiant dans ce semestre
ou sans semestre (ce dernier cas est nécessaire pour la transition au nouveau code)"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""select * from absences_notifications where etudid = %(etudid)s and (formsemestre_id = %(formsemestre_id)s or formsemestre_id is NULL) order by notification_date desc""",
@ -218,7 +218,7 @@ def etud_nbabs_last_notified(context, etudid, formsemestre_id=None):
def user_nbdays_since_last_notif(context, email_addr, etudid):
"""nb days since last notification to this email, or None if no previous notification"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""select * from absences_notifications where email = %(email_addr)s and etudid=%(etudid)s order by notification_date desc""",

View File

@ -198,7 +198,7 @@ def formsemestre_bulletinetud_dict(
I["filigranne"] = prefs["bul_temporary_txt"]
# --- Appreciations
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)
@ -655,7 +655,7 @@ def etud_descr_situation_semestre(
descr_decisions_ue : ' UE acquises: UE1, UE2', ou vide si pas de dec. ou si pas show_uevalid
descr_mention : 'Mention Bien', ou vide si pas de mention ou si pas show_mention
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
infos = scu.DictDefault(defaultvalue="")
# --- Situation et décisions jury

View File

@ -400,7 +400,7 @@ def formsemestre_bulletinetud_published_dict(
d["decision"] = dict(code="", etat="DEM")
# --- Appreciations
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)

View File

@ -412,7 +412,7 @@ def make_xml_formsemestre_bulletinetud(
doc.decision(code="", etat="DEM")
doc._pop()
# --- Appreciations
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
)

View File

@ -68,7 +68,7 @@ def formsemestre_expressions_use_abscounts(context, formsemestre_id):
"""
# check presence of 'nbabs' in expressions
ab = "nb_abs" # chaine recherchée
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# 1- moyennes d'UE:
elist = formsemestre_ue_computation_expr_list(
cnx, {"formsemestre_id": formsemestre_id}

View File

@ -32,7 +32,7 @@ from types import StringType
import safehtml
import sco_utils as scu
import notesdb
import ndb as ndb
from notes_log import log
import VERSION
from sco_exceptions import AccessDenied
@ -78,7 +78,7 @@ def get_etudids_with_debouche(context, start_year):
start_date = str(start_year) + "-01-01"
# Recupere tous les etudid avec un debouché renseigné et une inscription dans un semestre
# posterieur à la date de depart:
# r = notesdb.SimpleDictFetch(context,
# r = ndb.SimpleDictFetch(context,
# """SELECT DISTINCT i.etudid
# FROM notes_formsemestre_inscription i, admissions adm, notes_formsemestre s
# WHERE adm.debouche is not NULL
@ -87,7 +87,7 @@ def get_etudids_with_debouche(context, start_year):
# """,
# {'start_date' : start_date })
r = notesdb.SimpleDictFetch(
r = ndb.SimpleDictFetch(
context,
"""SELECT DISTINCT i.etudid
FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it
@ -215,7 +215,7 @@ def report_debouche_ask_date(context, REQUEST=None):
# raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
# adm_id = object
# debouche = value.strip('-_ \t')
# cnx = context.GetDBConnexion()
# cnx = ndb.GetDBConnexion()
# adms = scolars.admission_list(cnx, {'etudid' : etudid})
# if not adms:
# raise ValueError('no admission info for %s !' % etudid)
@ -224,7 +224,7 @@ def report_debouche_ask_date(context, REQUEST=None):
# admission_edit(cnx, adm)
_itemsuiviEditor = notesdb.EditableTable(
_itemsuiviEditor = ndb.EditableTable(
"itemsuivi",
"itemsuivi_id",
("itemsuivi_id", "etudid", "item_date", "situation"),
@ -232,9 +232,9 @@ _itemsuiviEditor = notesdb.EditableTable(
convert_null_outputs_to_empty=True,
output_formators={
"situation": safehtml.HTML2SafeHTML,
"item_date": notesdb.DateISOtoDMY,
"item_date": ndb.DateISOtoDMY,
},
input_formators={"item_date": notesdb.DateDMYtoISO},
input_formators={"item_date": ndb.DateDMYtoISO},
)
_itemsuivi_create = _itemsuiviEditor.create
@ -265,7 +265,7 @@ def itemsuivi_suppress(context, itemsuivi_id, REQUEST=None):
"""Suppression d'un item"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
item = itemsuivi_get(cnx, itemsuivi_id, ignore_errors=True)
if item:
_itemsuivi_delete(cnx, itemsuivi_id)
@ -279,7 +279,7 @@ def itemsuivi_create(
"""Creation d'un item"""
if not sco_permissions.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
itemsuivi_id = _itemsuivi_create(
cnx, args={"etudid": etudid, "item_date": item_date, "situation": situation}
)
@ -298,7 +298,7 @@ def itemsuivi_set_date(context, itemsuivi_id, item_date, REQUEST=None):
if not sco_permissions.can_edit_suivi(context, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
# log('itemsuivi_set_date %s : %s' % (itemsuivi_id, item_date))
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
item = itemsuivi_get(cnx, itemsuivi_id)
item["item_date"] = item_date
_itemsuivi_edit(cnx, item)
@ -311,7 +311,7 @@ def itemsuivi_set_situation(context, object, value, REQUEST=None):
itemsuivi_id = object
situation = value.strip("-_ \t")
# log('itemsuivi_set_situation %s : %s' % (itemsuivi_id, situation))
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
item = itemsuivi_get(cnx, itemsuivi_id)
item["situation"] = situation
_itemsuivi_edit(cnx, item)
@ -320,7 +320,7 @@ def itemsuivi_set_situation(context, object, value, REQUEST=None):
def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None):
"""Liste des items pour cet étudiant, avec tags"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
items = _itemsuivi_list(cnx, {"etudid": etudid})
for it in items:
it["tags"] = ", ".join(itemsuivi_tag_list(context, it["itemsuivi_id"]))
@ -331,7 +331,7 @@ def itemsuivi_list_etud(context, etudid, format=None, REQUEST=None):
def itemsuivi_tag_list(context, itemsuivi_id):
"""les noms de tags associés à cet item"""
r = notesdb.SimpleDictFetch(
r = ndb.SimpleDictFetch(
context,
"""SELECT t.title
FROM itemsuivi_tags_assoc a, itemsuivi_tags t
@ -349,7 +349,7 @@ def itemsuivi_tag_search(context, term, REQUEST=None):
if not scu.ALPHANUM_EXP.match(term.decode(scu.SCO_ENCODING)):
data = []
else:
r = notesdb.SimpleDictFetch(
r = ndb.SimpleDictFetch(
context,
"SELECT title FROM itemsuivi_tags WHERE title LIKE %(term)s",
{"term": term + "%"},
@ -373,7 +373,7 @@ def itemsuivi_tag_set(context, itemsuivi_id="", taglist=[], REQUEST=None):
taglist = [t.strip() for t in taglist]
# log('itemsuivi_tag_set: itemsuivi_id=%s taglist=%s' % (itemsuivi_id, taglist))
# Sanity check:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_ = itemsuivi_get(cnx, itemsuivi_id)
newtags = set(taglist)

View File

@ -232,7 +232,7 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
def do_formation_create(context, args, REQUEST):
"create a formation"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check unique acronyme/titre/version
a = args.copy()
if a.has_key("formation_id"):
@ -270,7 +270,7 @@ def do_formation_edit(context, args):
if args.has_key("formation_code") and not args["formation_code"]:
del args["formation_code"]
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sco_formations._formationEditor.edit(cnx, args)
# Invalide les semestres utilisant cette formation:

View File

@ -752,7 +752,7 @@ def do_ue_edit(context, args, bypass_lock=False, dont_invalidate_cache=False):
if args.has_key("ue_code") and not args["ue_code"]:
del args["ue_code"]
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._ueEditor.edit(cnx, args)
if not dont_invalidate_cache:

View File

@ -31,6 +31,7 @@
import datetime
import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO
@ -199,58 +200,58 @@ _entreprise_contactEditor = EditableTable(
def do_entreprise_create(context, args):
"entreprise_create"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _entreprisesEditor.create(cnx, args)
return r
def do_entreprise_delete(context, oid):
"entreprise_delete"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprisesEditor.delete(cnx, oid)
def do_entreprise_list(context, **kw):
"entreprise_list"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
kw["context"] = context
return _entreprisesEditor.list(cnx, **kw)
def do_entreprise_list_by_etud(context, **kw):
"entreprise_list_by_etud"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return _entreprisesEditor.list_by_etud(cnx, **kw)
def do_entreprise_edit(context, *args, **kw):
"entreprise_edit"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprisesEditor.edit(cnx, *args, **kw)
def do_entreprise_correspondant_create(context, args):
"entreprise_correspondant_create"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _entreprise_correspEditor.create(cnx, args)
return r
def do_entreprise_correspondant_delete(context, oid):
"entreprise_correspondant_delete"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.delete(cnx, oid)
def do_entreprise_correspondant_list(context, **kw):
"entreprise_correspondant_list"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return _entreprise_correspEditor.list(cnx, **kw)
def do_entreprise_correspondant_edit(context, *args, **kw):
"entreprise_correspondant_edit"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.edit(cnx, *args, **kw)
@ -262,25 +263,25 @@ def do_entreprise_correspondant_listnames(context, args={}):
def do_entreprise_contact_delete(context, oid):
"entreprise_contact_delete"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.delete(cnx, oid)
def do_entreprise_contact_list(context, **kw):
"entreprise_contact_list"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return _entreprise_contactEditor.list(cnx, **kw)
def do_entreprise_contact_edit(context, *args, **kw):
"entreprise_contact_edit"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.edit(cnx, *args, **kw)
def do_entreprise_contact_create(context, args):
"entreprise_contact_create"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _entreprise_contactEditor.create(cnx, args)
return r
@ -295,7 +296,7 @@ def do_entreprise_check_etudiant(context, etudiant):
) # suppress parens and quote from name
if not etudiant:
return 1, None
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(
"select etudid, nom, prenom from identite where upper(nom) ~ upper(%(etudiant)s) or etudid=%(etudiant)s",

View File

@ -34,6 +34,7 @@ import datetime
from notes_log import log, logCallStack
import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor
from sco_exceptions import AccessDenied, ScoValueError
import VERSION
@ -99,7 +100,7 @@ def do_evaluation_delete(context, REQUEST, evaluation_id):
moduleimpl_id = the_evals[0]["moduleimpl_id"]
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._evaluationEditor.delete(cnx, evaluation_id)
# inval cache pour ce semestre
@ -346,7 +347,7 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
"""
req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id order by moduleimpl_id, numero desc, jour desc, heure_debut desc"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(req, {"formsemestre_id": formsemestre_id})
res = cursor.dictfetchall()
@ -363,7 +364,7 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
# def formsemestre_evaluations_list(context, formsemestre_id):
# """Liste (non triée) des evals pour ce semestre"""
# req = "select E.* from notes_evaluation E, notes_moduleimpl MI where MI.formsemestre_id = %(formsemestre_id)s and MI.moduleimpl_id = E.moduleimpl_id"
# cnx = context.GetDBConnexion()
# cnx = ndb.GetDBConnexion()
# cursor = cnx.cursor(cursor_factory=ScoDocCursor)
# cursor.execute( req, { 'formsemestre_id' : formsemestre_id } )
# return cursor.dictfetchall()

View File

@ -191,7 +191,7 @@ def search_etuds_infos(context, expnom=None, code_nip=None, REQUEST=None):
et ramene liste de mappings utilisables en DTML.
"""
may_be_nip = scu.is_valid_code_nip(expnom)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if expnom and not may_be_nip:
expnom = scu.strupper(expnom) # les noms dans la BD sont en uppercase
etuds = scolars.etudident_list(cnx, args={"nom": expnom}, test="~")

View File

@ -153,7 +153,7 @@ def formation_import_xml(
ndb.quote_dict(F_quoted)
log("F_quoted=%s" % F_quoted)
# find new version number
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
log(
"select max(version) from notes_formations where acronyme=%(acronyme)s and titre=%(titre)s"

View File

@ -95,7 +95,7 @@ def get_formsemestre(context, formsemestre_id):
def do_formsemestre_list(context, *a, **kw):
"list formsemestres"
# log('do_formsemestre_list: a=%s kw=%s' % (str(a),str(kw)))
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sems = _formsemestreEditor.list(cnx, *a, **kw)
@ -220,7 +220,7 @@ def do_formsemestre_edit(context, sem, cnx=None, **kw):
"""Apply modifications to formsemestre.
Update etapes and resps. Invalidate cache."""
if not cnx:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_formsemestreEditor.edit(cnx, sem, **kw)
write_formsemestre_etapes(context, sem)

View File

@ -52,7 +52,7 @@ notes_formsemestre_custommenu_edit = _custommenuEditor.edit
def formsemestre_custommenu_get(context, formsemestre_id):
"returns dict [ { 'title' : xxx, 'url' : xxx } ]"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
vals = notes_formsemestre_custommenu_list(cnx, {"formsemestre_id": formsemestre_id})
return vals
@ -135,7 +135,7 @@ def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
return REQUEST.RESPONSE.redirect(dest_url)
else:
# form submission
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# add new
if tf[2]["title_new"]:
notes_formsemestre_custommenu_create(

View File

@ -178,7 +178,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
)
# Liste des ID de semestres
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute("select semestre_id from notes_semestres")
semestre_id_list = [str(x[0]) for x in cursor.fetchall()]
@ -991,7 +991,7 @@ def do_formsemestre_clone(
"""
log("cloning %s" % orig_formsemestre_id)
orig_sem = sco_formsemestre.get_formsemestre(context, orig_formsemestre_id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# 1- create sem
args = orig_sem.copy()
del args["formsemestre_id"]
@ -1177,7 +1177,7 @@ def do_formsemestres_associate_new_version(context, formsemestre_ids, REQUEST=No
if formation_id != sem["formation_id"]:
raise ScoValueError("les semestres ne sont pas tous de la même formation !")
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# New formation:
formation_id, modules_old2new, ues_old2new = context.formation_create_new_version(
formation_id, redirect=False, REQUEST=REQUEST
@ -1316,7 +1316,7 @@ def do_formsemestre_delete(context, formsemestre_id, REQUEST):
"""delete formsemestre, and all its moduleimpls.
No checks, no warnings: erase all !
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# --- Destruction des modules de ce semestre
@ -1545,7 +1545,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
]
)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
initvalues = {"formsemestre_id": formsemestre_id}
form = [("formsemestre_id", {"input_type": "hidden"})]

View File

@ -37,7 +37,7 @@ import sco_formsemestre_inscriptions
import sco_formsemestre_edit
import sco_formsemestre_validation
import sco_parcours_dut
import notesdb
import notesdb as ndb
from sco_utils import log
import pprint
@ -434,7 +434,7 @@ def _list_ue_with_coef_and_validations(context, sem, etudid):
avec leurs coefs d'UE capitalisée (si déjà saisi)
et leur validation pour cet étudiant.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
formsemestre_id = sem["formsemestre_id"]
ue_list = context.do_ue_list({"formation_id": sem["formation_id"]})
for ue in ue_list:

View File

@ -32,6 +32,7 @@
from notes_log import log
import sco_utils as scu
import notesdb as ndb
from sco_permissions import (
ScoImplement,
ScoChangeFormation,
@ -971,7 +972,7 @@ Il y a des notes en attente ! Le classement des étudiants n'a qu'une valeur ind
def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
"""Tableau de bord semestre HTML"""
# porté du DTML
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id

View File

@ -1311,7 +1311,7 @@ def get_etud_ue_cap_html(context, etudid, formsemestre_id, ue_id, REQUEST=None):
def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
log("etud_ue_suppress_validation( %s, %s, %s)" % (etudid, formsemestre_id, ue_id))
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"DELETE FROM scolar_formsemestre_validation WHERE etudid=%(etudid)s and ue_id=%(ue_id)s",

View File

@ -274,7 +274,7 @@ def get_group_members(context, group_id, etat=None):
def get_group_infos(context, group_id, etat=None): # was _getlisteetud
"""legacy code: used by group_list and trombino"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
group = get_group(context, group_id)
sem = sco_formsemestre.get_formsemestre(context, group["formsemestre_id"])
@ -538,7 +538,7 @@ def set_group(context, etudid, group_id):
Return True if ok, False si deja inscrit.
Warning: don't check if group_id exists (the caller should check).
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
args = {"etudid": etudid, "group_id": group_id}
# déjà inscrit ?
@ -593,7 +593,7 @@ def change_etud_group_in_partition(
# 3- log
formsemestre_id = partition["formsemestre_id"]
if REQUEST:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
logdb(
REQUEST,
cnx,
@ -659,7 +659,7 @@ def setGroups(
context, etudid, group_id, partition, REQUEST=REQUEST
)
# Retire les anciens membres:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for etudid in old_members_set:
log("removing %s from group %s" % (etudid, group_id))
@ -723,7 +723,7 @@ def createGroup(context, partition_id, group_name="", default=False, REQUEST=Non
raise ValueError(
"group_name %s already exists in partition" % group_name
) # XXX FIX: incorrect error handling (in AJAX)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
group_id = groupEditor.create(
cnx, {"partition_id": partition_id, "group_name": group_name}
)
@ -782,7 +782,7 @@ def partition_create(
"Il existe déjà une partition %s dans ce semestre" % partition_name
)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
partition_id = partitionEditor.create(
cnx, {"formsemestre_id": formsemestre_id, "partition_name": partition_name}
)
@ -945,7 +945,7 @@ def partition_set_attr(context, partition_id, attr, value, REQUEST=None):
log("partition_set_attr(%s, %s, %s)" % (partition_id, attr, value))
value = int(value)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
partition[attr] = value
partitionEditor.edit(cnx, partition)
# invalid bulletin cache
@ -968,7 +968,7 @@ def partition_delete(
if not partition["partition_name"] and not force:
raise ValueError("cannot suppress this partition")
redirect = int(redirect)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
groups = get_partition_groups(context, partition)
if not dialog_confirmed:
@ -1025,7 +1025,7 @@ def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
if neigh: #
# swap numero between partition and its neighbor
log("moving partition %s" % partition_id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
partition["numero"], neigh["numero"] = neigh["numero"], partition["numero"]
partitionEditor.edit(cnx, partition)
partitionEditor.edit(cnx, neigh)
@ -1105,7 +1105,7 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi
if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
redirect = int(redirect)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
partitionEditor.edit(
cnx, {"partition_id": partition_id, "partition_name": partition_name}
)
@ -1130,7 +1130,7 @@ def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1):
if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
redirect = int(redirect)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
groupEditor.edit(cnx, {"group_id": group_id, "group_name": group_name})
# redirect to partition edit page:
@ -1391,7 +1391,7 @@ def do_evaluation_listeetuds_groups(
if not include_dems:
req += " and Isem.etat='I'"
req += r
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(req, {"evaluation_id": evaluation_id})
# log('listeetuds_groups: getallstudents=%s groups=%s' % (getallstudents,groups))
@ -1410,7 +1410,7 @@ def do_evaluation_listegroupes(context, evaluation_id, include_default=False):
c = ""
else:
c = " AND p.partition_name is not NULL"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"SELECT DISTINCT gd.group_id FROM group_descr gd, group_membership gm, partition p, notes_moduleimpl m, notes_evaluation e WHERE gm.group_id = gd.group_id and gd.partition_id = p.partition_id and p.formsemestre_id = m.formsemestre_id and m.moduleimpl_id = e.moduleimpl_id and e.evaluation_id = %(evaluation_id)s"
@ -1423,7 +1423,7 @@ def do_evaluation_listegroupes(context, evaluation_id, include_default=False):
def listgroups(context, group_ids):
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
groups = []
for group_id in group_ids:

View File

@ -136,7 +136,7 @@ def list_inscrits_date(context, sem):
"""Liste les etudiants inscrits dans n'importe quel semestre
SAUF sem à la date de début de sem.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"])
cursor.execute(

View File

@ -86,27 +86,27 @@ _modaliteEditor = ndb.EditableTable(
def do_modalite_list(context, *args, **kw):
"""Liste des modalites"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return _modaliteEditor.list(cnx, *args, **kw)
def do_modalite_create(context, args, REQUEST=None):
"create a modalite"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _modaliteEditor.create(cnx, args)
return r
def do_modalite_delete(context, oid, REQUEST=None):
"delete a modalite"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
log("do_modalite_delete: form_modalite_id=%s" % oid)
_modaliteEditor.delete(cnx, oid)
def do_modalite_edit(context, *args, **kw):
"edit a modalite"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check
_ = do_modalite_list(context, {"form_modalite_id": args[0]["form_modalite_id"]})[0]
_modaliteEditor.edit(cnx, *args, **kw)

View File

@ -31,6 +31,7 @@
import datetime
import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO
from sco_permissions import ScoImplement
from sco_exceptions import ScoValueError, AccessDenied
@ -62,7 +63,7 @@ _modules_enseignantsEditor = EditableTable(
def do_moduleimpl_create(context, args):
"create a moduleimpl"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _moduleimplEditor.create(cnx, args)
sco_core.inval_cache(
context, formsemestre_id=args["formsemestre_id"]
@ -72,7 +73,7 @@ def do_moduleimpl_create(context, args):
def do_moduleimpl_delete(context, oid, formsemestre_id=None):
"delete moduleimpl (desinscrit tous les etudiants)"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# --- desinscription des etudiants
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
req = (
@ -101,7 +102,7 @@ def do_moduleimpl_list(
):
"list moduleimpls"
args = locals()
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
modimpls = _moduleimplEditor.list(cnx, args) # *args, **kw)
# Ajoute la liste des enseignants
for mo in modimpls:
@ -112,7 +113,7 @@ def do_moduleimpl_list(
def do_moduleimpl_edit(context, args, formsemestre_id=None, cnx=None):
"edit a moduleimpl"
if not cnx:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_moduleimplEditor.edit(cnx, args)
sco_core.inval_cache(context, formsemestre_id=formsemestre_id) # > modif moduleimpl
@ -156,7 +157,7 @@ def do_moduleimpl_inscription_list(
):
"list moduleimpl_inscriptions"
args = locals()
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return scu.return_text_if_published(
_moduleimpl_inscriptionEditor.list(cnx, args), REQUEST
)
@ -165,7 +166,7 @@ def do_moduleimpl_inscription_list(
def do_moduleimpl_listeetuds(context, moduleimpl_id):
"retourne liste des etudids inscrits a ce module"
req = "select distinct Im.etudid from notes_moduleimpl_inscription Im, notes_formsemestre_inscription Isem, notes_moduleimpl M where Isem.etudid=Im.etudid and Im.moduleimpl_id=M.moduleimpl_id and M.moduleimpl_id = %(moduleimpl_id)s"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(req, {"moduleimpl_id": moduleimpl_id})
res = cursor.fetchall()
@ -175,7 +176,7 @@ def do_moduleimpl_listeetuds(context, moduleimpl_id):
def do_moduleimpl_inscrit_tout_semestre(context, moduleimpl_id, formsemestre_id):
"inscrit tous les etudiants inscrit au semestre a ce module"
# UNUSED
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
req = """INSERT INTO notes_moduleimpl_inscription
(moduleimpl_id, etudid)
@ -196,7 +197,7 @@ _moduleimpl_inscriptionEditor = EditableTable(
def do_moduleimpl_inscription_create(context, args, REQUEST=None, formsemestre_id=None):
"create a moduleimpl_inscription"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
log("do_moduleimpl_inscription_create: " + str(args))
r = _moduleimpl_inscriptionEditor.create(cnx, args)
sco_core.inval_cache(
@ -216,7 +217,7 @@ def do_moduleimpl_inscription_create(context, args, REQUEST=None, formsemestre_i
def do_moduleimpl_inscription_delete(context, oid, formsemestre_id=None):
"delete moduleimpl_inscription"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_moduleimpl_inscriptionEditor.delete(cnx, oid)
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
@ -239,7 +240,7 @@ def do_moduleimpl_inscrit_etuds(
# Desinscriptions
if reset:
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(
"delete from notes_moduleimpl_inscription where moduleimpl_id = %(moduleimpl_id)s",
@ -272,27 +273,27 @@ def do_moduleimpl_inscrit_etuds(
def do_ens_list(context, *args, **kw):
"liste les enseignants d'un moduleimpl (pas le responsable)"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
ens = _modules_enseignantsEditor.list(cnx, *args, **kw)
return ens
def do_ens_edit(context, *args, **kw):
"edit ens"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
_modules_enseignantsEditor.edit(cnx, *args, **kw)
def do_ens_create(context, args):
"create ens"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _modules_enseignantsEditor.create(cnx, args)
return r
def do_ens_delete(context, oid):
"delete ens"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _modules_enseignantsEditor.delete(cnx, oid)
return r

View File

@ -510,7 +510,7 @@ def is_inscrit_ue(context, etudid, formsemestre_id, ue_id):
def do_etud_desinscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Desincrit l'etudiant de tous les modules de cette UE dans ce semestre."""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""DELETE FROM notes_moduleimpl_inscription
@ -551,7 +551,7 @@ def do_etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT mi.moduleimpl_id

View File

@ -37,7 +37,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
import notesdb as ndb # pylint: disable=unused-wildcard-import
import notesdb as ndb
from notes_log import log
import mails
import scolars
@ -81,7 +81,7 @@ def add(context, REQUEST, typ, object=None, text="", url=None, max_frequency=Fal
secondes d'intervalle.
"""
authuser_name = str(REQUEST.AUTHENTICATED_USER)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
args = {
"authenticated_user": authuser_name,
"user_info": context.Users.user_info(user_name=authuser_name),
@ -110,7 +110,7 @@ def scolar_news_summary(context, n=5):
News are "compressed", ie redondant events are joined.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute("select * from scolar_news order by date desc limit 100")
selected_news = {} # (type,object) : news dict

View File

@ -142,7 +142,7 @@ def _menuScolarite(context, authuser, sem, etudid):
def ficheEtud(context, etudid=None, REQUEST=None):
"fiche d'informations sur un etudiant"
authuser = REQUEST.AUTHENTICATED_USER
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if etudid and REQUEST:
# la sidebar est differente s'il y a ou pas un etudid
# voir html_sidebar.sidebar()

View File

@ -1001,7 +1001,7 @@ def formsemestre_has_decisions(context, formsemestre_id):
"""True s'il y a au moins une validation (decision de jury) dans ce semestre
equivalent to notes_table.sem_has_decisions() but much faster when nt not cached
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
validations = scolar_formsemestre_validation_list(
cnx, args={"formsemestre_id": formsemestre_id}
)
@ -1038,7 +1038,7 @@ def formsemestre_get_autorisation_inscription(context, etudid, origin_formsemest
"""Liste des autorisations d'inscription pour cet étudiant
émanant du semestre indiqué.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return scolar_autorisation_inscription_list(
cnx, {"origin_formsemestre_id": origin_formsemestre_id, "etudid": etudid}
)
@ -1059,7 +1059,7 @@ def formsemestre_get_etud_capitalisation(context, sem, etudid):
'is_external'
} ]
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""select distinct SFV.*, ue.ue_code from notes_ue ue, notes_formations nf, notes_formations nf2,
@ -1096,7 +1096,7 @@ def list_formsemestre_utilisateurs_uecap(context, formsemestre_id):
"""Liste des formsemestres pouvant utiliser une UE capitalisee de ce semestre
(et qui doivent donc etre sortis du cache si l'on modifie ce
semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)

View File

@ -4,6 +4,11 @@
"""Definition of ScoDoc 8 permissions
used by auth
"""
import notesdb as ndb
import scolars
import sco_formsemestre
# Définition des permissions: ne pas changer les numéros ou l'ordre des lignes !
_SCO_PERMISSIONS = (
# permission bit, symbol, description
@ -57,16 +62,13 @@ class Permission:
Permission.init_permissions()
import scolars
import sco_formsemestre
def can_suppress_annotation(context, annotation_id, REQUEST):
"""True if current user can suppress this annotation
Seuls l'auteur de l'annotation et le chef de dept peuvent supprimer
une annotation.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
annos = scolars.etud_annotations_list(cnx, args={"id": annotation_id})
if len(annos) != 1:
raise ScoValueError("annotation inexistante !")

View File

@ -55,6 +55,7 @@ import glob
from config import Config
from sco_utils import CONFIG, SCO_SRC_DIR
import notesdb as ndb
from notes_log import log
import scolars
@ -245,7 +246,7 @@ def store_photo(context, etud, data, REQUEST=None):
etud["photo_filename"] = filename
etud["foto"] = None
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
scolars.identite_edit_nocheck(cnx, etud)
cnx.commit()
#
@ -261,7 +262,7 @@ def suppress_photo(context, etud, REQUEST=None):
rel_path = photo_pathname(context, etud)
# 1- remove ref. from database
etud["photo_filename"] = None
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
scolars.identite_edit_nocheck(cnx, etud)
cnx.commit()
# 2- erase images files

View File

@ -249,7 +249,7 @@ def do_placement(context, REQUEST):
"""
% E["moduleimpl_id"]
)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# Infos transmises
placement_method = REQUEST.form["placement_method"]
teachers = REQUEST.form["teachers"]

View File

@ -1766,7 +1766,7 @@ class sco_base_preferences:
log("loading preferences")
try:
scu.GSL.acquire()
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
preflist = self._editor.list(cnx)
self.prefs = {None: {}} # { formsemestre_id (or None) : { name : value } }
self.default = {} # { name : default_value }
@ -1863,7 +1863,7 @@ class sco_base_preferences:
try:
scu.GSL.acquire()
modif = False
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if name is None:
names = self.prefs[formsemestre_id].keys()
else:
@ -1927,7 +1927,7 @@ class sco_base_preferences:
scu.GSL.acquire()
if formsemestre_id in self.prefs and name in self.prefs[formsemestre_id]:
del self.prefs[formsemestre_id][name]
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
pdb = self._editor.list(
cnx, args={"formsemestre_id": formsemestre_id, "name": name}
)

View File

@ -217,7 +217,7 @@ def dict_pvjury(
etudids = nt.get_etudids()
if not etudids:
return {}
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
max_date = "0000-01-01"
has_prev = False # vrai si au moins un etudiant a un code prev

View File

@ -34,6 +34,7 @@ import datetime
import psycopg2
import sco_utils as scu
import notesdb as ndb
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
from notesdb import ScoDocCursor, quote_dict, DateISOtoDMY, DateDMYtoISO
@ -997,7 +998,7 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
def _get_sorted_etuds(context, E, etudids, formsemestre_id):
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
NotesDB = context._notes_getall(E["evaluation_id"]) # Notes existantes
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
etuds = []
for etudid in etudids:
# infos identite etudiant

View File

@ -74,7 +74,7 @@ class SemSet(dict):
self.context = context
self.sems = []
self.formsemestre_ids = []
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if semset_id: # read existing set
L = semset_list(cnx, args={"semset_id": semset_id})
if not L:
@ -103,11 +103,11 @@ class SemSet(dict):
def delete(self):
"""delete"""
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
semset_delete(cnx, self.semset_id)
def edit(self, args):
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
semset_edit(cnx, args)
def load_sems(self):
@ -338,7 +338,7 @@ def get_semsets_list(context):
"""Liste de tous les semsets
Trié par date_debut, le plus récent d'abord
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
L = []
for s in semset_list(cnx):
L.append(SemSet(context, semset_id=s["semset_id"]))
@ -380,7 +380,7 @@ def edit_semset_set_title(context, id=None, value=None, REQUEST=None):
if not id:
raise ScoValueError("empty semset_id")
SemSet(context, semset_id=id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
semset_edit(cnx, {"semset_id": id, "title": title})
return title

View File

@ -32,6 +32,7 @@ import time
import pprint
import sco_utils as scu
import notesdb as ndb
from sco_permissions import ScoEtudInscrit
from sco_exceptions import ScoValueError
from notesdb import ScoDocCursor
@ -393,7 +394,7 @@ def list_synch(context, sem, anneeapogee=None):
[x[EKEY_APO] for x in etudsapo if x.get("paiementinscription", True)]
)
#
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# Tri listes
def set_to_sorted_list(etudset, etud_apo=False, is_inscrit=False):
def key2etud(key, etud_apo=False):
@ -505,7 +506,7 @@ def list_all(context, etudsapo_set):
# on charge TOUS les etudiants (au pire qq 100000 ?)
# si tres grosse base, il serait mieux de faire une requete
# d'interrogation par etudiant.
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute("select " + EKEY_SCO + ", etudid from identite")
key2etudid = dict([(x[0], x[1]) for x in cursor.fetchall()])
@ -579,7 +580,7 @@ def do_import_etuds_from_portal(context, sem, a_importer, etudsapo_ident, REQUES
log("do_import_etuds_from_portal: a_importer=%s" % a_importer)
if not a_importer:
return
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
created_etudids = []
try: # --- begin DB transaction
@ -790,7 +791,7 @@ def formsemestre_import_etud_admission(
no_nip = [] # liste d'etudids sans code NIP
unknowns = [] # etudiants avec NIP mais inconnus du portail
changed_mails = [] # modification d'adresse mails
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# Essaie de recuperer les etudiants des étapes, car
# la requete get_inscrits_etape est en général beaucoup plus

View File

@ -80,7 +80,7 @@ class ScoTag:
else:
# Create new tag:
log("creating new tag: %s" % self.title)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
oid = ndb.DBInsertDict(
cnx, self.tag_table, {"title": self.title}, commit=True
)
@ -122,7 +122,7 @@ class ScoTag:
)
if not r:
log("tag %s with %s" % (object_id, self.title))
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
ndb.DBInsertDict(cnx, self.assoc_table, args, commit=True)
def remove_tag_from_object(self, object_id):

View File

@ -213,7 +213,7 @@ def get_note_history(context, evaluation_id, etudid, REQUEST=None, fmt=""):
= liste chronologique d'opérations, la plus récente d'abord
[ { 'value', 'date', 'comment', 'uid' } ]
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
# Valeur courante

View File

@ -329,6 +329,10 @@ def get_dept_id():
raise ScoInvalidDept("département invalide: %s" % g.scodoc_dept)
def get_db_cnx_string():
return "SCO" + g.scodoc_dept
def ScoURL():
"""base URL for this sco instance.
e.g. https://scodoc.xxx.fr/ScoDoc/DEPT/Scolarite

View File

@ -32,6 +32,7 @@ import time
import mails
import sco_utils as scu
from sco_utils import SCO_ENCODING
import notesdb as ndb
from sco_exceptions import ScoGenError, ScoValueError
from notesdb import (
EditableTable,
@ -660,7 +661,7 @@ def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None):
"""
if etudid is None:
return []
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST)
etud = scolars.etudident_list(cnx, args=args)
@ -781,7 +782,7 @@ def add_annotations_to_etud_list(context, etuds):
"""Add key 'annotations' describing annotations of etuds
(used to list all annotations of a group)
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
for etud in etuds:
l = []
for a in etud_annotations_list(cnx, args={"etudid": etud["etudid"]}):
@ -893,7 +894,7 @@ o.close()
def list_scolog(context, etudid):
"liste des operations effectuees sur cet etudiant"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select * from scolog where etudid=%(etudid)s ORDER BY DATE DESC",
@ -907,7 +908,7 @@ def fillEtudsInfo(context, etuds):
Pour chaque etudiant, ajoute ou formatte les champs
-> informations pour fiche etudiant ou listes diverses
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# open('/tmp/t','w').write( str(etuds) )
for etud in etuds:
etudid = etud["etudid"]
@ -1005,7 +1006,7 @@ def fillEtudsInfo(context, etuds):
def descr_situation_etud(context, etudid, ne=""):
"""chaine decrivant la situation actuelle de l'etudiant"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select I.formsemestre_id, I.etat from notes_formsemestre_inscription I, notes_formsemestre S where etudid=%(etudid)s and S.formsemestre_id = I.formsemestre_id and date_debut < now() and date_fin > now() order by S.date_debut desc;",

View File

@ -73,7 +73,7 @@ from app.views import absences_bp as bp
# ---------------
from app.scodoc import sco_utils as scu
from app.scodoc import notesdb
from app.scodoc import notesdb as ndb
from app.scodoc.notes_log import log
from app.scodoc.scolog import logdb
from app.scodoc.sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView
@ -164,8 +164,8 @@ def _AddAbsence(
raise ScoValueError("date absence trop loin dans le futur !")
estjust = _toboolean(estjust)
matin = _toboolean(matin)
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin,description, moduleimpl_id) values (%(etudid)s, %(jour)s, TRUE, %(estjust)s, %(matin)s, %(description)s, %(moduleimpl_id)s )",
vars(),
@ -189,8 +189,8 @@ def _AddJustif(context, etudid, jour, matin, REQUEST, description=None):
if context._isFarFutur(jour):
raise ScoValueError("date justificatif trop loin dans le futur !")
matin = _toboolean(matin)
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
vars(),
@ -212,8 +212,8 @@ def _AnnuleAbsence(context, etudid, jour, matin, moduleimpl_id=None, REQUEST=Non
"""
# unpublished
matin = _toboolean(matin)
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
if moduleimpl_id:
req += " and moduleimpl_id=%(moduleimpl_id)s"
@ -233,8 +233,8 @@ def _AnnuleJustif(context, etudid, jour, matin, REQUEST=None):
"Annule un justificatif"
# unpublished
matin = _toboolean(matin)
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
vars(),
@ -277,8 +277,8 @@ def AnnuleAbsencesDatesNoJust(context, etudid, dates, moduleimpl_id=None, REQUES
raise ValueError("invalid ampm !")
context._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST)
return
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
# supr les absences non justifiees
for date in dates:
cursor.execute(
@ -332,8 +332,8 @@ def _list_abs_in_range(
else:
modul = ""
if not cursor:
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""
SELECT DISTINCT A.JOUR, A.MATIN
@ -382,8 +382,8 @@ def CountAbsJust(context, etudid, debut, fin, matin=None, moduleimpl_id=None):
modul = " AND A.MODULEIMPL_ID = %(moduleimpl_id)s "
else:
modul = ""
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT COUNT(*) AS NbAbsJust FROM (
SELECT DISTINCT A.JOUR, A.MATIN
@ -406,8 +406,8 @@ WHERE A.ETUDID = %(etudid)s
def _ListeAbsDate(context, etudid, beg_date, end_date):
# Liste des absences et justifs entre deux dates
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
@ -451,8 +451,8 @@ def _ListeAbsDate(context, etudid, beg_date, end_date):
@scodoc7func(context)
def ListeAbsJust(context, etudid, datedebut):
"Liste des absences justifiees (par ordre chronologique)"
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
WHERE A.ETUDID = %(etudid)s
@ -474,8 +474,8 @@ ORDER BY A.JOUR
@scodoc7func(context)
def ListeAbsNonJust(context, etudid, datedebut):
"Liste des absences NON justifiees (par ordre chronologique)"
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
@ -502,8 +502,8 @@ def ListeJustifs(context, etudid, datedebut, datefin=None, only_no_abs=False):
ou, si datefin spécifié, entre deux dates.
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
"""
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.ESTJUST
@ -527,8 +527,8 @@ AND B.ETUDID = %(etudid)s
def _GetAbsDescription(context, a, cursor=None):
"Description associee a l'absence"
if not cursor:
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
a = a.copy()
# a['jour'] = a['jour'].date()
if a["matin"]: # devrait etre booleen... :-(
@ -569,8 +569,8 @@ def ListeAbsJour(context, date, am=True, pm=True, is_abs=True, is_just=None):
is_abs: None (peu importe), True, False
is_just: idem
"""
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
WHERE A.jour = %(date)s
"""
@ -595,8 +595,8 @@ WHERE A.jour = %(date)s
@scodoc7func(context)
def ListeAbsNonJustJour(context, date, am=True, pm=True):
"Liste des absences non justifiees ce jour"
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
reqa = ""
if not am:
reqa += " AND NOT matin "
@ -746,7 +746,7 @@ def SignaleAbsenceGrHebdo(
# calcule dates jours de cette semaine
# liste de dates iso "yyyy-mm-dd"
datessem = [notesdb.DateDMYtoISO(datelundi)]
datessem = [ndb.DateDMYtoISO(datelundi)]
for _ in sco_abs.day_names(context)[1:]:
datessem.append(sco_abs.next_iso_day(context, datessem[-1]))
#
@ -1121,8 +1121,8 @@ def _gen_form_saisie_groupe(
'<tr><td><span class="redboldtext">Aucun étudiant inscrit !</span></td></tr>'
)
i = 1
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for etud in etuds:
i += 1
etudid = etud["etudid"]
@ -1241,8 +1241,8 @@ def _TablesAbsEtud(
absnonjust = context.ListeAbsNonJust(etudid=etudid, datedebut=datedebut)
# examens ces jours là ?
if with_evals:
cnx = context.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor)
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for a in absnonjust + absjust:
cursor.execute(
"""select eval.*
@ -1370,8 +1370,8 @@ def EtatAbsencesGr(
REQUEST=None,
):
"""Liste les absences de groupes"""
datedebut = notesdb.DateDMYtoISO(debut)
datefin = notesdb.DateDMYtoISO(fin)
datedebut = ndb.DateDMYtoISO(debut)
datefin = ndb.DateDMYtoISO(fin)
# Informations sur les groupes à afficher:
groups_infos = sco_groups_view.DisplayedGroupsInfos(
context, group_ids, REQUEST=REQUEST
@ -1515,7 +1515,7 @@ def EtatAbsencesDate(
)
]
if date:
dateiso = notesdb.DateDMYtoISO(date)
dateiso = ndb.DateDMYtoISO(date)
nbetud = 0
t_nbabsjustam = 0
t_nbabsam = 0
@ -1620,7 +1620,7 @@ def AddBilletAbsence(
#
justified = int(justified)
#
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
billet_id = sco_abs.billet_absence_create(
cnx,
{
@ -1766,7 +1766,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
return scu.log_unknown_etud(context, format=format, REQUEST=REQUEST)
etud = etuds[0]
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]})
tab = context._tableBillets(billets, etud=etud)
return tab.make_page(context, REQUEST=REQUEST, format=format)
@ -1790,7 +1790,7 @@ def XMLgetBilletsEtud(context, etudid=False, REQUEST=None):
@scodoc7func(context)
def listeBillets(context, REQUEST=None):
"""Page liste des billets non traités et formulaire recherche d'un billet"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"etat": 0})
tab = context._tableBillets(billets)
T = tab.html()
@ -1820,7 +1820,7 @@ def listeBillets(context, REQUEST=None):
@scodoc7func(context)
def deleteBilletAbsence(context, billet_id, REQUEST=None, dialog_confirmed=False):
"""Supprime un billet."""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
if not billets:
return REQUEST.RESPONSE.redirect(
@ -1846,7 +1846,7 @@ def _ProcessBilletAbsence(context, billet, estjust, description, REQUEST):
et change l'état du billet à 1.
NB: actuellement, les heures ne sont utilisées que pour déterminer si matin et/ou après-midi.
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if billet["etat"] != 0:
log("billet=%s" % billet)
log("billet deja traité !")
@ -1896,7 +1896,7 @@ def _ProcessBilletAbsence(context, billet, estjust, description, REQUEST):
@scodoc7func(context)
def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
"""Formulaire traitement d'un billet"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
if not billets:
return REQUEST.RESPONSE.redirect(

View File

@ -418,7 +418,7 @@ def do_formation_delete(context, oid, REQUEST):
F = context.formation_list(args={"formation_id": oid})[0]
if context.formation_has_locked_sems(oid):
raise ScoLockedFormError()
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# delete all UE in this formation
ues = context.do_ue_list({"formation_id": oid})
for ue in ues:
@ -449,7 +449,7 @@ def formation_list(context, format=None, REQUEST=None, formation_id=None, args={
args = {}
else:
args = {"formation_id": formation_id}
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = _formationEditor.list(cnx, args=args)
# log('%d formations found' % len(r))
return scu.sendResult(REQUEST, r, name="formation", format=format)
@ -575,7 +575,7 @@ _ueEditor = ndb.EditableTable(
@scodoc7func(context)
def do_ue_create(context, args, REQUEST):
"create an ue"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check duplicates
ues = context.do_ue_list(
{"formation_id": args["formation_id"], "acronyme": args["acronyme"]}
@ -599,7 +599,7 @@ def do_ue_create(context, args, REQUEST):
def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=False):
"delete UE and attached matieres (but not modules (it should ?))"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
log("do_ue_delete: ue_id=%s, delete_validations=%s" % (ue_id, delete_validations))
# check
ue = context.do_ue_list({"ue_id": ue_id})
@ -645,7 +645,7 @@ def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=
ndb.SimpleQuery(
context, "DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}
)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._ueEditor.delete(cnx, ue_id)
# > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?):
sco_core.inval_cache(context)
@ -672,7 +672,7 @@ def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=
@scodoc7func(context)
def do_ue_list(context, *args, **kw):
"list UEs"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return context._ueEditor.list(cnx, *args, **kw)
@ -691,7 +691,7 @@ _matiereEditor = ndb.EditableTable(
@scodoc7func(context)
def do_matiere_create(context, args, REQUEST):
"create a matiere"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check
ue = context.do_ue_list({"ue_id": args["ue_id"]})[0]
# create matiere
@ -714,7 +714,7 @@ def do_matiere_create(context, args, REQUEST):
@scodoc7func(context)
def do_matiere_delete(context, oid, REQUEST):
"delete matiere and attached modules"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check
mat = context.do_matiere_list({"matiere_id": oid})[0]
ue = context.do_ue_list({"ue_id": mat["ue_id"]})[0]
@ -747,7 +747,7 @@ def do_matiere_delete(context, oid, REQUEST):
@scodoc7func(context)
def do_matiere_list(context, *args, **kw):
"list matieres"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return context._matiereEditor.list(cnx, *args, **kw)
@ -756,7 +756,7 @@ def do_matiere_list(context, *args, **kw):
@scodoc7func(context)
def do_matiere_edit(context, *args, **kw):
"edit a matiere"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check
mat = context.do_matiere_list({"matiere_id": args[0]["matiere_id"]})[0]
if sco_edit_matiere.matiere_is_locked(context, mat["matiere_id"]):
@ -771,7 +771,7 @@ def do_matiere_edit(context, *args, **kw):
@scodoc7func(context)
def do_matiere_formation_id(context, matiere_id):
"get formation_id from matiere"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select UE.formation_id from notes_matieres M, notes_ue UE where M.matiere_id = %(matiere_id)s and M.ue_id = UE.ue_id",
@ -822,7 +822,7 @@ _moduleEditor = ndb.EditableTable(
def do_module_create(context, args, REQUEST):
"create a module"
# create
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = context._moduleEditor.create(cnx, args)
# news
@ -859,7 +859,7 @@ def do_module_delete(context, oid, REQUEST):
)
raise ScoGenError(err_page)
# delete
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._moduleEditor.delete(cnx, oid)
# news
@ -878,7 +878,7 @@ def do_module_delete(context, oid, REQUEST):
@scodoc7func(context)
def do_module_list(context, *args, **kw):
"list modules"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return context._moduleEditor.list(cnx, *args, **kw)
@ -896,7 +896,7 @@ def do_module_edit(context, val):
if f in val:
del val[f]
# edit
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._moduleEditor.edit(cnx, val)
sems = sco_formsemestre.do_formsemestre_list(
@ -968,7 +968,7 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
if neigh: #
# swap numero between partition and its neighbor
# log('moving module %s' % module_id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
module["numero"], neigh["numero"] = neigh["numero"], module["numero"]
if module["numero"] == neigh["numero"]:
neigh["numero"] -= 2 * after - 1
@ -1003,7 +1003,7 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
if neigh: #
# swap numero between partition and its neighbor
# log('moving ue %s (neigh #%s)' % (ue_id, neigh['numero']))
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
o["numero"], neigh["numero"] = neigh["numero"], o["numero"]
if o["numero"] == neigh["numero"]:
neigh["numero"] -= 2 * after - 1
@ -1022,7 +1022,7 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
@scodoc7func(context)
def do_formsemestre_create(context, args, REQUEST, silent=False):
"create a formsemestre"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
formsemestre_id = sco_formsemestre._formsemestreEditor.create(cnx, args)
if args["etapes"]:
args["formsemestre_id"] = formsemestre_id
@ -1550,7 +1550,7 @@ def edit_ue_expr(context, REQUEST, formsemestre_id, ue_id):
sem = sco_formsemestre_edit.can_edit_sem(context, REQUEST, formsemestre_id)
if not sem:
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération")
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
#
ue = context.do_ue_list({"ue_id": ue_id})[0]
H = [
@ -1641,7 +1641,7 @@ def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="htm
else:
sem_ens[ensd["ens_id"]]["mods"].append(mod)
# compte les absences ajoutées par chacun dans tout le semestre
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for ens in sem_ens:
cursor.execute(
@ -1733,7 +1733,7 @@ _formsemestre_inscriptionEditor = ndb.EditableTable(
@scodoc7func(context)
def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
"create a formsemestre_inscription (and sco event)"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
log("do_formsemestre_inscription_create: args=%s" % str(args))
sems = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": args["formsemestre_id"]}
@ -1777,7 +1777,7 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
@scodoc7func(context)
def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
"delete formsemestre_inscription"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._formsemestre_inscriptionEditor.delete(cnx, oid)
sco_core.inval_cache(
@ -1790,7 +1790,7 @@ def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
@scodoc7func(context)
def do_formsemestre_inscription_list(context, *args, **kw):
"list formsemestre_inscriptions"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
return context._formsemestre_inscriptionEditor.list(cnx, *args, **kw)
@ -1817,7 +1817,7 @@ def do_formsemestre_inscription_listinscrits(
@scodoc7func(context)
def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
"edit a formsemestre_inscription"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._formsemestre_inscriptionEditor.edit(cnx, args)
sco_core.inval_cache(
context, formsemestre_id=formsemestre_id
@ -1929,7 +1929,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
insem = insem[0]
# -- desinscription de tous les modules
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"select moduleimpl_inscription_id from notes_moduleimpl_inscription Im, notes_moduleimpl M where Im.etudid=%(etudid)s and Im.moduleimpl_id = M.moduleimpl_id and M.formsemestre_id = %(formsemestre_id)s",
@ -2170,7 +2170,7 @@ def do_evaluation_create(
args["numero"] = n
#
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
r = context._evaluationEditor.create(cnx, args)
# news
@ -2330,7 +2330,7 @@ def do_evaluation_list(context, args, sortkey=None):
'apresmidi' : 1 (termine après 12:00) ou 0
'descrheure' : ' de 15h00 à 16h30'
"""
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
evals = context._evaluationEditor.list(cnx, args, sortkey=sortkey)
# calcule duree (chaine de car.) de chaque evaluation et ajoute jouriso, matin, apresmidi
for e in evals:
@ -2396,7 +2396,7 @@ def do_evaluation_edit(context, REQUEST, args):
args["moduleimpl_id"] = moduleimpl_id
context._check_evaluation_args(args)
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context._evaluationEditor.edit(cnx, args)
# inval cache pour ce semestre
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
@ -2514,7 +2514,7 @@ def _notes_getall(
r = cache.get(evaluation_id)
if r != None:
return r
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cond = " where evaluation_id=%(evaluation_id)s"
if by_uid:
@ -2725,7 +2725,7 @@ def appreciation_add_form(
REQUEST=None,
):
"form ajout ou edition d'une appreciation"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
authuser = REQUEST.AUTHENTICATED_USER
if id: # edit mode
apps = scolars.appreciations_list(cnx, args={"id": id})

View File

@ -367,7 +367,7 @@ def etud_info(context, etudid=None, format="xml", REQUEST=None):
"Donne les informations sur un etudiant"
t0 = time.time()
args = make_etud_args(etudid=etudid, REQUEST=REQUEST)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
etuds = scolars.etudident_list(cnx, args)
if not etuds:
# etudiant non trouvé: message d'erreur
@ -521,7 +521,7 @@ sco_publish(
def doAddAnnotation(context, etudid, comment, REQUEST):
"ajoute annotation sur etudiant"
authuser = REQUEST.AUTHENTICATED_USER
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
scolars.etud_annotations_create(
cnx,
args={
@ -543,7 +543,7 @@ def doSuppressAnnotation(context, etudid, annotation_id, REQUEST):
if not sco_permissions.can_suppress_annotation(context, annotation_id, REQUEST):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
annos = scolars.etud_annotations_list(cnx, args={"id": annotation_id})
if len(annos) != 1:
raise ScoValueError("annotation inexistante !")
@ -562,7 +562,7 @@ def doSuppressAnnotation(context, etudid, annotation_id, REQUEST):
@scodoc7func(context)
def formChangeCoordonnees(context, etudid, REQUEST):
"edit coordonnees etudiant"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
adrs = scolars.adresse_list(cnx, {"etudid": etudid})
if adrs:
@ -895,7 +895,7 @@ def _doDem_or_Def_Etudiant(
"Démission ou défaillance d'un étudiant"
# marque 'D' ou DEF dans l'inscription au semestre et ajoute
# un "evenement" scolarite
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
# check lock
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if sem["etat"] != "1":
@ -1011,7 +1011,7 @@ def _doCancelDem_or_Def(
if ins["etat"] != etat_current:
raise ScoException("etudiant non %s !!!" % etat_current) # obviously a bug
ins["etat"] = etat_new
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
context.Notes.do_formsemestre_inscription_edit(
args=ins, formsemestre_id=formsemestre_id
)
@ -1048,7 +1048,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
H = [html_sco_header.sco_header(context, REQUEST, init_jquery_ui=True)]
F = context.sco_footer(REQUEST)
etudid = REQUEST.form.get("etudid", None)
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
descr = []
if not edit:
# creation nouvel etudiant
@ -1446,7 +1446,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
@scodoc7func(context)
def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
"Delete a student"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
etuds = scolars.etudident_list(cnx, {"etudid": etudid})
if not etuds:
raise ScoValueError("Etudiant inexistant !")
@ -1520,7 +1520,7 @@ def check_group_apogee(
members, group, _, sem, _ = sco_groups.get_group_infos(context, group_id, etat=etat)
formsemestre_id = group["formsemestre_id"]
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
H = [
context.Notes.html_sem_header(
REQUEST, "Etudiants du %s" % (group["group_name"] or "semestre"), sem
@ -2014,7 +2014,7 @@ sco_publish(
@scodoc7func(context)
def stat_bac(context, formsemestre_id):
"Renvoie statistisques sur nb d'etudiants par bac"
cnx = context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
ins = context.Notes.do_formsemestre_inscription_list(
args={"formsemestre_id": formsemestre_id}
)

View File

@ -21,6 +21,7 @@ random.seed(12345) # tests reproductibles
from debug import REQUEST
import sco_utils
import notesdb as ndb
from notes_log import log
from sco_exceptions import ScoValueError
import scolars
@ -34,18 +35,10 @@ import sco_edit_ue
import sco_codes_parcours
import sco_saisie_notes
<<<<<<< HEAD
DEMO_DIR = sco_utils.SCO_SRC_DIR + "/scotests/demo/"
NOMS = [x.strip() for x in open(DEMO_DIR + "/noms.txt").readlines()]
PRENOMS_H = [x.strip() for x in open(DEMO_DIR + "/prenoms-h.txt").readlines()]
PRENOMS_F = [x.strip() for x in open(DEMO_DIR + "/prenoms-f.txt").readlines()]
=======
DEMODIR = sco_utils.SCO_SRCDIR + "/scotests/demo/"
NOMS = [x.strip() for x in open(DEMODIR + "/noms.txt").readlines()]
PRENOMS_H = [x.strip() for x in open(DEMODIR + "/prenoms-h.txt").readlines()]
PRENOMS_F = [x.strip() for x in open(DEMODIR + "/prenoms-f.txt").readlines()]
PRENOMS_X = [x.strip() for x in open(DEMODIR + "/prenoms-x.txt").readlines()]
>>>>>>> a50a9eb8e8ed1b949c5ca16250186345f2f9e066
# nb: en python2, les chaines ci-dessus sont en utf8
@ -115,7 +108,7 @@ class ScoFake:
):
"""Crée un étudiant"""
if not cnx:
cnx = self.context.GetDBConnexion()
cnx = ndb.GetDBConnexion()
if code_nip == "":
code_nip = str(random.randint(10000, 99999))
if not civilite or not nom or not prenom: