1
0
forked from ScoDoc/ScoDoc

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)
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"))

View File

@ -324,8 +324,7 @@ 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
"""SELECT DISTINCT A.JOUR, A.MATIN
FROM ABSENCES A
WHERE A.ETUDID = %(etudid)s
AND A.ESTABS"""

View File

@ -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()

View File

@ -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:

View File

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

View File

@ -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,
)

View File

@ -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())

View File

@ -24,9 +24,9 @@
<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
indiquant la version du logiciel (ScoDoc {SCOVERSION})
<br />(pour plus d'informations sur les listes de diffusion <a
href="https://scodoc.org/ListesDeDiffusion/">voir cette page</a>).
indiquant la version du logiciel (ScoDoc {{SCOVERSION}})
<br />(pour plus d'informations sur les listes de diffusion
<a href="https://scodoc.org/ListesDeDiffusion/">voir cette page</a>).
</p>
</body>