ajout de facilitateurs de navigation

This commit is contained in:
Jean-Marie Favreau 2023-11-06 09:04:25 +01:00
parent 036f07073d
commit 1672fbaf67
3 changed files with 29 additions and 17 deletions

View File

@ -49,6 +49,12 @@
</div>
</div>
<footer>
{% if calendar.today_in_calendar %}
<a role="button" href="{% url 'aujourdhui' %}">Aujourd'hui</a>
<a role="button" href="{% url 'cette_semaine' %}">Cette semaine</a>
{% endif %}
</footer>
</article>

View File

@ -30,8 +30,6 @@
</hgroup>
<article>
<header>
<div class="navigation">
@ -54,10 +52,13 @@
</div>
<footer>
<p>Voir aussi tous les événements du mois de
<a href="{% url 'month_view' calendar.firstdate.year calendar.firstdate.month %}">{{ calendar.firstdate | date:"F o" }}</a>{% if calendar.firstdate.month != calendar.lastdate.month %}
ou tous les événements du mois de <a href="{% url 'month_view' calendar.lastdate.year calendar.lastdate.month %}">{{ calendar.lastdate | date:"F o" }}</a>
{% endif %}.</p>
{% if calendar.today_in_calendar %}
<a role="button" href="{% url 'aujourdhui' %}">Aujourd'hui</a>
{% endif %}
<a role="button" href="{% url 'month_view' calendar.firstdate.year calendar.firstdate.month %}">{{ calendar.firstdate | date:"F o" }}</a>
{% if calendar.firstdate.month != calendar.lastdate.month %}
<a role="button" href="{% url 'month_view' calendar.lastdate.year calendar.lastdate.month %}">{{ calendar.lastdate | date:"F o" }}</a>
{% endif %}
</footer>
</article>

View File

@ -76,6 +76,12 @@ class CalendarList:
self.fill_calendar_days()
def today_in_calendar(self):
for d in self.calendar_days.values():
if not d.is_today():
return True
return False
def all_in_past(self):
for d in self.calendar_days.values():
if not d.is_in_past():
@ -151,14 +157,13 @@ class CalendarWeek(CalendarList):
def home(request):
return week_view(request)
#return month_view(request, now.year, now.month)
def month_view(request, year = None, month = None):
# TODO: filter by category, tag
now = date.today()
if year == None:
if year is None:
year = now.year
if month == None:
if month is None:
month = now.month
cmonth = CalendarMonth(year, month)
@ -168,9 +173,9 @@ def month_view(request, year = None, month = None):
def week_view(request, year = None, week = None):
now = date.today()
if year == None:
if year is None:
year = now.year
if week == None:
if week is None:
week = now.isocalendar()[1]
cweek = CalendarWeek(year, week)
@ -181,11 +186,11 @@ def week_view(request, year = None, week = None):
def day_view(request, year = None, month = None, day = None):
now = date.today()
if year == None:
if year is None:
year = now.year
if month == None:
if month is None:
month = now.month
if day == None:
if day is None:
day = now.day
day = date(year, month, day)