diff --git a/src/agenda_culturel/calendar.py b/src/agenda_culturel/calendar.py index 84adcc4..204f0f8 100644 --- a/src/agenda_culturel/calendar.py +++ b/src/agenda_culturel/calendar.py @@ -214,6 +214,8 @@ class CalendarList: self.calendar_days = None + def is_today(self): + return self.firstdate == date.today() def build_internal(self): # create a list of DayInCalendars @@ -303,6 +305,9 @@ class CalendarList: def calendar_days_list(self): return list(self.get_calendar_days().values()) + def nb_days(self): + return (self.c_lastdate - self.c_firstdate).days + 1 + def time_intervals_list(self, onlyfirst=False): ds = self.calendar_days_list() result = [] diff --git a/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html b/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html index 576f784..a667b40 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html +++ b/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html @@ -14,7 +14,7 @@ {% endblock %} {% block navigation-menu %} -{% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.calendar_days_list|length %} +{% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %} {% navigation_links filter category %} {% endcache %} {% endblock %} @@ -26,23 +26,25 @@
+ {% cache 60000 upcoming_title user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}

{% block title %}{% block og_title %} {% if category %}{{ category.name }}{% else %}Événements{% endif %} - {% if calendar.calendar_days_list.0.is_today %} + {% if calendar.is_today %} à venir {% else %} - du {{ calendar.calendar_days_list.0.date| date:"l j F Y" }} - {% if calendar.calendar_days_list|length > 1 %} + du {{ calendar.firstdate | date:"l j F Y" }} + {% if calendar.nb_days > 1 %} et suivants {% endif %} {% endif %}{% if filter.has_location %} à {{ filter.get_position }}{% endif %} {% endblock %}{% endblock %}

+ {% endcache %} {% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=1 %} {% with cache_timeout=user.is_authenticated|yesno:"30,600" %} - {% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.calendar_days_list|length %} + {% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}