Fix bug: synchro apogee/dept

This commit is contained in:
Emmanuel Viennet 2021-09-13 22:10:01 +02:00
parent e9d996be41
commit e98302070a
10 changed files with 43 additions and 22 deletions

View File

@ -19,7 +19,7 @@ class FormSemestre(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
formsemestre_id = db.synonym("id") 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 # simplifier et accélérer les selects dans notesdb
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True) dept_id = db.Column(db.Integer, db.ForeignKey("departement.id"), index=True)
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id")) formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))

View File

@ -324,15 +324,14 @@ def list_abs_in_range(etudid, debut, fin, matin=None, moduleimpl_id=None, cursor
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
""" """SELECT DISTINCT A.JOUR, A.MATIN
SELECT DISTINCT A.JOUR, A.MATIN FROM ABSENCES A
FROM ABSENCES A WHERE A.ETUDID = %(etudid)s
WHERE A.ETUDID = %(etudid)s AND A.ESTABS"""
AND A.ESTABS"""
+ ismatin + ismatin
+ modul + modul
+ """ + """
AND A.JOUR BETWEEN %(debut)s AND %(fin)s AND A.JOUR BETWEEN %(debut)s AND %(fin)s
""", """,
{ {
"etudid": etudid, "etudid": etudid,

View File

@ -218,7 +218,10 @@ def user_nbdays_since_last_notif(email_addr, etudid):
cnx = ndb.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
""",
{"email_addr": email_addr, "etudid": etudid}, {"email_addr": email_addr, "etudid": etudid},
) )
res = cursor.dictfetchone() res = cursor.dictfetchone()

View File

@ -628,14 +628,18 @@ def AnnuleAbsencesDatesNoJust(etudid, dates, moduleimpl_id=None):
# supr les absences non justifiees # supr les absences non justifiees
for date in dates: for date in dates:
cursor.execute( 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(), vars(),
) )
sco_abs.invalidate_abs_etud_date(etudid, date) sco_abs.invalidate_abs_etud_date(etudid, date)
# s'assure que les justificatifs ne sont pas "absents" # s'assure que les justificatifs ne sont pas "absents"
for date in dates: for date in dates:
cursor.execute( 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(), vars(),
) )
if dates: if dates:

View File

@ -100,7 +100,7 @@ class ScoDocCache:
log("Error: cache set failed !") log("Error: cache set failed !")
except: except:
log("XXX CACHE Warning: error in set !!!") log("XXX CACHE Warning: error in set !!!")
status = None
return status return status
@classmethod @classmethod

View File

@ -307,7 +307,7 @@ def check_nom_prenom(cnx, nom="", prenom="", etudid=None):
# Don't allow some special cars (eg used in sql regexps) # 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): if scu.FORBIDDEN_CHARS_EXP.search(nom) or scu.FORBIDDEN_CHARS_EXP.search(prenom):
return False, 0 return False, 0
# Now count homonyms: # Now count homonyms (dans tous les départements):
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
req = """SELECT id req = """SELECT id
FROM identite FROM identite
@ -896,7 +896,7 @@ def list_scolog(etudid):
cnx = ndb.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",
{"etudid": etudid}, {"etudid": etudid},
) )
return cursor.dictfetchall() return cursor.dictfetchall()

View File

@ -139,6 +139,7 @@ def list_etuds_from_sem(src, dst):
def list_inscrits_date(sem): def list_inscrits_date(sem):
"""Liste les etudiants inscrits dans n'importe quel semestre """Liste les etudiants inscrits dans n'importe quel semestre
du même département
SAUF sem à la date de début de sem. SAUF sem à la date de début de sem.
""" """
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
@ -146,11 +147,15 @@ def list_inscrits_date(sem):
sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"]) sem["date_debut_iso"] = ndb.DateDMYtoISO(sem["date_debut"])
cursor.execute( cursor.execute(
"""SELECT I.etudid """SELECT I.etudid
FROM notes_formsemestre_inscription I, notes_formsemestre S FROM
WHERE I.formsemestre_id = S.id notes_formsemestre_inscription ins,
notes_formsemestre S,
identite i
WHERE ins.formsemestre_id = S.id
AND S.id != %(formsemestre_id)s AND S.id != %(formsemestre_id)s
AND S.date_debut <= %(date_debut_iso)s AND S.date_debut <= %(date_debut_iso)s
AND S.date_fin >= %(date_debut_iso)s AND S.date_fin >= %(date_debut_iso)s
AND ins.dept_id = %(dept_id)
""", """,
sem, sem,
) )

View File

@ -400,7 +400,10 @@ def list_synch(sem, anneeapogee=None):
def key2etud(key, etud_apo=False): def key2etud(key, etud_apo=False):
if not etud_apo: if not etud_apo:
etudid = key2etudid[key] 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["inscrit"] = is_inscrit # checkbox state
etud[ etud[
"datefinalisationinscription" "datefinalisationinscription"
@ -508,7 +511,14 @@ def list_all(etudsapo_set):
# d'interrogation par etudiant. # d'interrogation par etudiant.
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) 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()]) key2etudid = dict([(x[0], x[1]) for x in cursor.fetchall()])
all_set = set(key2etudid.keys()) all_set = set(key2etudid.keys())

View File

@ -24,9 +24,9 @@
<p> Si le problème persiste après intervention de votre équipe locale, <p> Si le problème persiste après intervention de votre équipe locale,
contacter la liste "notes" <a href="mailto:notes@listes.univ-paris13.fr">notes@listes.univ-paris13.fr</a> en contacter la liste "notes" <a href="mailto:notes@listes.univ-paris13.fr">notes@listes.univ-paris13.fr</a> en
indiquant la version du logiciel (ScoDoc {SCOVERSION}) indiquant la version du logiciel (ScoDoc {{SCOVERSION}})
<br />(pour plus d'informations sur les listes de diffusion <a <br />(pour plus d'informations sur les listes de diffusion
href="https://scodoc.org/ListesDeDiffusion/">voir cette page</a>). <a href="https://scodoc.org/ListesDeDiffusion/">voir cette page</a>).
</p> </p>
</body> </body>