diff --git a/src/agenda_culturel/calendar.py b/src/agenda_culturel/calendar.py index fd1354b..36feebc 100644 --- a/src/agenda_culturel/calendar.py +++ b/src/agenda_culturel/calendar.py @@ -127,21 +127,19 @@ class DayInCalendar: self.time_intervals = [IntervalInDay(self.date, i, n[0], n[1]) for i, n in enumerate(zip([all_day_name] + interval_names, [all_day_short_name] + interval_short_names))] - nm2 = datetime.now() + timedelta(hours=-2) for e in self.events: if e.start_time is None: self.time_intervals[0].add_event(e) else: dt = datetime.combine(e.start_day, e.start_time) - if dt >= nm2: - ok = False - for i in range(len(interval_markers)): - if dt < interval_markers[i]: - self.time_intervals[i + 1].add_event(e) - ok = True - break - if not ok: - self.time_intervals[-1].add_event(e) + ok = False + for i in range(len(interval_markers)): + if dt < interval_markers[i]: + self.time_intervals[i + 1].add_event(e) + ok = True + break + if not ok: + self.time_intervals[-1].add_event(e) def get_time_intervals(self): if self.time_intervals is None: diff --git a/src/agenda_culturel/templates/agenda_culturel/page-day.html b/src/agenda_culturel/templates/agenda_culturel/page-day.html deleted file mode 100644 index f90afda..0000000 --- a/src/agenda_culturel/templates/agenda_culturel/page-day.html +++ /dev/null @@ -1,120 +0,0 @@ -{% extends "agenda_culturel/page.html" %} - - - -{% load i18n %} - -{% load cat_extra %} -{% load event_extra %} -{% load utils_extra %} -{% load static %} -{% load cache %} - - -{% block entete_header %} - {% css_categories %} - -{% endblock %} - -{% block title %}{% block og_title %} -{{ day | date:"l j F"|frdate }} -{% endblock %}{% endblock %} - - - {% block content %} - - {% get_current_language as LANGUAGE_CODE %} - {% with cache_timeout=user.is_authenticated|yesno:"30,600" %} - {% cache cache_timeout day user.is_authenticated day filter.to_str LANGUAGE_CODE %} - - - - {% include "agenda_culturel/filter-inc.html" with filter=filter %} - -
-
-

{{ day | date:"l j F"|frdate }}

- -
-
- - -
- - -
- {% if events %} - {% for event in events %} - {% include "agenda_culturel/single-event/event-in-list-by-day-inc.html" with event=event filter=filter day=day indexlink=1 %} - {% endfor %} - {% else %} -
- {% if filter.is_active %} - Il n'y a pas d'événement prévu à cette date correspondant au filtre sélectionné. - {% else %} - Il n'y a pas d'événement prévu à cette date. - {% endif %} -
- {% endif %} - -
- - - - -
-{% endcache %} -{% endwith %} - -{% endblock %} \ No newline at end of file diff --git a/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html b/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html index c96dc2f..20ce4cf 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html +++ b/src/agenda_culturel/templates/agenda_culturel/page-upcoming.html @@ -15,7 +15,7 @@ {% endblock %} -{% block title %}{% block og_title %}Événements à venir{% endblock %}{% endblock %} + {% block body-class %}a-venir{% endblock %} @@ -26,23 +26,43 @@ {% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.to_str LANGUAGE_CODE %}
-

Événements à venir

+

{% block title %}{% block og_title %} + {% if calendar.calendar_days_list.0.is_now %} + Événements à venir + {% else %} + Événements du {{ calendar.calendar_days_list.0.date| date:"l j F Y" }} + {% endif %} + {% endblock %}{% endblock %}

{% include "agenda_culturel/filter-inc.html" with filter=filter %}
@@ -50,7 +70,21 @@
{% picto_from_name "chevrons-up" %} -

{{ cd.date }}

+ {% if cd.is_today %} +
+

Aujourd'hui

+

{{ cd.date|date:"l j F Y"|frdate }}

+
+ {% else %} + {% if cd.is_tomorrow %} +
+

Demain

+

{{ cd.date|date:"l j F Y"|frdate }}

+
+ {% else %} +

{{ cd.date|date:"l j F Y"|frdate }}

+ {% endif %} + {% endif %}
{% if cd.events|length > 0 %}
@@ -81,7 +115,7 @@ {% picto_from_name "chevron-up" %}

{{ ti.name }}

-

{{ ti.date }}

+

{{ ti.date| date:"l j F"|frdate }}

{% with indexti=cd.id %} @@ -96,15 +130,25 @@ {% endfor %}

Voir aussi

+ {% if date_pred %} + {% picto_from_name "chevrons-left" %} + {% endif %} {% if calendar.today_in_calendar %} Aujourd'hui {% endif %} + {% if calendar.calendar_days_list|length == 1 %} + Autour du {{ day }} + {% endif %} Semaine du {{ calendar.firstdate }} {{ calendar.firstdate | date:"F o" }} {% if calendar.firstdate.month != calendar.lastdate.month %} {{ calendar.lastdate | date:"F o" }} {% endif %} Export ical {% picto_from_name "calendar" %} + {% if date_next %} + {% picto_from_name "chevrons-right" %} + {% endif %} +
{% endcache %} diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py index 9e34e14..bf8468a 100644 --- a/src/agenda_culturel/urls.py +++ b/src/agenda_culturel/urls.py @@ -15,6 +15,7 @@ urlpatterns = [ path("jour////", day_view, name="day_view"), path("aujourdhui/", day_view, name="aujourdhui"), path("a-venir/", upcoming_events, name="a_venir"), + path("a-venir////", upcoming_events, name="a_venir_jour"), path("cette-semaine/", week_view, name="cette_semaine"), path("ce-mois-ci", month_view, name="ce_mois_ci"), path("tag//", view_tag, name="view_tag"), diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 99c5e4a..90a0d06 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -441,58 +441,34 @@ def week_view(request, year=None, week=None, home=False): def day_view(request, year=None, month=None, day=None): + return upcoming_events(request, year, month, day, 0) + + +def upcoming_events(request, year=None, month=None, day=None, neighsize=1): now = date.today() if year is None: year = now.year if month is None: month = now.month if day is None: - day = now.day + day = now.day + neighsize day = date(year, month, day) request = EventFilter.set_default_values(request) filter = EventFilter(request.GET, get_event_qs(request), request=request) - cday = CalendarDay(day, filter) - - categories = Counter( - [ - e.category if e.category is not None else Category.get_default_category() - for e in cday.get_events() - ] - ) - categories = [(k, v) for k, v in categories.items()] - categories.sort(key=lambda k: -k[1]) - - context = { - "day": day, - "events": cday.get_events(), - "filter": filter, - "categories": categories, - } - return render(request, "agenda_culturel/page-day.html", context) - - -def upcoming_events(request, year=None, month=None, day=None): - now = date.today() - if year is None: - year = now.year - if month is None: - month = now.month - if day is None: - day = now.day - - day = date(year, month, day) - - request = EventFilter.set_default_values(request) - filter = EventFilter(request.GET, get_event_qs(request), request=request) - cal = CalendarList(now, now + timedelta(days=4), filter, True) - + cal = CalendarList(day + timedelta(days=-neighsize), day + timedelta(days=neighsize), filter, True) + context = { "calendar": cal, "now": now, + "day": day, "filter": filter, + "date_pred": day + timedelta(days=-neighsize - 1), + "date_next": day + timedelta(days=neighsize + 1) } + + return render(request, "agenda_culturel/page-upcoming.html", context) def view_tag(request, t):