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

View File

@ -168,7 +168,7 @@ class NotesTable:
raise ScoValueError("invalid formsemestre_id (%s)" % formsemestre_id) raise ScoValueError("invalid formsemestre_id (%s)" % formsemestre_id)
self.context = context self.context = context
self.formsemestre_id = formsemestre_id self.formsemestre_id = formsemestre_id
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
self.moduleimpl_stats = {} # { moduleimpl_id : {stats} } self.moduleimpl_stats = {} # { moduleimpl_id : {stats} }
self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap 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 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 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 = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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;", "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. """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). (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 = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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", "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 = {} _pools = {}
def GetDBConnexion(context, autocommit=True): def GetDBConnexion(autocommit=True):
pool = _pools.get(context._db_cnx_string, None) """connexion to the DB of a departement"""
pool = _pools.get(scu.get_db_cnx_string(), None)
if not pool: if not pool:
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=context._db_cnx_string) pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=scu.get_db_cnx_string())
_pools[context._db_cnx_string] = pool _pools[scu.get_db_cnx_string()] = pool
# log('GetDBConnexion: created pool for "%s"' % context._db_cnx_string) # log('GetDBConnexion: created pool for "%s"' % scu.get_db_cnx_string())
cnx = pool.getconn(key=(thread.get_ident(), autocommit)) cnx = pool.getconn(key=(thread.get_ident(), autocommit))
# log('GetDBConnexion: autocommit=%s cnx=%s' % (autocommit,cnx)) # log('GetDBConnexion: autocommit=%s cnx=%s' % (autocommit,cnx))
if cnx.autocommit != autocommit: if cnx.autocommit != autocommit:
@ -57,11 +58,11 @@ _users_pools = {}
def GetUsersDBConnexion(context, autocommit=True): 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: if not pool:
pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=context._db_cnx_string) pool = psycopg2.pool.ThreadedConnectionPool(2, 8, dsn=scu.get_db_cnx_string())
_users_pools[context._db_cnx_string] = pool _users_pools[scu.get_db_cnx_string()] = pool
log('GetUsersDBConnexion: created pool for "%s"' % context._db_cnx_string) log('GetUsersDBConnexion: created pool for "%s"' % scu.get_db_cnx_string())
cnx = pool.getconn(key=(thread.get_ident(), autocommit)) cnx = pool.getconn(key=(thread.get_ident(), autocommit))
if cnx.autocommit != autocommit: if cnx.autocommit != autocommit:
cnx.autocommit = autocommit cnx.autocommit = autocommit
@ -87,7 +88,7 @@ class ScoDocCursor(psycopg2.extensions.cursor):
def SimpleQuery(context, query, args, cursor=None): def SimpleQuery(context, query, args, cursor=None):
if not cursor: if not cursor:
cnx = context.GetDBConnexion() cnx = GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor) cursor = cnx.cursor(cursor_factory=ScoDocCursor)
# log( 'SimpleQuery(%s)' % (query % args) ) # log( 'SimpleQuery(%s)' % (query % args) )
cursor.execute(query, args) cursor.execute(query, args)

View File

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

View File

@ -110,7 +110,7 @@ def abs_notify_send(
context, destinations, etudid, msg, nbabs, nbabsjust, formsemestre_id context, destinations, etudid, msg, nbabs, nbabsjust, formsemestre_id
): ):
"""Actually send the notification by email, and register it in database""" """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) log("abs_notify: sending notification to %s" % destinations)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for email in destinations: 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): 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 """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)""" 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 = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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""", """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): def user_nbdays_since_last_notif(context, email_addr, etudid):
"""nb days since last notification to this email, or None if no previous notification""" """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 = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""select * from absences_notifications where email = %(email_addr)s and etudid=%(etudid)s order by notification_date desc""", """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"] I["filigranne"] = prefs["bul_temporary_txt"]
# --- Appreciations # --- Appreciations
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list( apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id} 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_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 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="") infos = scu.DictDefault(defaultvalue="")
# --- Situation et décisions jury # --- Situation et décisions jury

View File

@ -400,7 +400,7 @@ def formsemestre_bulletinetud_published_dict(
d["decision"] = dict(code="", etat="DEM") d["decision"] = dict(code="", etat="DEM")
# --- Appreciations # --- Appreciations
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list( apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id} 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.decision(code="", etat="DEM")
doc._pop() doc._pop()
# --- Appreciations # --- Appreciations
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
apprecs = scolars.appreciations_list( apprecs = scolars.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id} 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 # check presence of 'nbabs' in expressions
ab = "nb_abs" # chaine recherchée ab = "nb_abs" # chaine recherchée
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# 1- moyennes d'UE: # 1- moyennes d'UE:
elist = formsemestre_ue_computation_expr_list( elist = formsemestre_ue_computation_expr_list(
cnx, {"formsemestre_id": formsemestre_id} cnx, {"formsemestre_id": formsemestre_id}

View File

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

View File

@ -31,6 +31,7 @@
import datetime import datetime
import sco_utils as scu import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO from notesdb import ScoDocCursor, EditableTable, DateISOtoDMY, DateDMYtoISO
@ -199,58 +200,58 @@ _entreprise_contactEditor = EditableTable(
def do_entreprise_create(context, args): def do_entreprise_create(context, args):
"entreprise_create" "entreprise_create"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = _entreprisesEditor.create(cnx, args) r = _entreprisesEditor.create(cnx, args)
return r return r
def do_entreprise_delete(context, oid): def do_entreprise_delete(context, oid):
"entreprise_delete" "entreprise_delete"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprisesEditor.delete(cnx, oid) _entreprisesEditor.delete(cnx, oid)
def do_entreprise_list(context, **kw): def do_entreprise_list(context, **kw):
"entreprise_list" "entreprise_list"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
kw["context"] = context kw["context"] = context
return _entreprisesEditor.list(cnx, **kw) return _entreprisesEditor.list(cnx, **kw)
def do_entreprise_list_by_etud(context, **kw): def do_entreprise_list_by_etud(context, **kw):
"entreprise_list_by_etud" "entreprise_list_by_etud"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return _entreprisesEditor.list_by_etud(cnx, **kw) return _entreprisesEditor.list_by_etud(cnx, **kw)
def do_entreprise_edit(context, *args, **kw): def do_entreprise_edit(context, *args, **kw):
"entreprise_edit" "entreprise_edit"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprisesEditor.edit(cnx, *args, **kw) _entreprisesEditor.edit(cnx, *args, **kw)
def do_entreprise_correspondant_create(context, args): def do_entreprise_correspondant_create(context, args):
"entreprise_correspondant_create" "entreprise_correspondant_create"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = _entreprise_correspEditor.create(cnx, args) r = _entreprise_correspEditor.create(cnx, args)
return r return r
def do_entreprise_correspondant_delete(context, oid): def do_entreprise_correspondant_delete(context, oid):
"entreprise_correspondant_delete" "entreprise_correspondant_delete"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.delete(cnx, oid) _entreprise_correspEditor.delete(cnx, oid)
def do_entreprise_correspondant_list(context, **kw): def do_entreprise_correspondant_list(context, **kw):
"entreprise_correspondant_list" "entreprise_correspondant_list"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return _entreprise_correspEditor.list(cnx, **kw) return _entreprise_correspEditor.list(cnx, **kw)
def do_entreprise_correspondant_edit(context, *args, **kw): def do_entreprise_correspondant_edit(context, *args, **kw):
"entreprise_correspondant_edit" "entreprise_correspondant_edit"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprise_correspEditor.edit(cnx, *args, **kw) _entreprise_correspEditor.edit(cnx, *args, **kw)
@ -262,25 +263,25 @@ def do_entreprise_correspondant_listnames(context, args={}):
def do_entreprise_contact_delete(context, oid): def do_entreprise_contact_delete(context, oid):
"entreprise_contact_delete" "entreprise_contact_delete"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.delete(cnx, oid) _entreprise_contactEditor.delete(cnx, oid)
def do_entreprise_contact_list(context, **kw): def do_entreprise_contact_list(context, **kw):
"entreprise_contact_list" "entreprise_contact_list"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return _entreprise_contactEditor.list(cnx, **kw) return _entreprise_contactEditor.list(cnx, **kw)
def do_entreprise_contact_edit(context, *args, **kw): def do_entreprise_contact_edit(context, *args, **kw):
"entreprise_contact_edit" "entreprise_contact_edit"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_entreprise_contactEditor.edit(cnx, *args, **kw) _entreprise_contactEditor.edit(cnx, *args, **kw)
def do_entreprise_contact_create(context, args): def do_entreprise_contact_create(context, args):
"entreprise_contact_create" "entreprise_contact_create"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = _entreprise_contactEditor.create(cnx, args) r = _entreprise_contactEditor.create(cnx, args)
return r return r
@ -295,7 +296,7 @@ def do_entreprise_check_etudiant(context, etudiant):
) # suppress parens and quote from name ) # suppress parens and quote from name
if not etudiant: if not etudiant:
return 1, None return 1, None
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ScoDocCursor) cursor = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute( cursor.execute(
"select etudid, nom, prenom from identite where upper(nom) ~ upper(%(etudiant)s) or etudid=%(etudiant)s", "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 from notes_log import log, logCallStack
import sco_utils as scu import sco_utils as scu
import notesdb as ndb
from notesdb import ScoDocCursor from notesdb import ScoDocCursor
from sco_exceptions import AccessDenied, ScoValueError from sco_exceptions import AccessDenied, ScoValueError
import VERSION import VERSION
@ -99,7 +100,7 @@ def do_evaluation_delete(context, REQUEST, evaluation_id):
moduleimpl_id = the_evals[0]["moduleimpl_id"] moduleimpl_id = the_evals[0]["moduleimpl_id"]
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id) context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._evaluationEditor.delete(cnx, evaluation_id) context._evaluationEditor.delete(cnx, evaluation_id)
# inval cache pour ce semestre # 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" 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 = cnx.cursor(cursor_factory=ScoDocCursor)
cursor.execute(req, {"formsemestre_id": formsemestre_id}) cursor.execute(req, {"formsemestre_id": formsemestre_id})
res = cursor.dictfetchall() res = cursor.dictfetchall()
@ -363,7 +364,7 @@ def do_evaluation_list_in_sem(context, formsemestre_id):
# def formsemestre_evaluations_list(context, formsemestre_id): # def formsemestre_evaluations_list(context, formsemestre_id):
# """Liste (non triée) des evals pour ce semestre""" # """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" # 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 = cnx.cursor(cursor_factory=ScoDocCursor)
# cursor.execute( req, { 'formsemestre_id' : formsemestre_id } ) # cursor.execute( req, { 'formsemestre_id' : formsemestre_id } )
# return cursor.dictfetchall() # 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. et ramene liste de mappings utilisables en DTML.
""" """
may_be_nip = scu.is_valid_code_nip(expnom) may_be_nip = scu.is_valid_code_nip(expnom)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
if expnom and not may_be_nip: if expnom and not may_be_nip:
expnom = scu.strupper(expnom) # les noms dans la BD sont en uppercase expnom = scu.strupper(expnom) # les noms dans la BD sont en uppercase
etuds = scolars.etudident_list(cnx, args={"nom": expnom}, test="~") etuds = scolars.etudident_list(cnx, args={"nom": expnom}, test="~")

