forked from ScoDoc/ScoDoc
Assiduites : fix bug comptage absences + invalide cache justification
This commit is contained in:
parent
1e33626b60
commit
5bb4e4e0eb
@ -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)
|
||||
@ -663,7 +663,7 @@ def get_assiduites_count_in_interval(
|
||||
|
||||
calculator: CountCalculator = CountCalculator()
|
||||
calculator.compute_assiduites(assiduites)
|
||||
calcul : dict = calculator.to_dict(only_total=False)
|
||||
calcul: dict = calculator.to_dict(only_total=False)
|
||||
nb_abs: dict = calcul["absent"][metrique]
|
||||
nb_abs_just: dict = calcul["absent_just"][metrique]
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user