From e98302070ab7c748d552763468766321569f401b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 13 Sep 2021 22:10:01 +0200 Subject: [PATCH] Fix bug: synchro apogee/dept --- app/models/formsemestre.py | 2 +- app/scodoc/sco_abs.py | 11 +++++------ app/scodoc/sco_abs_notification.py | 5 ++++- app/scodoc/sco_abs_views.py | 8 ++++++-- app/scodoc/sco_cache.py | 2 +- app/scodoc/sco_etud.py | 4 ++-- app/scodoc/sco_inscr_passage.py | 9 +++++++-- app/scodoc/sco_moduleimpl_inscriptions.py | 4 ++-- app/scodoc/sco_synchro_etuds.py | 14 ++++++++++++-- app/templates/error_503.html | 6 +++--- 10 files changed, 43 insertions(+), 22 deletions(-) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 148d9c871..06adb3bea 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -19,7 +19,7 @@ class FormSemestre(db.Model): id = db.Column(db.Integer, primary_key=True) formsemestre_id = db.synonym("id") - # dept_id est aussi dans la formation, ajpouté ici pour + # dept_id est aussi dans la formation, ajouté ici pour # simplifier et accélérer les selects dans notesdb dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True) formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id")) diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index c318dd609..39d075bb1 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -324,15 +324,14 @@ def list_abs_in_range(etudid, debut, fin, matin=None, moduleimpl_id=None, cursor cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - """ -SELECT DISTINCT A.JOUR, A.MATIN -FROM ABSENCES A -WHERE A.ETUDID = %(etudid)s - AND A.ESTABS""" + """SELECT DISTINCT A.JOUR, A.MATIN + FROM ABSENCES A + WHERE A.ETUDID = %(etudid)s + AND A.ESTABS""" + ismatin + modul + """ - AND A.JOUR BETWEEN %(debut)s AND %(fin)s + AND A.JOUR BETWEEN %(debut)s AND %(fin)s """, { "etudid": etudid, diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py index 69f6518bb..bf7c5e095 100644 --- a/app/scodoc/sco_abs_notification.py +++ b/app/scodoc/sco_abs_notification.py @@ -218,7 +218,10 @@ def user_nbdays_since_last_notif(email_addr, etudid): cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - """select * from absences_notifications where email = %(email_addr)s and etudid=%(etudid)s order by notification_date desc""", + """SELECT * FROM absences_notifications + WHERE email = %(email_addr)s and etudid=%(etudid)s + ORDER BY notification_date DESC + """, {"email_addr": email_addr, "etudid": etudid}, ) res = cursor.dictfetchone() diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 213a4a3ef..8ab6a9a03 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -628,14 +628,18 @@ def AnnuleAbsencesDatesNoJust(etudid, dates, moduleimpl_id=None): # supr les absences non justifiees for date in dates: cursor.execute( - "delete from absences where etudid=%(etudid)s and (not estjust) and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s", + """DELETE FROM absences + WHERE etudid=%(etudid)s and (not estjust) and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s + """, vars(), ) sco_abs.invalidate_abs_etud_date(etudid, date) # s'assure que les justificatifs ne sont pas "absents" for date in dates: cursor.execute( - "update absences set estabs=FALSE where etudid=%(etudid)s and jour=%(date)s and moduleimpl_id=%(moduleimpl_id)s", + """UPDATE absences SET estabs=FALSE + WHERE etudid=%(etudid)s AND jour=%(date)s AND moduleimpl_id=%(moduleimpl_id)s + """, vars(), ) if dates: diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index f92ba7bc2..50539d88c 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -100,7 +100,7 @@ class ScoDocCache: log("Error: cache set failed !") except: log("XXX CACHE Warning: error in set !!!") - + status = None return status @classmethod diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index 15fa188f1..80981b37c 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -307,7 +307,7 @@ def check_nom_prenom(cnx, nom="", prenom="", etudid=None): # Don't allow some special cars (eg used in sql regexps) if scu.FORBIDDEN_CHARS_EXP.search(nom) or scu.FORBIDDEN_CHARS_EXP.search(prenom): return False, 0 - # Now count homonyms: + # Now count homonyms (dans tous les départements): cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) req = """SELECT id FROM identite @@ -896,7 +896,7 @@ def list_scolog(etudid): cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - "select * from scolog where etudid=%(etudid)s ORDER BY DATE DESC", + "SELECT * FROM scolog WHERE etudid=%(etudid)s ORDER BY DATE DESC", {"etudid": etudid}, ) return cursor.dictfetchall() diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 60787c5f9..4bcb59820 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -139,6 +139,7 @@ def list_etuds_from_sem(src, dst): def list_inscrits_date(sem): """Liste les etudiants inscrits dans n'importe quel semestre + du même département SAUF sem à la date de début de sem. """ cnx = ndb.GetDBConnexion() @@ -146,11 +147,15 @@ def list_inscrits_date(sem): sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"]) cursor.execute( """SELECT I.etudid - FROM notes_formsemestre_inscription I, notes_formsemestre S - WHERE I.formsemestre_id = S.id + FROM + notes_formsemestre_inscription ins, + notes_formsemestre S, + identite i + WHERE ins.formsemestre_id = S.id AND S.id != %(formsemestre_id)s AND S.date_debut <= %(date_debut_iso)s AND S.date_fin >= %(date_debut_iso)s + AND ins.dept_id = %(dept_id) """, sem, ) diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index ce1d972c1..91650d489 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -529,10 +529,10 @@ def do_etud_desinscrit_ue(etudid, formsemestre_id, ue_id, REQUEST=None): cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - """DELETE FROM notes_moduleimpl_inscription + """DELETE FROM notes_moduleimpl_inscription WHERE moduleimpl_inscription_id IN ( SELECT i.moduleimpl_inscription_id FROM - notes_moduleimpl mi, notes_modules mod, + notes_moduleimpl mi, notes_modules mod, notes_formsemestre sem, notes_moduleimpl_inscription i WHERE sem.formsemestre_id = %(formsemestre_id)s AND mi.formsemestre_id = sem.formsemestre_id diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index b3a158f52..da7cc3bc3 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -400,7 +400,10 @@ def list_synch(sem, anneeapogee=None): def key2etud(key, etud_apo=False): if not etud_apo: etudid = key2etudid[key] - etud = sco_etud.identite_list(cnx, {"etudid": etudid})[0] + etuds = sco_etud.identite_list(cnx, {"etudid": etudid}) + if not etud: # ? cela ne devrait pas arriver XXX + log(f"XXX key2etud etudid={{etudid}}, type {{type(etudid)}}") + etud = etuds[0] etud["inscrit"] = is_inscrit # checkbox state etud[ "datefinalisationinscription" @@ -508,7 +511,14 @@ def list_all(etudsapo_set): # d'interrogation par etudiant. cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) - cursor.execute("SELECT " + EKEY_SCO + ", id AS etudid FROM identite") + cursor.execute( + "SELECT " + + EKEY_SCO + + """, id AS etudid + FROM identite WHERE dept_id=%(dept_id) + """, + {"dept_id", g.scodoc_dept_id}, + ) key2etudid = dict([(x[0], x[1]) for x in cursor.fetchall()]) all_set = set(key2etudid.keys()) diff --git a/app/templates/error_503.html b/app/templates/error_503.html index ba0ef9e04..723a87179 100644 --- a/app/templates/error_503.html +++ b/app/templates/error_503.html @@ -24,9 +24,9 @@

Si le problème persiste après intervention de votre équipe locale, contacter la liste "notes" notes@listes.univ-paris13.fr en - indiquant la version du logiciel (ScoDoc {SCOVERSION}) -
(pour plus d'informations sur les listes de diffusion voir cette page). + indiquant la version du logiciel (ScoDoc {{SCOVERSION}}) +
(pour plus d'informations sur les listes de diffusion + voir cette page).