From dfd4d5bb9d987d3cf95fbf1e561390951eef41b2 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 9 Aug 2021 07:43:41 +0200 Subject: [PATCH] Fix some sql request --- app/scodoc/notes_table.py | 4 ++-- app/scodoc/notesdb.py | 7 +++++-- app/scodoc/sco_edit_ue.py | 5 +++-- app/scodoc/sco_tag_module.py | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index b3b50ae61..115db008d 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -133,9 +133,9 @@ def comp_etud_sum_coef_modules_ue(context, formsemestre_id, etudid, ue_id): infos = ndb.SimpleDictFetch( """SELECT mod.coefficient 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.moduleimpl_id = mi.moduleimpl_id + and ins.moduleimpl_id = mi.id and mi.formsemestre_id = %(formsemestre_id)s and mod.ue_id = %(ue_id)s """, diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 72441eaae..02d024a9a 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -283,10 +283,10 @@ class EditableTable(object): self.id_name = id_name self.aux_tables = aux_tables self.dbfields = dbfields - # DB remove object_id ("id" in db) + # DB remove object_id and replace by "id": try: 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: pass self.sortkey = sortkey @@ -329,7 +329,10 @@ class EditableTable(object): offset="", ): "returns list of dicts" + id_value = args.get(self.id_name) 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: sortkey = self.sortkey res = DBSelectArgs( diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 70b44152e..e33f82e3d 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -824,13 +824,14 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module 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 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 + stop if ue_id: ue = do_ue_list(context, args={"ue_id": ue_id})[0] if not ue_code: diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py index 681e5d53e..63e80334b 100644 --- a/app/scodoc/sco_tag_module.py +++ b/app/scodoc/sco_tag_module.py @@ -173,7 +173,7 @@ class ModuleTag(ScoTag): # tous les modules de toutes les formations ! r = ndb.SimpleDictFetch( self.context, - "SELECT " + "SELECT id AS" + self.obj_colname + " FROM " + self.assoc_table @@ -188,8 +188,8 @@ class ModuleTag(ScoTag): """SELECT mt.module_id FROM notes_modules_tags mt, notes_modules m, notes_formations f WHERE mt.tag_id = %(tag_id)s - AND m.module_id = mt.module_id - AND m.formation_id = f.formation_id + AND m.id = mt.module_id + AND m.formation_id = f.id AND f.formation_code = %(formation_code)s """, args,