parent
02626c3ced
commit
182d7b85ce
@ -432,13 +432,19 @@ class CalendarList:
|
||||
|
||||
|
||||
class CalendarMonth(CalendarList):
|
||||
def __init__(self, year, month, filter, qs=None):
|
||||
def __init__(self, year, month, filter, qs=None, day=None):
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.day = day
|
||||
r = calendar.monthrange(year, month)
|
||||
|
||||
if self.day is None:
|
||||
first = date(year, month, 1)
|
||||
last = date(year, month, r[1])
|
||||
else:
|
||||
first = date(year, month, day)
|
||||
last = first + timedelta(days=28)
|
||||
last = last + timedelta(days=6 - last.weekday())
|
||||
|
||||
super().__init__(first, last, filter, qs)
|
||||
|
||||
|
@ -15,18 +15,35 @@
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
{% 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 this_month category filter.get_url %}
|
||||
{% navigation_links filter category calendar "month" %}
|
||||
{% endcache %}
|
||||
{% endblock %}
|
||||
{% block when_parameters %}{{ filter.get_url }}{% endblock %}
|
||||
{% block content %}
|
||||
{% with cache_timeout=user.is_authenticated|yesno:"30,6000" %}
|
||||
{% cache cache_timeout month user.is_authenticated calendar.firstdate category filter.get_url %}
|
||||
{% cache cache_timeout month user.is_authenticated calendar.firstdate this_month category filter.get_url %}
|
||||
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=0 %}
|
||||
<article>
|
||||
<header id="navigation">
|
||||
<div class="title small">
|
||||
{% if this_month %}
|
||||
<hgroup>
|
||||
<h1>
|
||||
{% if category %}{{ category.name }}{% endif %}
|
||||
ce mois-ci
|
||||
{% if filter.has_location %}à {{ filter.get_position }}{% endif %}
|
||||
<a aria-label="Quand"
|
||||
href="#quand-popup"
|
||||
data-target="quand-popup"
|
||||
onClick="toggleModal(event)">{% picto_from_name "calendar" %}</a>
|
||||
</h1>
|
||||
<h2>
|
||||
{{ calendar.firstdate|date:"F o" }}
|
||||
{% if calendar.firstdate.month != calendar.lastdate.month %}/ {{ calendar.lastdate|date:"F o" }}{% endif %}
|
||||
</h2>
|
||||
</hgroup>
|
||||
{% else %}
|
||||
<h1>
|
||||
{% if category %}{{ category.name }} en{% endif %}
|
||||
{{ calendar.firstdate | date:"F o" }}
|
||||
@ -36,6 +53,7 @@
|
||||
data-target="quand-popup"
|
||||
onClick="toggleModal(event)">{% picto_from_name "calendar" %}</a>
|
||||
</h1>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="left">
|
||||
{% if calendar.firstdate|shift_day:-1|not_before_first %}
|
||||
@ -110,7 +128,13 @@
|
||||
<header {% if day.is_today %}id="today"{% endif %}>
|
||||
<h3>
|
||||
<a href="{{ day.date | url_day:category }}?{{ filter.get_url }}"
|
||||
class="visible-link">{{ day.date | date:"l j" }}</a>
|
||||
class="visible-link">
|
||||
{% if day.date.day == 1 and this_month or day.date == calendar.firstdate and this_month %}
|
||||
{{ day.date | date:"l j F" }}
|
||||
{% else %}
|
||||
{{ day.date | date:"l j" }}
|
||||
{% endif %}
|
||||
</a>
|
||||
</h3>
|
||||
</header>
|
||||
{% if day.events %}
|
||||
|
@ -236,6 +236,10 @@ def home(request, cat=None):
|
||||
|
||||
def month_view(request, year=None, month=None, cat=None):
|
||||
now = date.today()
|
||||
if year is None and month is None:
|
||||
day = now.day
|
||||
else:
|
||||
day = None
|
||||
if year is None:
|
||||
year = now.year
|
||||
if month is None:
|
||||
@ -266,12 +270,11 @@ def month_view(request, year=None, month=None, cat=None):
|
||||
if filter.has_category_parameters():
|
||||
return HttpResponseRedirect(filter.get_new_url())
|
||||
|
||||
cmonth = CalendarMonth(year, month, filter)
|
||||
cmonth = CalendarMonth(year, month, filter, day=day)
|
||||
|
||||
context = {
|
||||
"year": year,
|
||||
"month": cmonth.get_month_name(),
|
||||
"calendar": cmonth,
|
||||
"this_month": day is not None,
|
||||
"filter": filter,
|
||||
"category": category,
|
||||
"init_date": now if cmonth.today_in_calendar() else cmonth.firstdate,
|
||||
|
Loading…
x
Reference in New Issue
Block a user