diff --git a/app/scodoc/sco_gen_cal.py b/app/scodoc/sco_gen_cal.py index 54a66e9de..8d11ac1d6 100644 --- a/app/scodoc/sco_gen_cal.py +++ b/app/scodoc/sco_gen_cal.py @@ -93,12 +93,22 @@ class Calendrier: Représente un calendrier Permet d'obtenir les informations sur les jours et générer une représentation html + + highlight: str + -> ["jour", "semaine", "mois"] + permet de mettre en valeur lors du passage de la souris """ - def __init__(self, date_debut: datetime.date, date_fin: datetime.date): + def __init__( + self, + date_debut: datetime.date, + date_fin: datetime.date, + highlight: str = None, + ): self.date_debut = date_debut self.date_fin = date_fin self.jours: dict[str, list[Jour]] = {} + self.highlight: str = highlight def _get_dates_between(self) -> list[datetime.date]: """ @@ -130,11 +140,13 @@ class Calendrier: month = scu.MONTH_NAMES_ABBREV[date.month - 1] # Ajouter le jour à la liste correspondante au mois if month not in organized: - organized[month] = [] + organized[month] = {} # semaine {22: []} jour: Jour = self.instanciate_jour(date) - - organized[month].append(jour) + semaine = date.strftime("%G-W%V") + if semaine not in organized[month]: + organized[month][semaine] = [] + organized[month][semaine].append(jour) self.jours = organized @@ -150,4 +162,6 @@ class Calendrier: get_html Renvoie le code html du calendrier """ self.organize_by_month() - return render_template("calendrier.j2", calendrier=self.jours) + return render_template( + "calendrier.j2", calendrier=self.jours, highlight=self.highlight + ) diff --git a/app/templates/calendrier.j2 b/app/templates/calendrier.j2 index 2149a7865..8a667b5b9 100644 --- a/app/templates/calendrier.j2 +++ b/app/templates/calendrier.j2 @@ -1,10 +1,11 @@
- {% for mois,jours in calendrier.items() %} -
+ {% for mois,semaines in calendrier.items() %} +

{{mois}}

-
- {% for jour in jours %} -
+ {% for semaine in semaines %} +
+ {% for jour in semaines[semaine] %} +
{{jour.get_nom()}}
{{jour.get_html() | safe}} @@ -12,6 +13,7 @@
{% endfor %}
+ {% endfor %}
{% endfor %}
@@ -84,5 +86,8 @@ border-left: solid 3px var(--couleur); border-right: solid 3px var(--couleur); } + .highlight:hover{ + border: solid 3px yellow; + } \ No newline at end of file