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