Diverses petites améliorations du code

This commit is contained in:
Emmanuel Viennet 2023-12-22 15:18:20 +01:00
parent 79c6a03c26
commit 5e39b3ae44
7 changed files with 23 additions and 13 deletions

View File

@ -52,7 +52,7 @@ def get_model_api_object(model_cls: db.Model, model_id: int, join_cls: db.Model
"""
Retourne une réponse contenant la représentation api de l'objet "Model[model_id]"
Filtrage du département en fonction d'une classe de jointure (eg: Identite, Formsemstre) -> join_cls
Filtrage du département en fonction d'une classe de jointure (eg: Identite, Formsemestre) -> join_cls
exemple d'utilisation : fonction "justificatif()" -> app/api/justificatifs.py
"""

View File

@ -49,6 +49,11 @@ def decisions_jury(formsemestre_id: int):
"""Décisions du jury des étudiants du formsemestre."""
# APC, pair:
formsemestre: FormSemestre = db.session.get(FormSemestre, formsemestre_id)
if formsemestre is None:
return json_error(
404,
message="formsemestre inconnu",
)
if formsemestre.formation.is_apc():
app.set_sco_dept(formsemestre.departement.acronym)
rows = jury_but_results.get_jury_but_results(formsemestre)

View File

@ -232,6 +232,11 @@ class EtatJustificatif(int, BiDirectionalEnum):
EtatJustificatif.NON_VALIDE: "invalide",
}.get(self, "")
@classmethod
def is_valid_etat(cls, etat: int) -> bool:
"True if etat is valid"
return etat in cls._value2member_map_
def is_iso_formated(date: str, convert=False) -> bool or datetime.datetime or None:
"""

View File

@ -132,7 +132,7 @@ function sco_message(msg, className = "message_custom", duration = 0) {
if (duration) {
setTimeout(() => {
div.remove();
}, 8000);
}, duration);
}
}

View File

@ -259,9 +259,9 @@ def _signal_absences_justificatifs(etudid: int):
)
db.session.commit()
justif: Justificatif = Justificatif.create_justificatif(
etud=etud,
date_debut=localize_datetime(datetime.datetime(2020, 1, 17, 8, 0)),
date_fin=localize_datetime(datetime.datetime(2020, 1, 17, 18, 0)),
etud,
localize_datetime(datetime.datetime(2020, 1, 17, 8, 0)),
localize_datetime(datetime.datetime(2020, 1, 17, 18, 0)),
etat=EtatJustificatif.VALIDE,
)
db.session.add(justif)

View File

@ -414,9 +414,9 @@ def ajouter_assiduites_justificatifs(formsemestre: FormSemestre):
raison = random.choice(["raison", None])
code = Justificatif.create_justificatif(
etud=etud,
date_debut=deb_date,
date_fin=fin_date,
etud,
deb_date,
fin_date,
etat=etat,
raison=raison,
)