View File

@ -153,7 +153,7 @@ def formation_import_xml(
ndb.quote_dict(F_quoted) ndb.quote_dict(F_quoted)
log("F_quoted=%s" % F_quoted) log("F_quoted=%s" % F_quoted)
# find new version number # find new version number
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
log( log(
"select max(version) from notes_formations where acronyme=%(acronyme)s and titre=%(titre)s" "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): def do_formsemestre_list(context, *a, **kw):
"list formsemestres" "list formsemestres"
# log('do_formsemestre_list: a=%s kw=%s' % (str(a),str(kw))) # log('do_formsemestre_list: a=%s kw=%s' % (str(a),str(kw)))
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
sems = _formsemestreEditor.list(cnx, *a, **kw) sems = _formsemestreEditor.list(cnx, *a, **kw)
@ -220,7 +220,7 @@ def do_formsemestre_edit(context, sem, cnx=None, **kw):
"""Apply modifications to formsemestre. """Apply modifications to formsemestre.
Update etapes and resps. Invalidate cache.""" Update etapes and resps. Invalidate cache."""
if not cnx: if not cnx:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
_formsemestreEditor.edit(cnx, sem, **kw) _formsemestreEditor.edit(cnx, sem, **kw)
write_formsemestre_etapes(context, sem) write_formsemestre_etapes(context, sem)

View File

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

View File

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

View File

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

View File

@ -32,6 +32,7 @@
from notes_log import log from notes_log import log
import sco_utils as scu import sco_utils as scu
import notesdb as ndb
from sco_permissions import ( from sco_permissions import (
ScoImplement, ScoImplement,
ScoChangeFormation, 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): def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
"""Tableau de bord semestre HTML""" """Tableau de bord semestre HTML"""
# porté du DTML # porté du DTML
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list( Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id 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): def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Suppress a validation (ue_id, etudid) and redirect to formsemestre""" """Suppress a validation (ue_id, etudid) and redirect to formsemestre"""
log("etud_ue_suppress_validation( %s, %s, %s)" % (etudid, formsemestre_id, ue_id)) 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 = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"DELETE FROM scolar_formsemestre_validation WHERE etudid=%(etudid)s and ue_id=%(ue_id)s", "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 def get_group_infos(context, group_id, etat=None): # was _getlisteetud
"""legacy code: used by group_list and trombino""" """legacy code: used by group_list and trombino"""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
group = get_group(context, group_id) group = get_group(context, group_id)
sem = sco_formsemestre.get_formsemestre(context, group["formsemestre_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. Return True if ok, False si deja inscrit.
Warning: don't check if group_id exists (the caller should check). 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) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
args = {"etudid": etudid, "group_id": group_id} args = {"etudid": etudid, "group_id": group_id}
# déjà inscrit ? # déjà inscrit ?
@ -593,7 +593,7 @@ def change_etud_group_in_partition(
# 3- log # 3- log
formsemestre_id = partition["formsemestre_id"] formsemestre_id = partition["formsemestre_id"]
if REQUEST: if REQUEST:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
logdb( logdb(
REQUEST, REQUEST,
cnx, cnx,
@ -659,7 +659,7 @@ def setGroups(
context, etudid, group_id, partition, REQUEST=REQUEST context, etudid, group_id, partition, REQUEST=REQUEST
) )
# Retire les anciens membres: # Retire les anciens membres:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for etudid in old_members_set: for etudid in old_members_set:
log("removing %s from group %s" % (etudid, group_id)) log("removing %s from group %s" % (etudid, group_id))
@ -723,7 +723,7 @@ def createGroup(context, partition_id, group_name="", default=False, REQUEST=Non
raise ValueError( raise ValueError(
"group_name %s already exists in partition" % group_name "group_name %s already exists in partition" % group_name
) # XXX FIX: incorrect error handling (in AJAX) ) # XXX FIX: incorrect error handling (in AJAX)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
group_id = groupEditor.create( group_id = groupEditor.create(
cnx, {"partition_id": partition_id, "group_name": group_name} 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 "Il existe déjà une partition %s dans ce semestre" % partition_name
) )
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
partition_id = partitionEditor.create( partition_id = partitionEditor.create(
cnx, {"formsemestre_id": formsemestre_id, "partition_name": partition_name} 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)) log("partition_set_attr(%s, %s, %s)" % (partition_id, attr, value))
value = int(value) value = int(value)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
partition[attr] = value partition[attr] = value
partitionEditor.edit(cnx, partition) partitionEditor.edit(cnx, partition)
# invalid bulletin cache # invalid bulletin cache
@ -968,7 +968,7 @@ def partition_delete(
if not partition["partition_name"] and not force: if not partition["partition_name"] and not force:
raise ValueError("cannot suppress this partition") raise ValueError("cannot suppress this partition")
redirect = int(redirect) redirect = int(redirect)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
groups = get_partition_groups(context, partition) groups = get_partition_groups(context, partition)
if not dialog_confirmed: if not dialog_confirmed:
@ -1025,7 +1025,7 @@ def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
if neigh: # if neigh: #
# swap numero between partition and its neighbor # swap numero between partition and its neighbor
log("moving partition %s" % partition_id) log("moving partition %s" % partition_id)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
partition["numero"], neigh["numero"] = neigh["numero"], partition["numero"] partition["numero"], neigh["numero"] = neigh["numero"], partition["numero"]
partitionEditor.edit(cnx, partition) partitionEditor.edit(cnx, partition)
partitionEditor.edit(cnx, neigh) 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): if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
redirect = int(redirect) redirect = int(redirect)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
partitionEditor.edit( partitionEditor.edit(
cnx, {"partition_id": partition_id, "partition_name": partition_name} 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): if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
redirect = int(redirect) redirect = int(redirect)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
groupEditor.edit(cnx, {"group_id": group_id, "group_name": group_name}) groupEditor.edit(cnx, {"group_id": group_id, "group_name": group_name})
# redirect to partition edit page: # redirect to partition edit page:
@ -1391,7 +1391,7 @@ def do_evaluation_listeetuds_groups(
if not include_dems: if not include_dems:
req += " and Isem.etat='I'" req += " and Isem.etat='I'"
req += r req += r
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(req, {"evaluation_id": evaluation_id}) cursor.execute(req, {"evaluation_id": evaluation_id})
# log('listeetuds_groups: getallstudents=%s groups=%s' % (getallstudents,groups)) # log('listeetuds_groups: getallstudents=%s groups=%s' % (getallstudents,groups))
@ -1410,7 +1410,7 @@ def do_evaluation_listegroupes(context, evaluation_id, include_default=False):
c = "" c = ""
else: else:
c = " AND p.partition_name is not NULL" c = " AND p.partition_name is not NULL"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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" "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): def listgroups(context, group_ids):
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
groups = [] groups = []
for group_id in group_ids: 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 """Liste les etudiants inscrits dans n'importe quel semestre
SAUF sem à la date de début de sem. SAUF sem à la date de début de sem.
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"]) sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"])
cursor.execute( cursor.execute(

View File

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

View File

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

View File

@ -37,7 +37,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.header import Header from email.header import Header
import notesdb as ndb # pylint: disable=unused-wildcard-import import notesdb as ndb
from notes_log import log from notes_log import log
import mails import mails
import scolars import scolars
@ -81,7 +81,7 @@ def add(context, REQUEST, typ, object=None, text="", url=None, max_frequency=Fal
secondes d'intervalle. secondes d'intervalle.
""" """
authuser_name = str(REQUEST.AUTHENTICATED_USER) authuser_name = str(REQUEST.AUTHENTICATED_USER)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
args = { args = {
"authenticated_user": authuser_name, "authenticated_user": authuser_name,
"user_info": context.Users.user_info(user_name=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. News are "compressed", ie redondant events are joined.
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute("select * from scolar_news order by date desc limit 100") cursor.execute("select * from scolar_news order by date desc limit 100")
selected_news = {} # (type,object) : news dict 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): def ficheEtud(context, etudid=None, REQUEST=None):
"fiche d'informations sur un etudiant" "fiche d'informations sur un etudiant"
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
if etudid and REQUEST: if etudid and REQUEST:
# la sidebar est differente s'il y a ou pas un etudid # la sidebar est differente s'il y a ou pas un etudid
# voir html_sidebar.sidebar() # 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 """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 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( validations = scolar_formsemestre_validation_list(
cnx, args={"formsemestre_id": formsemestre_id} 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 """Liste des autorisations d'inscription pour cet étudiant
émanant du semestre indiqué. émanant du semestre indiqué.
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return scolar_autorisation_inscription_list( return scolar_autorisation_inscription_list(
cnx, {"origin_formsemestre_id": origin_formsemestre_id, "etudid": etudid} cnx, {"origin_formsemestre_id": origin_formsemestre_id, "etudid": etudid}
) )
@ -1059,7 +1059,7 @@ def formsemestre_get_etud_capitalisation(context, sem, etudid):
'is_external' 'is_external'
} ] } ]
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""select distinct SFV.*, ue.ue_code from notes_ue ue, notes_formations nf, notes_formations nf2, """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 """Liste des formsemestres pouvant utiliser une UE capitalisee de ce semestre
(et qui doivent donc etre sortis du cache si l'on modifie ce (et qui doivent donc etre sortis du cache si l'on modifie ce
semestre): meme code formation, meme semestre_id, date posterieure""" semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0] F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -80,7 +80,7 @@ class ScoTag:
else: else:
# Create new tag: # Create new tag:
log("creating new tag: %s" % self.title) log("creating new tag: %s" % self.title)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
oid = ndb.DBInsertDict( oid = ndb.DBInsertDict(
cnx, self.tag_table, {"title": self.title}, commit=True cnx, self.tag_table, {"title": self.title}, commit=True
) )
@ -122,7 +122,7 @@ class ScoTag:
) )
if not r: if not r:
log("tag %s with %s" % (object_id, self.title)) 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) ndb.DBInsertDict(cnx, self.assoc_table, args, commit=True)
def remove_tag_from_object(self, object_id): 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 = liste chronologique d'opérations, la plus récente d'abord
[ { 'value', 'date', 'comment', 'uid' } ] [ { 'value', 'date', 'comment', 'uid' } ]
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
# Valeur courante # Valeur courante

View File

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

View File

@ -32,6 +32,7 @@ import time
import mails import mails
import sco_utils as scu import sco_utils as scu
from sco_utils import SCO_ENCODING from sco_utils import SCO_ENCODING
import notesdb as ndb
from sco_exceptions import ScoGenError, ScoValueError from sco_exceptions import ScoGenError, ScoValueError
from notesdb import ( from notesdb import (
EditableTable, EditableTable,
@ -660,7 +661,7 @@ def get_etud_info(etudid=False, code_nip=False, filled=False, REQUEST=None):
""" """
if etudid is None: if etudid is None:
return [] return []
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST) args = make_etud_args(etudid=etudid, code_nip=code_nip, REQUEST=REQUEST)
etud = scolars.etudident_list(cnx, args=args) 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 """Add key 'annotations' describing annotations of etuds
(used to list all annotations of a group) (used to list all annotations of a group)
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
for etud in etuds: for etud in etuds:
l = [] l = []
for a in etud_annotations_list(cnx, args={"etudid": etud["etudid"]}): for a in etud_annotations_list(cnx, args={"etudid": etud["etudid"]}):
@ -893,7 +894,7 @@ o.close()
def list_scolog(context, etudid): def list_scolog(context, etudid):
"liste des operations effectuees sur cet etudiant" "liste des operations effectuees sur cet etudiant"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"select * from scolog where etudid=%(etudid)s ORDER BY DATE DESC", "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 Pour chaque etudiant, ajoute ou formatte les champs
-> informations pour fiche etudiant ou listes diverses -> informations pour fiche etudiant ou listes diverses
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# open('/tmp/t','w').write( str(etuds) ) # open('/tmp/t','w').write( str(etuds) )
for etud in etuds: for etud in etuds:
etudid = etud["etudid"] etudid = etud["etudid"]
@ -1005,7 +1006,7 @@ def fillEtudsInfo(context, etuds):
def descr_situation_etud(context, etudid, ne=""): def descr_situation_etud(context, etudid, ne=""):
"""chaine decrivant la situation actuelle de l'etudiant""" """chaine decrivant la situation actuelle de l'etudiant"""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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;", "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 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.notes_log import log
from app.scodoc.scolog import logdb from app.scodoc.scolog import logdb
from app.scodoc.sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView from app.scodoc.sco_permissions import ScoAbsAddBillet, ScoAbsChange, ScoView
@ -164,8 +164,8 @@ def _AddAbsence(
raise ScoValueError("date absence trop loin dans le futur !") raise ScoValueError("date absence trop loin dans le futur !")
estjust = _toboolean(estjust) estjust = _toboolean(estjust)
matin = _toboolean(matin) matin = _toboolean(matin)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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 )", "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(), vars(),
@ -189,8 +189,8 @@ def _AddJustif(context, etudid, jour, matin, REQUEST, description=None):
if context._isFarFutur(jour): if context._isFarFutur(jour):
raise ScoValueError("date justificatif trop loin dans le futur !") raise ScoValueError("date justificatif trop loin dans le futur !")
matin = _toboolean(matin) matin = _toboolean(matin)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )", "insert into absences (etudid,jour,estabs,estjust,matin, description) values (%(etudid)s,%(jour)s, FALSE, TRUE, %(matin)s, %(description)s )",
vars(), vars(),
@ -212,8 +212,8 @@ def _AnnuleAbsence(context, etudid, jour, matin, moduleimpl_id=None, REQUEST=Non
""" """
# unpublished # unpublished
matin = _toboolean(matin) matin = _toboolean(matin)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) 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" req = "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and estabs"
if moduleimpl_id: if moduleimpl_id:
req += " and moduleimpl_id=%(moduleimpl_id)s" req += " and moduleimpl_id=%(moduleimpl_id)s"
@ -233,8 +233,8 @@ def _AnnuleJustif(context, etudid, jour, matin, REQUEST=None):
"Annule un justificatif" "Annule un justificatif"
# unpublished # unpublished
matin = _toboolean(matin) matin = _toboolean(matin)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS", "delete from absences where jour=%(jour)s and matin=%(matin)s and etudid=%(etudid)s and ESTJUST AND NOT ESTABS",
vars(), vars(),
@ -277,8 +277,8 @@ def AnnuleAbsencesDatesNoJust(context, etudid, dates, moduleimpl_id=None, REQUES
raise ValueError("invalid ampm !") raise ValueError("invalid ampm !")
context._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST) context._AnnuleAbsence(etudid, jour, matin, moduleimpl_id, REQUEST)
return return
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
# supr les absences non justifiees # supr les absences non justifiees
for date in dates: for date in dates:
cursor.execute( cursor.execute(
@ -332,8 +332,8 @@ def _list_abs_in_range(
else: else:
modul = "" modul = ""
if not cursor: if not cursor:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
""" """
SELECT DISTINCT A.JOUR, A.MATIN 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 " modul = " AND A.MODULEIMPL_ID = %(moduleimpl_id)s "
else: else:
modul = "" modul = ""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""SELECT COUNT(*) AS NbAbsJust FROM ( """SELECT COUNT(*) AS NbAbsJust FROM (
SELECT DISTINCT A.JOUR, A.MATIN SELECT DISTINCT A.JOUR, A.MATIN
@ -406,8 +406,8 @@ WHERE A.ETUDID = %(etudid)s
def _ListeAbsDate(context, etudid, beg_date, end_date): def _ListeAbsDate(context, etudid, beg_date, end_date):
# Liste des absences et justifs entre deux dates # Liste des absences et justifs entre deux dates
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""SELECT jour, matin, estabs, estjust, description FROM ABSENCES A """SELECT jour, matin, estabs, estjust, description FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s WHERE A.ETUDID = %(etudid)s
@ -451,8 +451,8 @@ def _ListeAbsDate(context, etudid, beg_date, end_date):
@scodoc7func(context) @scodoc7func(context)
def ListeAbsJust(context, etudid, datedebut): def ListeAbsJust(context, etudid, datedebut):
"Liste des absences justifiees (par ordre chronologique)" "Liste des absences justifiees (par ordre chronologique)"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B """SELECT DISTINCT A.ETUDID, A.JOUR, A.MATIN FROM ABSENCES A, ABSENCES B
WHERE A.ETUDID = %(etudid)s WHERE A.ETUDID = %(etudid)s
@ -474,8 +474,8 @@ ORDER BY A.JOUR
@scodoc7func(context) @scodoc7func(context)
def ListeAbsNonJust(context, etudid, datedebut): def ListeAbsNonJust(context, etudid, datedebut):
"Liste des absences NON justifiees (par ordre chronologique)" "Liste des absences NON justifiees (par ordre chronologique)"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""SELECT ETUDID, JOUR, MATIN FROM ABSENCES A """SELECT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s 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. ou, si datefin spécifié, entre deux dates.
Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées. Si only_no_abs: seulement les justificatifs correspondant aux jours sans absences relevées.
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A req = """SELECT DISTINCT ETUDID, JOUR, MATIN FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s WHERE A.ETUDID = %(etudid)s
AND A.ESTJUST AND A.ESTJUST
@ -527,8 +527,8 @@ AND B.ETUDID = %(etudid)s
def _GetAbsDescription(context, a, cursor=None): def _GetAbsDescription(context, a, cursor=None):
"Description associee a l'absence" "Description associee a l'absence"
if not cursor: if not cursor:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
a = a.copy() a = a.copy()
# a['jour'] = a['jour'].date() # a['jour'] = a['jour'].date()
if a["matin"]: # devrait etre booleen... :-( 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_abs: None (peu importe), True, False
is_just: idem is_just: idem
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A
WHERE A.jour = %(date)s WHERE A.jour = %(date)s
""" """
@ -595,8 +595,8 @@ WHERE A.jour = %(date)s
@scodoc7func(context) @scodoc7func(context)
def ListeAbsNonJustJour(context, date, am=True, pm=True): def ListeAbsNonJustJour(context, date, am=True, pm=True):
"Liste des absences non justifiees ce jour" "Liste des absences non justifiees ce jour"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
reqa = "" reqa = ""
if not am: if not am:
reqa += " AND NOT matin " reqa += " AND NOT matin "
@ -746,7 +746,7 @@ def SignaleAbsenceGrHebdo(
# calcule dates jours de cette semaine # calcule dates jours de cette semaine
# liste de dates iso "yyyy-mm-dd" # liste de dates iso "yyyy-mm-dd"
datessem = [notesdb.DateDMYtoISO(datelundi)] datessem = [ndb.DateDMYtoISO(datelundi)]
for _ in sco_abs.day_names(context)[1:]: for _ in sco_abs.day_names(context)[1:]:
datessem.append(sco_abs.next_iso_day(context, datessem[-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>' '<tr><td><span class="redboldtext">Aucun étudiant inscrit !</span></td></tr>'
) )
i = 1 i = 1
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for etud in etuds: for etud in etuds:
i += 1 i += 1
etudid = etud["etudid"] etudid = etud["etudid"]
@ -1241,8 +1241,8 @@ def _TablesAbsEtud(
absnonjust = context.ListeAbsNonJust(etudid=etudid, datedebut=datedebut) absnonjust = context.ListeAbsNonJust(etudid=etudid, datedebut=datedebut)
# examens ces jours là ? # examens ces jours là ?
if with_evals: if with_evals:
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=notesdb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for a in absnonjust + absjust: for a in absnonjust + absjust:
cursor.execute( cursor.execute(
"""select eval.* """select eval.*
@ -1370,8 +1370,8 @@ def EtatAbsencesGr(
REQUEST=None, REQUEST=None,
): ):
"""Liste les absences de groupes""" """Liste les absences de groupes"""
datedebut = notesdb.DateDMYtoISO(debut) datedebut = ndb.DateDMYtoISO(debut)
datefin = notesdb.DateDMYtoISO(fin) datefin = ndb.DateDMYtoISO(fin)
# Informations sur les groupes à afficher: # Informations sur les groupes à afficher:
groups_infos = sco_groups_view.DisplayedGroupsInfos( groups_infos = sco_groups_view.DisplayedGroupsInfos(
context, group_ids, REQUEST=REQUEST context, group_ids, REQUEST=REQUEST
@ -1515,7 +1515,7 @@ def EtatAbsencesDate(
) )
] ]
if date: if date:
dateiso = notesdb.DateDMYtoISO(date) dateiso = ndb.DateDMYtoISO(date)
nbetud = 0 nbetud = 0
t_nbabsjustam = 0 t_nbabsjustam = 0
t_nbabsam = 0 t_nbabsam = 0
@ -1620,7 +1620,7 @@ def AddBilletAbsence(
# #
justified = int(justified) justified = int(justified)
# #
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
billet_id = sco_abs.billet_absence_create( billet_id = sco_abs.billet_absence_create(
cnx, cnx,
{ {
@ -1766,7 +1766,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
return scu.log_unknown_etud(context, format=format, REQUEST=REQUEST) return scu.log_unknown_etud(context, format=format, REQUEST=REQUEST)
etud = etuds[0] etud = etuds[0]
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]}) billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]})
tab = context._tableBillets(billets, etud=etud) tab = context._tableBillets(billets, etud=etud)
return tab.make_page(context, REQUEST=REQUEST, format=format) return tab.make_page(context, REQUEST=REQUEST, format=format)
@ -1790,7 +1790,7 @@ def XMLgetBilletsEtud(context, etudid=False, REQUEST=None):
@scodoc7func(context) @scodoc7func(context)
def listeBillets(context, REQUEST=None): def listeBillets(context, REQUEST=None):
"""Page liste des billets non traités et formulaire recherche d'un billet""" """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}) billets = sco_abs.billet_absence_list(cnx, {"etat": 0})
tab = context._tableBillets(billets) tab = context._tableBillets(billets)
T = tab.html() T = tab.html()
@ -1820,7 +1820,7 @@ def listeBillets(context, REQUEST=None):
@scodoc7func(context) @scodoc7func(context)
def deleteBilletAbsence(context, billet_id, REQUEST=None, dialog_confirmed=False): def deleteBilletAbsence(context, billet_id, REQUEST=None, dialog_confirmed=False):
"""Supprime un billet.""" """Supprime un billet."""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id}) billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
if not billets: if not billets:
return REQUEST.RESPONSE.redirect( return REQUEST.RESPONSE.redirect(
@ -1846,7 +1846,7 @@ def _ProcessBilletAbsence(context, billet, estjust, description, REQUEST):
et change l'état du billet à 1. 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. 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: if billet["etat"] != 0:
log("billet=%s" % billet) log("billet=%s" % billet)
log("billet deja traité !") log("billet deja traité !")
@ -1896,7 +1896,7 @@ def _ProcessBilletAbsence(context, billet, estjust, description, REQUEST):
@scodoc7func(context) @scodoc7func(context)
def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None): def ProcessBilletAbsenceForm(context, billet_id, REQUEST=None):
"""Formulaire traitement d'un billet""" """Formulaire traitement d'un billet"""
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id}) billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
if not billets: if not billets:
return REQUEST.RESPONSE.redirect( 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] F = context.formation_list(args={"formation_id": oid})[0]
if context.formation_has_locked_sems(oid): if context.formation_has_locked_sems(oid):
raise ScoLockedFormError() raise ScoLockedFormError()
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# delete all UE in this formation # delete all UE in this formation
ues = context.do_ue_list({"formation_id": oid}) ues = context.do_ue_list({"formation_id": oid})
for ue in ues: for ue in ues:
@ -449,7 +449,7 @@ def formation_list(context, format=None, REQUEST=None, formation_id=None, args={
args = {} args = {}
else: else:
args = {"formation_id": formation_id} args = {"formation_id": formation_id}
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = _formationEditor.list(cnx, args=args) r = _formationEditor.list(cnx, args=args)
# log('%d formations found' % len(r)) # log('%d formations found' % len(r))
return scu.sendResult(REQUEST, r, name="formation", format=format) return scu.sendResult(REQUEST, r, name="formation", format=format)
@ -575,7 +575,7 @@ _ueEditor = ndb.EditableTable(
@scodoc7func(context) @scodoc7func(context)
def do_ue_create(context, args, REQUEST): def do_ue_create(context, args, REQUEST):
"create an ue" "create an ue"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# check duplicates # check duplicates
ues = context.do_ue_list( ues = context.do_ue_list(
{"formation_id": args["formation_id"], "acronyme": args["acronyme"]} {"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): def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=False):
"delete UE and attached matieres (but not modules (it should ?))" "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)) log("do_ue_delete: ue_id=%s, delete_validations=%s" % (ue_id, delete_validations))
# check # check
ue = context.do_ue_list({"ue_id": ue_id}) 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( ndb.SimpleQuery(
context, "DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id} context, "DELETE FROM scolar_events WHERE ue_id=%(ue_id)s", {"ue_id": ue_id}
) )
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._ueEditor.delete(cnx, ue_id) context._ueEditor.delete(cnx, ue_id)
# > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?): # > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?):
sco_core.inval_cache(context) sco_core.inval_cache(context)
@ -672,7 +672,7 @@ def _do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=
@scodoc7func(context) @scodoc7func(context)
def do_ue_list(context, *args, **kw): def do_ue_list(context, *args, **kw):
"list UEs" "list UEs"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return context._ueEditor.list(cnx, *args, **kw) return context._ueEditor.list(cnx, *args, **kw)
@ -691,7 +691,7 @@ _matiereEditor = ndb.EditableTable(
@scodoc7func(context) @scodoc7func(context)
def do_matiere_create(context, args, REQUEST): def do_matiere_create(context, args, REQUEST):
"create a matiere" "create a matiere"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# check # check
ue = context.do_ue_list({"ue_id": args["ue_id"]})[0] ue = context.do_ue_list({"ue_id": args["ue_id"]})[0]
# create matiere # create matiere
@ -714,7 +714,7 @@ def do_matiere_create(context, args, REQUEST):
@scodoc7func(context) @scodoc7func(context)
def do_matiere_delete(context, oid, REQUEST): def do_matiere_delete(context, oid, REQUEST):
"delete matiere and attached modules" "delete matiere and attached modules"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# check # check
mat = context.do_matiere_list({"matiere_id": oid})[0] mat = context.do_matiere_list({"matiere_id": oid})[0]
ue = context.do_ue_list({"ue_id": mat["ue_id"]})[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) @scodoc7func(context)
def do_matiere_list(context, *args, **kw): def do_matiere_list(context, *args, **kw):
"list matieres" "list matieres"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return context._matiereEditor.list(cnx, *args, **kw) return context._matiereEditor.list(cnx, *args, **kw)
@ -756,7 +756,7 @@ def do_matiere_list(context, *args, **kw):
@scodoc7func(context) @scodoc7func(context)
def do_matiere_edit(context, *args, **kw): def do_matiere_edit(context, *args, **kw):
"edit a matiere" "edit a matiere"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# check # check
mat = context.do_matiere_list({"matiere_id": args[0]["matiere_id"]})[0] mat = context.do_matiere_list({"matiere_id": args[0]["matiere_id"]})[0]
if sco_edit_matiere.matiere_is_locked(context, mat["matiere_id"]): if sco_edit_matiere.matiere_is_locked(context, mat["matiere_id"]):
@ -771,7 +771,7 @@ def do_matiere_edit(context, *args, **kw):
@scodoc7func(context) @scodoc7func(context)
def do_matiere_formation_id(context, matiere_id): def do_matiere_formation_id(context, matiere_id):
"get formation_id from matiere" "get formation_id from matiere"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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", "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): def do_module_create(context, args, REQUEST):
"create a module" "create a module"
# create # create
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = context._moduleEditor.create(cnx, args) r = context._moduleEditor.create(cnx, args)
# news # news
@ -859,7 +859,7 @@ def do_module_delete(context, oid, REQUEST):
) )
raise ScoGenError(err_page) raise ScoGenError(err_page)
# delete # delete
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._moduleEditor.delete(cnx, oid) context._moduleEditor.delete(cnx, oid)
# news # news
@ -878,7 +878,7 @@ def do_module_delete(context, oid, REQUEST):
@scodoc7func(context) @scodoc7func(context)
def do_module_list(context, *args, **kw): def do_module_list(context, *args, **kw):
"list modules" "list modules"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return context._moduleEditor.list(cnx, *args, **kw) return context._moduleEditor.list(cnx, *args, **kw)
@ -896,7 +896,7 @@ def do_module_edit(context, val):
if f in val: if f in val:
del val[f] del val[f]
# edit # edit
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._moduleEditor.edit(cnx, val) context._moduleEditor.edit(cnx, val)
sems = sco_formsemestre.do_formsemestre_list( sems = sco_formsemestre.do_formsemestre_list(
@ -968,7 +968,7 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
if neigh: # if neigh: #
# swap numero between partition and its neighbor # swap numero between partition and its neighbor
# log('moving module %s' % module_id) # log('moving module %s' % module_id)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
module["numero"], neigh["numero"] = neigh["numero"], module["numero"] module["numero"], neigh["numero"] = neigh["numero"], module["numero"]
if module["numero"] == neigh["numero"]: if module["numero"] == neigh["numero"]:
neigh["numero"] -= 2 * after - 1 neigh["numero"] -= 2 * after - 1
@ -1003,7 +1003,7 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
if neigh: # if neigh: #
# swap numero between partition and its neighbor # swap numero between partition and its neighbor
# log('moving ue %s (neigh #%s)' % (ue_id, neigh['numero'])) # log('moving ue %s (neigh #%s)' % (ue_id, neigh['numero']))
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
o["numero"], neigh["numero"] = neigh["numero"], o["numero"] o["numero"], neigh["numero"] = neigh["numero"], o["numero"]
if o["numero"] == neigh["numero"]: if o["numero"] == neigh["numero"]:
neigh["numero"] -= 2 * after - 1 neigh["numero"] -= 2 * after - 1
@ -1022,7 +1022,7 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
@scodoc7func(context) @scodoc7func(context)
def do_formsemestre_create(context, args, REQUEST, silent=False): def do_formsemestre_create(context, args, REQUEST, silent=False):
"create a formsemestre" "create a formsemestre"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
formsemestre_id = sco_formsemestre._formsemestreEditor.create(cnx, args) formsemestre_id = sco_formsemestre._formsemestreEditor.create(cnx, args)
if args["etapes"]: if args["etapes"]:
args["formsemestre_id"] = formsemestre_id 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) sem = sco_formsemestre_edit.can_edit_sem(context, REQUEST, formsemestre_id)
if not sem: if not sem:
raise AccessDenied("vous n'avez pas le droit d'effectuer cette opération") 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] ue = context.do_ue_list({"ue_id": ue_id})[0]
H = [ H = [
@ -1641,7 +1641,7 @@ def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="htm
else: else:
sem_ens[ensd["ens_id"]]["mods"].append(mod) sem_ens[ensd["ens_id"]]["mods"].append(mod)
# compte les absences ajoutées par chacun dans tout le semestre # compte les absences ajoutées par chacun dans tout le semestre
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for ens in sem_ens: for ens in sem_ens:
cursor.execute( cursor.execute(
@ -1733,7 +1733,7 @@ _formsemestre_inscriptionEditor = ndb.EditableTable(
@scodoc7func(context) @scodoc7func(context)
def do_formsemestre_inscription_create(context, args, REQUEST, method=None): def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
"create a formsemestre_inscription (and sco event)" "create a formsemestre_inscription (and sco event)"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
log("do_formsemestre_inscription_create: args=%s" % str(args)) log("do_formsemestre_inscription_create: args=%s" % str(args))
sems = sco_formsemestre.do_formsemestre_list( sems = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": args["formsemestre_id"]} context, {"formsemestre_id": args["formsemestre_id"]}
@ -1777,7 +1777,7 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
@scodoc7func(context) @scodoc7func(context)
def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None): def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
"delete formsemestre_inscription" "delete formsemestre_inscription"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._formsemestre_inscriptionEditor.delete(cnx, oid) context._formsemestre_inscriptionEditor.delete(cnx, oid)
sco_core.inval_cache( sco_core.inval_cache(
@ -1790,7 +1790,7 @@ def do_formsemestre_inscription_delete(context, oid, formsemestre_id=None):
@scodoc7func(context) @scodoc7func(context)
def do_formsemestre_inscription_list(context, *args, **kw): def do_formsemestre_inscription_list(context, *args, **kw):
"list formsemestre_inscriptions" "list formsemestre_inscriptions"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
return context._formsemestre_inscriptionEditor.list(cnx, *args, **kw) return context._formsemestre_inscriptionEditor.list(cnx, *args, **kw)
@ -1817,7 +1817,7 @@ def do_formsemestre_inscription_listinscrits(
@scodoc7func(context) @scodoc7func(context)
def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None): def do_formsemestre_inscription_edit(context, args=None, formsemestre_id=None):
"edit a formsemestre_inscription" "edit a formsemestre_inscription"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._formsemestre_inscriptionEditor.edit(cnx, args) context._formsemestre_inscriptionEditor.edit(cnx, args)
sco_core.inval_cache( sco_core.inval_cache(
context, formsemestre_id=formsemestre_id 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) raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
insem = insem[0] insem = insem[0]
# -- desinscription de tous les modules # -- desinscription de tous les modules
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( 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", "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 args["numero"] = n
# #
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
r = context._evaluationEditor.create(cnx, args) r = context._evaluationEditor.create(cnx, args)
# news # news
@ -2330,7 +2330,7 @@ def do_evaluation_list(context, args, sortkey=None):
'apresmidi' : 1 (termine après 12:00) ou 0 'apresmidi' : 1 (termine après 12:00) ou 0
'descrheure' : ' de 15h00 à 16h30' 'descrheure' : ' de 15h00 à 16h30'
""" """
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
evals = context._evaluationEditor.list(cnx, args, sortkey=sortkey) evals = context._evaluationEditor.list(cnx, args, sortkey=sortkey)
# calcule duree (chaine de car.) de chaque evaluation et ajoute jouriso, matin, apresmidi # calcule duree (chaine de car.) de chaque evaluation et ajoute jouriso, matin, apresmidi
for e in evals: for e in evals:
@ -2396,7 +2396,7 @@ def do_evaluation_edit(context, REQUEST, args):
args["moduleimpl_id"] = moduleimpl_id args["moduleimpl_id"] = moduleimpl_id
context._check_evaluation_args(args) context._check_evaluation_args(args)
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id) context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context._evaluationEditor.edit(cnx, args) context._evaluationEditor.edit(cnx, args)
# inval cache pour ce semestre # inval cache pour ce semestre
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0] M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
@ -2514,7 +2514,7 @@ def _notes_getall(
r = cache.get(evaluation_id) r = cache.get(evaluation_id)
if r != None: if r != None:
return r return r
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cond = " where evaluation_id=%(evaluation_id)s" cond = " where evaluation_id=%(evaluation_id)s"
if by_uid: if by_uid:
@ -2725,7 +2725,7 @@ def appreciation_add_form(
REQUEST=None, REQUEST=None,
): ):
"form ajout ou edition d'une appreciation" "form ajout ou edition d'une appreciation"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
if id: # edit mode if id: # edit mode
apps = scolars.appreciations_list(cnx, args={"id": id}) 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" "Donne les informations sur un etudiant"
t0 = time.time() t0 = time.time()
args = make_etud_args(etudid=etudid, REQUEST=REQUEST) args = make_etud_args(etudid=etudid, REQUEST=REQUEST)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
etuds = scolars.etudident_list(cnx, args) etuds = scolars.etudident_list(cnx, args)
if not etuds: if not etuds:
# etudiant non trouvé: message d'erreur # etudiant non trouvé: message d'erreur
@ -521,7 +521,7 @@ sco_publish(
def doAddAnnotation(context, etudid, comment, REQUEST): def doAddAnnotation(context, etudid, comment, REQUEST):
"ajoute annotation sur etudiant" "ajoute annotation sur etudiant"
authuser = REQUEST.AUTHENTICATED_USER authuser = REQUEST.AUTHENTICATED_USER
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
scolars.etud_annotations_create( scolars.etud_annotations_create(
cnx, cnx,
args={ args={
@ -543,7 +543,7 @@ def doSuppressAnnotation(context, etudid, annotation_id, REQUEST):
if not sco_permissions.can_suppress_annotation(context, 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 !") 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}) annos = scolars.etud_annotations_list(cnx, args={"id": annotation_id})
if len(annos) != 1: if len(annos) != 1:
raise ScoValueError("annotation inexistante !") raise ScoValueError("annotation inexistante !")
@ -562,7 +562,7 @@ def doSuppressAnnotation(context, etudid, annotation_id, REQUEST):
@scodoc7func(context) @scodoc7func(context)
def formChangeCoordonnees(context, etudid, REQUEST): def formChangeCoordonnees(context, etudid, REQUEST):
"edit coordonnees etudiant" "edit coordonnees etudiant"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0] etud = scolars.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
adrs = scolars.adresse_list(cnx, {"etudid": etudid}) adrs = scolars.adresse_list(cnx, {"etudid": etudid})
if adrs: if adrs:
@ -895,7 +895,7 @@ def _doDem_or_Def_Etudiant(
"Démission ou défaillance d'un étudiant" "Démission ou défaillance d'un étudiant"
# marque 'D' ou DEF dans l'inscription au semestre et ajoute # marque 'D' ou DEF dans l'inscription au semestre et ajoute
# un "evenement" scolarite # un "evenement" scolarite
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
# check lock # check lock
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
if sem["etat"] != "1": if sem["etat"] != "1":
@ -1011,7 +1011,7 @@ def _doCancelDem_or_Def(
if ins["etat"] != etat_current: if ins["etat"] != etat_current:
raise ScoException("etudiant non %s !!!" % etat_current) # obviously a bug raise ScoException("etudiant non %s !!!" % etat_current) # obviously a bug
ins["etat"] = etat_new ins["etat"] = etat_new
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
context.Notes.do_formsemestre_inscription_edit( context.Notes.do_formsemestre_inscription_edit(
args=ins, formsemestre_id=formsemestre_id 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)] H = [html_sco_header.sco_header(context, REQUEST, init_jquery_ui=True)]
F = context.sco_footer(REQUEST) F = context.sco_footer(REQUEST)
etudid = REQUEST.form.get("etudid", None) etudid = REQUEST.form.get("etudid", None)
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
descr = [] descr = []
if not edit: if not edit:
# creation nouvel etudiant # creation nouvel etudiant
@ -1446,7 +1446,7 @@ def _etudident_create_or_edit_form(context, REQUEST, edit):
@scodoc7func(context) @scodoc7func(context)
def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None): def etudident_delete(context, etudid, dialog_confirmed=False, REQUEST=None):
"Delete a student" "Delete a student"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
etuds = scolars.etudident_list(cnx, {"etudid": etudid}) etuds = scolars.etudident_list(cnx, {"etudid": etudid})
if not etuds: if not etuds:
raise ScoValueError("Etudiant inexistant !") 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) members, group, _, sem, _ = sco_groups.get_group_infos(context, group_id, etat=etat)
formsemestre_id = group["formsemestre_id"] formsemestre_id = group["formsemestre_id"]
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
H = [ H = [
context.Notes.html_sem_header( context.Notes.html_sem_header(
REQUEST, "Etudiants du %s" % (group["group_name"] or "semestre"), sem REQUEST, "Etudiants du %s" % (group["group_name"] or "semestre"), sem
@ -2014,7 +2014,7 @@ sco_publish(
@scodoc7func(context) @scodoc7func(context)
def stat_bac(context, formsemestre_id): def stat_bac(context, formsemestre_id):
"Renvoie statistisques sur nb d'etudiants par bac" "Renvoie statistisques sur nb d'etudiants par bac"
cnx = context.GetDBConnexion() cnx = ndb.GetDBConnexion()
ins = context.Notes.do_formsemestre_inscription_list( ins = context.Notes.do_formsemestre_inscription_list(
args={"formsemestre_id": formsemestre_id} args={"formsemestre_id": formsemestre_id}
) )

View File

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