From fb71d1be2fc64792fde55f98e3a8e2e3931f9e53 Mon Sep 17 00:00:00 2001 From: ppiro <68238658+ppiro@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:17:43 +0200 Subject: [PATCH] refactor compute start and end day in advance to improve readability --- cal/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cal/views.py b/cal/views.py index d0734a2..00269ef 100644 --- a/cal/views.py +++ b/cal/views.py @@ -43,14 +43,17 @@ def formatday(self, day, weekday): .exclude(startDate__gt=next_day) .exclude(endDate__lt=this_day, endDate__isnull=False) .exclude(endDate__isnull=True, startDate__lt=this_day)): + start_day = event.startDate.date() + end_day = (event.endDate or event.startDate).date() + body.append('
  • ') if self.admin: body.append(u'✏️' % event.get_absolute_url()) body.append('' % event.wikiPage) - if (this_day == event.startDate.date()): + if this_day == start_day: body.append('' + event.startDate.strftime('%H:%M') + '') body.append('' + esc(event.name) + '') - if (event.endDate) and (event.startDate.date() != event.endDate.date()) and (this_day == event.endDate.date()): + if start_day != end_day and this_day == end_day: body.append(' ' + event.endDate.strftime('%H:%M') + '') body.append('' + esc(event.location) + '') body.append('')