From dbb5ac8946f563557b8e30721fe8a46ea11cd56f Mon Sep 17 00:00:00 2001 From: Iziram Date: Tue, 4 Jun 2024 16:26:55 +0200 Subject: [PATCH] =?UTF-8?q?Assiduit=C3=A9=20:=20calendrier=5Fassiduite=5Fe?= =?UTF-8?q?tud=20:=20prio=20absence=20non=5Fjust=20+=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/assiduites.py | 67 +++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 96445b81c..8484e01d0 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -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, + else: + heure_soir = scass.str_to_time( + ScoDocSiteConfig.get("assi_afternoon_time", "17:00") ) - est_just = self._get_color_justificatifs_cascade( - self._get_etats_from_justificatifs(justificatifs_matin), + # séparation en demi journées + 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}" - - 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 = [ + 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]: