1
0
forked from ScoDoc/ScoDoc

Assiduites : fix bug comptage absences + invalide cache justification

This commit is contained in:
Iziram 2024-01-09 14:38:02 +01:00
parent 1e33626b60
commit 5bb4e4e0eb
3 changed files with 32 additions and 12 deletions

View File

@ -188,7 +188,7 @@ class CountCalculator:
if assi.etat != scu.EtatAssiduite.PRESENT:
_key: str = scu.EtatAssiduite.inverse().get(assi.etat).name.lower()
if key not in self.data[_key]["demi"]:
self.data[_key]["demi"].append(day)
self.data[_key]["demi"].append(key)
if key not in self.data["total"]["demi"]:
self.data["total"]["demi"].append(key)

View File

@ -1492,7 +1492,9 @@ def tableau_assiduite_actions():
)
compute_assiduites_justified(objet.etudiant.id, [justificatif_correspondant])
scass.simple_invalidate_cache(
justificatif_correspondant.to_dict(), objet.etudiant.id
)
flash(f"{objet_name} justifiée")
return redirect(request.referrer)

View File

@ -1307,6 +1307,19 @@ def test_calcul_assiduites(test_client):
scu.EtatAssiduite.ABSENT,
False,
),
# 18/12
(
"12-18T08:00",
"12-18T10:00",
scu.EtatAssiduite.ABSENT,
False,
),
(
"12-18T10:00",
"12-18T12:00",
scu.EtatAssiduite.ABSENT,
False,
),
]
for ass in assiduites:
@ -1333,17 +1346,17 @@ def test_calcul_assiduites(test_client):
resultat_attendu: dict = {
"present": {"journee": 5, "demi": 8, "heure": 13.25, "compte": 9},
"absent": {
"journee": 5 + 5,
"demi": 7 + 10,
"heure": 11.25 + 42,
"compte": 7 + 1,
"journee": 6 + 5,
"demi": 8 + 10,
"heure": 15.25 + 42,
"compte": 9 + 1,
},
"absent_just": {"journee": 3, "demi": 3, "heure": 4.25, "compte": 3},
"absent_non_just": {
"journee": 3 + 5,
"demi": 4 + 10,
"heure": 7 + 42,
"compte": 4 + 1,
"journee": 4 + 5,
"demi": 5 + 10,
"heure": 11 + 42,
"compte": 6 + 1,
},
"retard": {
"journee": 5,
@ -1353,9 +1366,14 @@ def test_calcul_assiduites(test_client):
},
"retard_just": {"journee": 3, "demi": 3, "heure": 2.5, "compte": 3},
"retard_non_just": {"journee": 3, "demi": 4, "heure": 8.0, "compte": 4},
"total": {"journee": 10, "demi": 19, "heure": 77.0, "compte": 24},
"total": {"journee": 11, "demi": 20, "heure": 81.0, "compte": 26},
}
for key in resultat_attendu:
assert (
resultat_attendu[key]["journee"] * 2 >= resultat_attendu[key]["demi"]
), f"Trop de demi-journées [{key}]"
for key in resultat_attendu:
for key2 in resultat_attendu[key]:
assert (