On supprime la navigation vers les pages 1 an avant maintenant et 1 an après maintenant
This commit is contained in:
parent
355eb6c5f7
commit
6d3033ba37
@ -3,7 +3,6 @@ import calendar
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -38,19 +38,27 @@
|
||||
<header>
|
||||
<div class="title"><h1>{{ day | date:"l j F Y"|frdate }}</h1></div>
|
||||
<div class="navigation">
|
||||
<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>
|
||||
<div class="right">
|
||||
{% 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>
|
||||
|
@ -35,14 +35,22 @@
|
||||
<div class="title"><h1>{{ calendar.firstdate | date:"F o" }}</h1></div>
|
||||
<div class="navigation">
|
||||
<div>
|
||||
{% if calendar.firstdate|shift_day:-1|not_before_first %}
|
||||
{% if calendar.lastdate|not_after_last %}
|
||||
<a role="button" href="{% url 'month_view' calendar.previous_month.year calendar.previous_month.month %}?{{ filter.get_url }}">
|
||||
{% picto_from_name "chevron-left" %} précédent</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if calendar.lastdate|shift_day:+1|not_after_last %}
|
||||
{% if calendar.lastdate|not_before_first %}
|
||||
<div class="right">
|
||||
<a role="button" href="{% url 'month_view' calendar.next_month.year calendar.next_month.month %}?{{ filter.get_url }}">suivant
|
||||
{% picto_from_name "chevron-right" %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
<div id="calendar">
|
||||
|
@ -31,14 +31,22 @@
|
||||
<div class="title"><h1>Semaine du {{ calendar.calendar_days_list.0.date |date|frdate }}</h1></div>
|
||||
<div class="navigation">
|
||||
<div>
|
||||
<a role="button" href="{% url 'week_view' calendar.previous_week.year calendar.previous_week|week %}?{{ filter.get_url }}">
|
||||
{% if calendar.firstdate|shift_day:-1|not_before_first %}
|
||||
{% if calendar.lastdate|not_after_last %}
|
||||
<a role="button" href="{% url 'week_view' calendar.previous_week.year calendar.previous_week|week %}?{{ filter.get_url }}">
|
||||
{% picto_from_name "chevron-left" %} précédente</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if calendar.lastdate|shift_day:+1|not_after_last %}
|
||||
{% if calendar.lastdate|not_before_first %}
|
||||
<div class="right">
|
||||
<a role="button" href="{% url 'week_view' calendar.next_week.year calendar.next_week|week %}?{{ filter.get_url }}">suivante
|
||||
{% picto_from_name "chevron-right" %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</header>
|
||||
<div id="calendar">
|
||||
|
@ -3,7 +3,8 @@ from django.utils.safestring import mark_safe
|
||||
from django.template.defaultfilters import stringfilter
|
||||
|
||||
from urllib.parse import urlparse
|
||||
from datetime import timedelta, date
|
||||
from datetime import timedelta, date, datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.urls import reverse_lazy
|
||||
from django.templatetags.static import static
|
||||
from string import ascii_uppercase as auc
|
||||
@ -27,6 +28,14 @@ def week(d):
|
||||
return d.isocalendar()[1]
|
||||
|
||||
|
||||
@register.filter
|
||||
def not_before_first(d):
|
||||
return d >= datetime.now().date() - relativedelta(years=1)
|
||||
|
||||
@register.filter
|
||||
def not_after_last(d):
|
||||
return d <= datetime.now().date() + relativedelta(years=1)
|
||||
|
||||
@register.filter
|
||||
def shift_day(d, shift):
|
||||
return d + timedelta(days=shift)
|
||||
|
Loading…
Reference in New Issue
Block a user