On intègre un peu plus la nouvelle présentation
This commit is contained in:
parent
41de08c283
commit
8e40faa889
@ -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:
|
||||
|
@ -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 %}
|
||||
<script src="{% static 'js/filters.js' %}"></script>
|
||||
{% 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 %}
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<div class="title"><h1>{{ day | date:"l j F"|frdate }}</h1></div>
|
||||
<div class="navigation">
|
||||
{% if day|shift_day:-1|not_before_first %}
|
||||
{% if day|not_after_last %}
|
||||
<div>
|
||||
{% with day|shift_day:-1 as pred_day %}
|
||||
<a role="button" href="{% url 'day_view' pred_day.year pred_day.month pred_day.day %}?{{ filter.get_url }}">
|
||||
{% picto_from_name "chevron-left" %} précédent</a>
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if day|shift_day:-1|not_before_first %}
|
||||
{% if day|not_after_last %}
|
||||
<div class="right">
|
||||
{% with day|shift_day:1 as next_day %}
|
||||
<a role="button" href="{% url 'day_view' next_day.year next_day.month next_day.day %}?{{ filter.get_url }}">suivant
|
||||
{% picto_from_name "chevron-right" %}
|
||||
</a>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
</article>
|
||||
|
||||
|
||||
<div class="grid two-columns grid-reverse">
|
||||
<aside>
|
||||
<article>
|
||||
<header>
|
||||
<h2 id="index-day">{{ events|length }} événement{{ events|length|pluralize }} </h2>
|
||||
{% if events|length == 0 %}
|
||||
<p class="remarque">Il n'y a pas d'événement le {{ day }}</p>
|
||||
{% else %}
|
||||
<nav class="paragraph">
|
||||
<ul>
|
||||
{% for event in events %}
|
||||
<li id="index-event-{{ event.pk }}">{{ event.category | circle_cat:event.has_recurrences }}
|
||||
{% if event.start_day == day and event.start_time %}
|
||||
{{ event.start_time }}
|
||||
{% endif %} {{ event|picto_status }} <a href="#event-{{ event.pk }}">{{ event.title }},</a>
|
||||
{% include "agenda_culturel/event-location-inc.html" with event=event nolink=1 nocity=1 %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</header>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<h2>Voir aussi</h2>
|
||||
</header>
|
||||
<a role="button" href="{% url 'week_view' day.year day|week %}?{{ filter.get_url }}">Toute la semaine</a>
|
||||
</article>
|
||||
</aside>
|
||||
|
||||
<div>
|
||||
{% 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 %}
|
||||
<article>
|
||||
{% if filter.is_active %}
|
||||
<em>Il n'y a pas d'événement prévu à cette date correspondant au filtre sélectionné.</em>
|
||||
{% else %}
|
||||
<em>Il n'y a pas d'événement prévu à cette date.</em>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
{% endcache %}
|
||||
{% endwith %}
|
||||
|
||||
{% endblock %}
|
@ -15,7 +15,7 @@
|
||||
<script src="{% static 'js/filters.js' %}"></script>
|
||||
{% 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 %}
|
||||
|
||||
<article>
|
||||
<header><h1 id="index-avenir">Événements à venir</h1></header>
|
||||
<header><h1 id="index-avenir">{% 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 %}</h1></header>
|
||||
|
||||
|
||||
{% include "agenda_culturel/filter-inc.html" with filter=filter %}
|
||||
|
||||
<footer>
|
||||
<a href="{% url 'a_venir_jour' date_pred.year date_pred.month date_pred.day %}" aria-label="dates précédentes" role="button">
|
||||
{% picto_from_name "chevrons-left" %}
|
||||
{% if calendar.calendar_days_list|length == 1 %}
|
||||
{{ date_pred }}
|
||||
{% endif %}
|
||||
</a>
|
||||
{% if calendar.calendar_days_list|length > 1 %}
|
||||
{% for cd in calendar.calendar_days_list %}
|
||||
<a href="#{{ cd.id }}" role="button">
|
||||
{% if cd.is_today %}Aujourd'hui
|
||||
{% else %}
|
||||
{% if cd.is_tomorrow %}Demain
|
||||
{% else %}
|
||||
{{ cd.date| date:"l j" }}
|
||||
{{ cd.date| date:"l j b" }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% picto_from_name "chevrons-down" %}</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<a href="{% url 'a_venir_jour' date_next.year date_next.month date_next.day %}" aria-label="dates suivantes" role="button">
|
||||
{% if calendar.calendar_days_list|length == 1 %}
|
||||
{{ date_next }}
|
||||
{% endif %}
|
||||
{% picto_from_name "chevrons-right" %}
|
||||
</a>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
@ -50,7 +70,21 @@
|
||||
<article class="day-interval" id="{{ cd.id }}">
|
||||
<header class="sticky">
|
||||
<a role="button" class="secondary slide-buttons" href="#index-avenir" data-placement="left" data-tooltip="Retour en haut">{% picto_from_name "chevrons-up" %}</a>
|
||||
<h2>{{ cd.date }}</h2>
|
||||
{% if cd.is_today %}
|
||||
<hgroup>
|
||||
<h2>Aujourd'hui</h2>
|
||||
<h3>{{ cd.date|date:"l j F Y"|frdate }}</h3>
|
||||
</hgroup>
|
||||
{% else %}
|
||||
{% if cd.is_tomorrow %}
|
||||
<hgroup>
|
||||
<h2>Demain</h2>
|
||||
<h3>{{ cd.date|date:"l j F Y"|frdate }}</h3>
|
||||
</hgroup>
|
||||
{% else %}
|
||||
<h2>{{ cd.date|date:"l j F Y"|frdate }}</h2>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</header>
|
||||
{% if cd.events|length > 0 %}
|
||||
<div class="resume">
|
||||
@ -81,7 +115,7 @@
|
||||
<a role="button" class="secondary slide-buttons" href="#{{ cd.id }}" data-placement="left" data-tooltip="Retour au résumé de la journée">{% picto_from_name "chevron-up" %}</a>
|
||||
<hgroup>
|
||||
<h3>{{ ti.name }}</h3>
|
||||
<h4>{{ ti.date }}</h4>
|
||||
<h4>{{ ti.date| date:"l j F"|frdate }}</h4>
|
||||
</hgroup>
|
||||
</header>
|
||||
{% with indexti=cd.id %}
|
||||
@ -96,15 +130,25 @@
|
||||
{% endfor %}
|
||||
<article>
|
||||
<header><h2>Voir aussi</h2></header>
|
||||
{% if date_pred %}
|
||||
<a href="{% url 'a_venir_jour' date_pred.year date_pred.month date_pred.day %}" aria-label="dates précédentes" role="button">{% picto_from_name "chevrons-left" %}</a>
|
||||
{% endif %}
|
||||
{% if calendar.today_in_calendar %}
|
||||
<a role="button" href="{% url 'aujourdhui' %}?{{ filter.get_url }}">Aujourd'hui</a>
|
||||
{% endif %}
|
||||
{% if calendar.calendar_days_list|length == 1 %}
|
||||
<a role="button" href="{% url 'a_venir_jour' day.year day.month day.day %}?{{ filter.get_url }}">Autour du {{ day }}</a>
|
||||
{% endif %}
|
||||
<a role="button" href="{% url 'week_view' calendar.firstdate.year calendar.firstdate|week %}?{{ filter.get_url }}">Semaine du {{ calendar.firstdate }}</a>
|
||||
<a role="button" href="{% url 'month_view' calendar.firstdate.year calendar.firstdate.month %}?{{ filter.get_url }}">{{ 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 %}?{{ filter.get_url }}">{{ calendar.lastdate | date:"F o" }}</a>
|
||||
{% endif %}
|
||||
<a role="button" data-tooltip="Copiez ce lien et importez-le dans votre agenda" href="{% url 'export_ical' %}?{{ filter.get_url }}">Export ical {% picto_from_name "calendar" %}</a>
|
||||
{% if date_next %}
|
||||
<a href="{% url 'a_venir_jour' date_next.year date_next.month date_next.day %}" aria-label="dates suivantes" role="button">{% picto_from_name "chevrons-right" %}</a>
|
||||
{% endif %}
|
||||
|
||||
</article>
|
||||
|
||||
{% endcache %}
|
||||
|
@ -15,6 +15,7 @@ urlpatterns = [
|
||||
path("jour/<int:year>/<int:month>/<int:day>/", day_view, name="day_view"),
|
||||
path("aujourdhui/", day_view, name="aujourdhui"),
|
||||
path("a-venir/", upcoming_events, name="a_venir"),
|
||||
path("a-venir/<int:year>/<int:month>/<int:day>/", 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/<t>/", view_tag, name="view_tag"),
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user