Fix years with 52 weeks

This commit is contained in:
Raphael Michel
2020-10-06 12:48:50 +02:00
parent b4778b5845
commit d7459b3b83
2 changed files with 5 additions and 2 deletions

View File

@@ -467,7 +467,7 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
context['days'] = days_for_template(ebd, week)
context['weeks'] = [
(date.fromisocalendar(self.year, i + 1, 1), date.fromisocalendar(self.year, i + 1, 7))
for i in range(53)
for i in range(53 if date(self.year, 12, 31)[0] == self.year else 52)
]
context['years'] = range(now().year - 2, now().year + 3)
context['week_format'] = get_format('WEEK_FORMAT')

View File

@@ -522,7 +522,10 @@ class WeekCalendarView(OrganizerViewMixin, EventListMixin, TemplateView):
ebd = self._events_by_day(before, after)
ctx['days'] = days_for_template(ebd, week)
ctx['weeks'] = [(date.fromisocalendar(self.year, i + 1, 1), date.fromisocalendar(self.year, i + 1, 7)) for i in range(53)]
ctx['weeks'] = [
(date.fromisocalendar(self.year, i + 1, 1), date.fromisocalendar(self.year, i + 1, 7))
for i in range(53 if date(self.year, 12, 31)[0] == self.year else 52)
]
ctx['years'] = range(now().year - 2, now().year + 3)
ctx['week_format'] = get_format('WEEK_FORMAT')
if ctx['week_format'] == 'WEEK_FORMAT':