calendar date is updated + correct today
This commit is contained in:
parent
ff02258d8b
commit
8ff67fe68a
|
@ -2,6 +2,7 @@
|
||||||
Define different Section css_class that can be used by views.Sections;
|
Define different Section css_class that can be used by views.Sections;
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
import datetime # used in calendar
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
|
|
||||||
from django.utils import timezone as tz
|
from django.utils import timezone as tz
|
||||||
|
@ -509,7 +510,7 @@ class Calendar(Section):
|
||||||
import aircox.cms.routes as routes
|
import aircox.cms.routes as routes
|
||||||
context = super().get_context_data(*args, **kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
|
||||||
date = tz.datetime.today()
|
date = datetime.date.today()
|
||||||
if year:
|
if year:
|
||||||
date = date.replace(year = year)
|
date = date.replace(year = year)
|
||||||
if month:
|
if month:
|
||||||
|
@ -520,14 +521,15 @@ class Calendar(Section):
|
||||||
context.update({
|
context.update({
|
||||||
'first_weekday': first,
|
'first_weekday': first,
|
||||||
'days': [
|
'days': [
|
||||||
(day, self.model.reverse(
|
(date + tz.timedelta(days=day), self.model.reverse(
|
||||||
routes.DateRoute, year = date.year, month = date.month,
|
routes.DateRoute, year = date.year, month = date.month,
|
||||||
day = day
|
day = day
|
||||||
)
|
)
|
||||||
) for day in range(1, count+1)
|
) for day in range(0, count)
|
||||||
],
|
],
|
||||||
|
|
||||||
'today': tz.datetime.today(),
|
'today': datetime.date.today(),
|
||||||
|
'this_month': date,
|
||||||
'prev_month': date - tz.timedelta(days=10),
|
'prev_month': date - tz.timedelta(days=10),
|
||||||
'next_month': date + tz.timedelta(days=count),
|
'next_month': date + tz.timedelta(days=count),
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<a href="{% url exp.name key="render" year=prev_month.year month=prev_month.month %}"
|
<a href="{% url exp.name key="render" year=prev_month.year month=prev_month.month %}"
|
||||||
onclick="return Section.load_event(event);"><</a>
|
onclick="return Section.load_event(event);"><</a>
|
||||||
|
|
||||||
<h3>{{ today|date:'F Y' }}</h3>
|
<h3>{{ this_month|date:'F Y' }}</h3>
|
||||||
|
|
||||||
<a href="{% url exp.name key="render" year=next_month.year month=next_month.month %}"
|
<a href="{% url exp.name key="render" year=next_month.year month=next_month.month %}"
|
||||||
onclick="return Section.load_event(event);">></a>
|
onclick="return Section.load_event(event);">></a>
|
||||||
|
@ -19,7 +19,11 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div first_weekday="{{ first_weekday }}"> </div>
|
<div first_weekday="{{ first_weekday }}"> </div>
|
||||||
{% for day, url in days %}
|
{% for day, url in days %}
|
||||||
<a href="{{ url }}" {% if day == today.day %}class="today"{% endif %}>{{ day }}</a>
|
{% if day == today %}
|
||||||
|
<a href="{{ url }}" weekday="{{ day.weekday }}" class="today">{{ day.day }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ url }}" weekday="{{ day.weekday }}">{{ day.day }}</a>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user