forked from ScoDoc/ScoDoc
sco_gen_cal : hightlight + week_index + jour date
This commit is contained in:
parent
50f2cd7a0f
commit
2aafbad9e2
@ -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
|
||||
)
|
||||
|
@ -1,10 +1,11 @@
|
||||
<div class="calendrier">
|
||||
{% for mois,jours in calendrier.items() %}
|
||||
<div class="mois">
|
||||
{% for mois,semaines in calendrier.items() %}
|
||||
<div class="mois {{'highlight' if highlight=='mois'}}">
|
||||
<h3>{{mois}}</h3>
|
||||
<div class="jours">
|
||||
{% for jour in jours %}
|
||||
<div class="jour {{jour.get_class()}}">
|
||||
{% for semaine in semaines %}
|
||||
<div class="jours {{'highlight' if highlight=='semaine'}}" week_index="{{semaine}}">
|
||||
{% for jour in semaines[semaine] %}
|
||||
<div class="jour {{jour.get_class()}} {{'highlight' if highlight=='jour'}}" date="{{jour.get_date()}}">
|
||||
<span class="nom">{{jour.get_nom()}}</span>
|
||||
<div class="contenu">
|
||||
{{jour.get_html() | safe}}
|
||||
@ -12,6 +13,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -84,5 +86,8 @@
|
||||
border-left: solid 3px var(--couleur);
|
||||
border-right: solid 3px var(--couleur);
|
||||
}
|
||||
.highlight:hover{
|
||||
border: solid 3px yellow;
|
||||
}
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user