Fix some sql request

This commit is contained in:
Emmanuel Viennet 2021-08-09 07:43:41 +02:00
parent 0e57f6b857
commit dfd4d5bb9d
4 changed files with 13 additions and 9 deletions

View File

@ -133,9 +133,9 @@ def comp_etud_sum_coef_modules_ue(context, formsemestre_id, etudid, ue_id):
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
"""SELECT mod.coefficient """SELECT mod.coefficient
FROM notes_modules mod, notes_moduleimpl mi, notes_moduleimpl_inscription ins FROM notes_modules mod, notes_moduleimpl mi, notes_moduleimpl_inscription ins
WHERE mod.module_id = mi.module_id WHERE mod.id = mi.module_id
and ins.etudid = %(etudid)s and ins.etudid = %(etudid)s
and ins.moduleimpl_id = mi.moduleimpl_id and ins.moduleimpl_id = mi.id
and mi.formsemestre_id = %(formsemestre_id)s and mi.formsemestre_id = %(formsemestre_id)s
and mod.ue_id = %(ue_id)s and mod.ue_id = %(ue_id)s
""", """,

View File

@ -283,10 +283,10 @@ class EditableTable(object):
self.id_name = id_name self.id_name = id_name
self.aux_tables = aux_tables self.aux_tables = aux_tables
self.dbfields = dbfields self.dbfields = dbfields
# DB remove object_id ("id" in db) # DB remove object_id and replace by "id":
try: try:
i = self.dbfields.index(id_name) i = self.dbfields.index(id_name)
self.dbfields = self.dbfields[:i] + self.dbfields[i + 1 :] self.dbfields = ("id",) + self.dbfields[:i] + self.dbfields[i + 1 :]
except ValueError: except ValueError:
pass pass
self.sortkey = sortkey self.sortkey = sortkey
@ -329,7 +329,10 @@ class EditableTable(object):
offset="", offset="",
): ):
"returns list of dicts" "returns list of dicts"
id_value = args.get(self.id_name)
vals = dictfilter(args, self.dbfields, self.filter_nulls) vals = dictfilter(args, self.dbfields, self.filter_nulls)
if (id_value is not None) and (not "id" in vals):
vals["id"] = id_value
if not sortkey: if not sortkey:
sortkey = self.sortkey sortkey = self.sortkey
res = DBSelectArgs( res = DBSelectArgs(

View File

@ -824,13 +824,14 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
return "".join(H) return "".join(H)
def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=False): def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
"""HTML list of UE sharing this code """HTML list of UE sharing this code
Either ue_code or ue_id may be specified. Either ue_code or ue_id may be specified.
Si hide_ue_id, ne montre pas l'UE d'origine dans la liste hide_ue_id spécifie un id à retirer de la liste.
""" """
from app.scodoc import sco_formations from app.scodoc import sco_formations
stop
if ue_id: if ue_id:
ue = do_ue_list(context, args={"ue_id": ue_id})[0] ue = do_ue_list(context, args={"ue_id": ue_id})[0]
if not ue_code: if not ue_code:

View File

@ -173,7 +173,7 @@ class ModuleTag(ScoTag):
# tous les modules de toutes les formations ! # tous les modules de toutes les formations !
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
self.context, self.context,
"SELECT " "SELECT id AS"
+ self.obj_colname + self.obj_colname
+ " FROM " + " FROM "
+ self.assoc_table + self.assoc_table
@ -188,8 +188,8 @@ class ModuleTag(ScoTag):
"""SELECT mt.module_id """SELECT mt.module_id
FROM notes_modules_tags mt, notes_modules m, notes_formations f FROM notes_modules_tags mt, notes_modules m, notes_formations f
WHERE mt.tag_id = %(tag_id)s WHERE mt.tag_id = %(tag_id)s
AND m.module_id = mt.module_id AND m.id = mt.module_id
AND m.formation_id = f.formation_id AND m.formation_id = f.id
AND f.formation_code = %(formation_code)s AND f.formation_code = %(formation_code)s
""", """,
args, args,