Ajout d'un lien pour la journée

This commit is contained in:
Jean-Marie Favreau 2023-11-06 08:40:30 +01:00
parent c30640e137
commit bfdb9c6342
3 changed files with 22 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<article class="day{{ day|calendar_classes:fixed_style }}" id="{{ daytag }}">
<header>
<h2><a href="{% url 'day_view' day.date.year day.date.month day.date.day %}">{{ day.date | date:"l j" }}</a></h2>
<h2><a href="{{ day.date | url_day }}">{{ day.date | date:"l j" }}</a></h2>
</header>
{% if day.events %}
{% if resume %}
@ -38,7 +38,7 @@
</ul>
<footer>
<div class="buttons">
<a href="{% url 'day_view' day.date.year day.date.month day.date.day %}" role="button">Voir la journée <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<a href="{{ day.date | url_day }}" role="button">Voir la journée <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
</div>

View File

@ -1,8 +1,10 @@
{% load utils_extra %}
<article class='ephemeris'>
{% if not event.end_day or event.start_day == event.end_day %}
{{ event.start_day |date:"l" }}<br />
<span class="large">{{ event.start_day |date:"j" }}</span><br />
{{ event.start_day |date:"F" }}
<a href="{{ event.start_day | url_day }}"><span class="large">{{ event.start_day |date:"j" }}</span><br />
{{ event.start_day |date:"F" }}</a>
{% if event.start_time %}
<footer>
<span class="large">{{ event.start_time }}</span>
@ -11,13 +13,13 @@
{% else %}
du
{{ event.start_day |date:"D" }}<br />
<span class="large">{{ event.start_day |date:"j" }} </span>
<a href="{{ event.start_day | url_day }}"><span class="large">{{ event.start_day |date:"j" }} </span>
{% if event.start_day|date:"F" != event.end_day|date:"F" %}
{{ event.start_day |date:"F" }}
{% endif %}<br />
{% endif %}</a><br />
au
{{ event.start_day |date:"D" }} <br />
<span class="large">{{ event.end_day |date:"j" }}</span><br />
{{ event.end_day |date:"F" }}
<a href="{{ event.end_day | url_day }}"><span class="large">{{ event.end_day |date:"j" }}</span><br />
{{ event.end_day |date:"F" }}</a>
{% endif %}
</article>

View File

@ -3,6 +3,7 @@ from django.utils.safestring import mark_safe
from urllib.parse import urlparse
from datetime import timedelta, date
from django.urls import reverse_lazy
register = template.Library()
@ -17,22 +18,27 @@ def hostname(url):
def add_de(txt):
return ("d'" if txt[0].lower() in ['a', 'e', 'i', 'o', 'u', 'y'] else "de ") + txt
@register.filter
def week(d):
return d.isocalendar()[1]
@register.filter
def shift_day(d, shift):
return d + timedelta(days=shift)
@register.filter
def first_day_of_this_week(d):
return date.fromisocalendar(d.year, week(d), 1)
@register.filter
def last_day_of_this_week(d):
return date.fromisocalendar(d.year, week(d), 7)
@register.filter
def calendar_classes(d, fixed_style):
result = ""
@ -44,3 +50,8 @@ def calendar_classes(d, fixed_style):
if not d.on_requested_interval:
result += " other_month"
return result
@register.filter
def url_day(d):
return reverse_lazy("day_view", kwargs={"year": d.year, "month": d.month, "day": d.day})