From c3d6c1f40f3bb0c5a7969b6bd0bf7b8ac202f532 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 22 Aug 2021 15:36:17 +0200 Subject: [PATCH] Fix desinscription --- app/scodoc/sco_formsemestre_inscriptions.py | 7 ++++- app/scodoc/sco_pdf.py | 31 +++++++++++++++++---- app/views/notes.py | 3 +- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index dfeead3e0..8f2c3a088 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -163,7 +163,12 @@ def do_formsemestre_desinscription(etudid, formsemestre_id, REQUEST=None): cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - "select moduleimpl_inscription_id from notes_moduleimpl_inscription Im, notes_moduleimpl M where Im.etudid=%(etudid)s and Im.moduleimpl_id = M.moduleimpl_id and M.formsemestre_id = %(formsemestre_id)s", + """SELECT Im.id AS moduleimpl_inscription_id + FROM notes_moduleimpl_inscription Im, notes_moduleimpl M + WHERE Im.etudid=%(etudid)s + and Im.moduleimpl_id = M.id + and M.formsemestre_id = %(formsemestre_id)s + """, {"etudid": etudid, "formsemestre_id": formsemestre_id}, ) res = cursor.fetchall() diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index bed6ff317..3d3799c8a 100755 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -371,19 +371,40 @@ class PDFLock(object): log("PDFLock: granted to %s" % self.current_thread) +class WatchLock: + "Surveille threads (mais ne verrouille pas)" + + def __init__(self, timeout=None): + self.timeout = timeout + t = threading.current_thread() + self.native_id = t.native_id + self.ident = t.ident + + def acquire(self): + t = threading.current_thread() + if (self.native_id != t.native_id) or (self.ident != t.ident): + log( + f"Warning: LOCK detected several threads ! (native_id {self.native_id} -> {t.native_id}, ident {self.ident} -> {t.ident}" + ) + self.native_id = t.native_id + self.ident = t.ident + + def release(self): + t = threading.current_thread() + assert (self.native_id == t.native_id) and (self.ident == t.ident) + pass + + class FakeLock: "Pour ScoDoc 9: pas de verrou" - def __init__(self, timeout=15): - self.timeout = timeout - self.current_thread = threading.get_ident() + def __init__(self, timeout=None): + pass def acquire(self): - assert threading.get_ident() == self.current_thread pass def release(self): - assert threading.get_ident() == self.current_thread pass diff --git a/app/views/notes.py b/app/views/notes.py index 307c8b69a..a324f433b 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -1289,7 +1289,7 @@ def do_formsemestre_inscription_listinscrits( return scu.sendResult(REQUEST, r, format=format, name="inscrits") -@bp.route("/formsemestre_desinscription") +@bp.route("/formsemestre_desinscription", methods=["GET", "POST"]) @scodoc @permission_required(Permission.ScoImplement) @scodoc7func @@ -1373,6 +1373,7 @@ sco_publish( "/do_formsemestre_desinscription", sco_formsemestre_inscriptions.do_formsemestre_desinscription, Permission.ScoEtudInscrit, + methods=["GET", "POST"], )