Amélioration des accès rapides agenda
This commit is contained in:
parent
519528cf69
commit
f1ec525c5f
@ -16,7 +16,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block navigation-menu %}
|
{% block navigation-menu %}
|
||||||
{% cache 90000 navigation_links_month user.is_authenticated calendar.firstdate category filter.get_url %}
|
{% cache 90000 navigation_links_month user.is_authenticated calendar.firstdate category filter.get_url %}
|
||||||
{% navigation_links filter category %}
|
{% navigation_links filter category calendar "month" %}
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block navigation-menu %}
|
{% block navigation-menu %}
|
||||||
{% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}
|
{% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}
|
||||||
{% navigation_links filter category %}
|
{% navigation_links filter category calendar "upcoming" %}
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block navigation-menu %}
|
{% block navigation-menu %}
|
||||||
{% cache 90000 navigation_links_week user.is_authenticated calendar.firstdate category filter.get_url %}
|
{% cache 90000 navigation_links_week user.is_authenticated calendar.firstdate category filter.get_url %}
|
||||||
{% navigation_links filter category %}
|
{% navigation_links filter category calendar "week" %}
|
||||||
{% endcache %}
|
{% endcache %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
||||||
|
@ -2,6 +2,8 @@ from datetime import date, datetime, timedelta
|
|||||||
import calendar
|
import calendar
|
||||||
from string import ascii_uppercase as auc
|
from string import ascii_uppercase as auc
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
from django.utils.formats import localize
|
||||||
|
from django.utils import dates
|
||||||
|
|
||||||
import emoji
|
import emoji
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@ -187,58 +189,70 @@ def no_emoji(text):
|
|||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def navigation_links(filter, category):
|
def navigation_links(filter, category, calendar, current_view):
|
||||||
extra = "?" + filter.get_url()
|
extra = "?" + filter.get_url()
|
||||||
if category is None:
|
|
||||||
result = (
|
result = ""
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("aujourdhui")
|
extra_path = "" if category is None else "_category"
|
||||||
+ extra
|
|
||||||
+ "\">aujourd'hui</a></li>"
|
if not calendar.today_in_calendar():
|
||||||
)
|
if current_view == "upcoming":
|
||||||
|
params = {}
|
||||||
|
if category:
|
||||||
|
params["cat"] = category.slug
|
||||||
|
params["year"] = calendar.firstdate.year
|
||||||
|
params["week"] = calendar.firstdate.isocalendar()[1]
|
||||||
|
result += (
|
||||||
|
'<li><a href="'
|
||||||
|
+ reverse_lazy("week_view" + extra_path, kwargs=params)
|
||||||
|
+ extra
|
||||||
|
+ '">semaine du '
|
||||||
|
+ localize(calendar.firstdate)
|
||||||
|
+ "</a></li>"
|
||||||
|
)
|
||||||
|
|
||||||
|
if current_view != "month":
|
||||||
|
params = {}
|
||||||
|
if category:
|
||||||
|
params["cat"] = category.slug
|
||||||
|
|
||||||
|
days = [calendar.firstdate]
|
||||||
|
if calendar.firstdate.month != calendar.lastdate.month:
|
||||||
|
days.append(calendar.lastdate)
|
||||||
|
for d in days:
|
||||||
|
params["year"] = d.year
|
||||||
|
params["month"] = d.month
|
||||||
|
result += (
|
||||||
|
'<li><a href="'
|
||||||
|
+ reverse_lazy("month_view" + extra_path, kwargs=params)
|
||||||
|
+ extra
|
||||||
|
+ '">'
|
||||||
|
+ dates.MONTHS[d.month]
|
||||||
|
+ " "
|
||||||
|
+ str(d.year)
|
||||||
|
+ "</a></li>"
|
||||||
|
)
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
if category:
|
||||||
|
kwargs["cat"] = category.slug
|
||||||
|
|
||||||
|
for t in [
|
||||||
|
("aujourdhui", "aujourd'hui"),
|
||||||
|
("a_venir", "ces jours-ci"),
|
||||||
|
("cette_semaine", "cette semaine"),
|
||||||
|
("ce_mois_ci", "ce mois-ci"),
|
||||||
|
]:
|
||||||
result += (
|
result += (
|
||||||
'<li><a href="'
|
'<li><a href="'
|
||||||
+ reverse_lazy("a_venir")
|
+ reverse_lazy(t[0] + extra_path, kwargs=kwargs)
|
||||||
+ extra
|
+ extra
|
||||||
+ '">ces jours-ci</a></li>'
|
+ '">'
|
||||||
)
|
+ t[1]
|
||||||
result += (
|
+ "</a></li>"
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("cette_semaine")
|
|
||||||
+ extra
|
|
||||||
+ '">cette semaine</a></li>'
|
|
||||||
)
|
|
||||||
result += (
|
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("ce_mois_ci")
|
|
||||||
+ extra
|
|
||||||
+ '">ce mois-ci</a></li>'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
result = (
|
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("aujourdhui_category", kwargs={"cat": category.slug})
|
|
||||||
+ extra
|
|
||||||
+ "\">aujourd'hui</a></li>"
|
|
||||||
)
|
|
||||||
result += (
|
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("a_venir_category", kwargs={"cat": category.slug})
|
|
||||||
+ extra
|
|
||||||
+ '">à venir</a></li>'
|
|
||||||
)
|
|
||||||
result += (
|
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("cette_semaine_category", kwargs={"cat": category.slug})
|
|
||||||
+ extra
|
|
||||||
+ '">cette semaine</a></li>'
|
|
||||||
)
|
|
||||||
result += (
|
|
||||||
'<li><a href="'
|
|
||||||
+ reverse_lazy("ce_mois_ci_category", kwargs={"cat": category.slug})
|
|
||||||
+ extra
|
|
||||||
+ '">ce mois-ci</a></li>'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return mark_safe(result)
|
return mark_safe(result)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user