Assiduité : calendrier_assiduite_etud : prio absence non_just + cleanup

This commit is contained in:
Iziram 2024-06-04 16:26:55 +02:00
parent 93bb9d598e
commit dbb5ac8946

View File

@ -2608,12 +2608,12 @@ class JourAssi(sco_gen_cal.Jour):
(version journee divisée en demi-journees)
"""
heure_midi = scass.str_to_time(ScoDocSiteConfig.get("assi_lunch_time", "13:00"))
plage: tuple[datetime.datetime, datetime.datetime] = ()
if matin:
heure_matin = scass.str_to_time(
ScoDocSiteConfig.get("assi_morning_time", "08:00")
)
matin = (
plage = (
# date debut
scu.localize_datetime(
datetime.datetime.combine(self.date, heure_matin)
@ -2621,71 +2621,52 @@ class JourAssi(sco_gen_cal.Jour):
# date fin
scu.localize_datetime(datetime.datetime.combine(self.date, heure_midi)),
)
assiduites_matin = [
assi
for assi in self.assiduites
if scu.is_period_overlapping(
(assi.date_debut, assi.date_fin), matin, bornes=False
)
]
justificatifs_matin = [
justi
for justi in self.justificatifs
if scu.is_period_overlapping(
(justi.date_debut, justi.date_fin), matin, bornes=False
)
]
etat = self._get_color_assiduites_cascade(
self._get_etats_from_assiduites(assiduites_matin),
show_pres=self.parent.show_pres,
show_reta=self.parent.show_reta,
)
est_just = self._get_color_justificatifs_cascade(
self._get_etats_from_justificatifs(justificatifs_matin),
)
return f"color {etat} {est_just}"
else:
heure_soir = scass.str_to_time(
ScoDocSiteConfig.get("assi_afternoon_time", "17:00")
)
# séparation en demi journées
aprem = (
plage = (
# date debut
scu.localize_datetime(datetime.datetime.combine(self.date, heure_midi)),
# date fin
scu.localize_datetime(datetime.datetime.combine(self.date, heure_soir)),
)
assiduites_aprem = [
assiduites = [
assi
for assi in self.assiduites
if scu.is_period_overlapping(
(assi.date_debut, assi.date_fin), aprem, bornes=False
(assi.date_debut, assi.date_fin), plage, bornes=False
)
]
justificatifs_aprem = [
justificatifs = [
justi
for justi in self.justificatifs
if scu.is_period_overlapping(
(justi.date_debut, justi.date_fin), aprem, bornes=False
(justi.date_debut, justi.date_fin), plage, bornes=False
)
]
etat = self._get_color_assiduites_cascade(
self._get_etats_from_assiduites(assiduites_aprem),
self._get_etats_from_assiduites(assiduites),
show_pres=self.parent.show_pres,
show_reta=self.parent.show_reta,
)
est_just = self._get_color_justificatifs_cascade(
self._get_etats_from_justificatifs(justificatifs_aprem),
self._get_etats_from_justificatifs(justificatifs),
)
if est_just == "est_just" and any(
not assi.est_just
for assi in assiduites
if assi.etat != scu.EtatAssiduite.PRESENT
):
est_just = ""
return f"color {etat} {est_just}"
def _get_etats_from_assiduites(self, assiduites: Query) -> list[scu.EtatAssiduite]: