Skip to content

Commit

Permalink
events: Fix last day of web calendar for full-day event
Browse files Browse the repository at this point in the history
In the events model, an event with an end_date but without an end_time is
meant to include the last day. Fullcalendar.io, which is used for the
web calendar, however, always regards the end datetime as exclusive.

Add a day in the case that we have no end_time, so that the web calender
includes the last day in the display.
  • Loading branch information
donald committed Mar 15, 2023
1 parent 002199f commit 4b2bbc4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mpicms/events/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime, date
from datetime import datetime, date, timedelta
from ics import Calendar, Event as ICSEvent

from django.db import models
Expand Down Expand Up @@ -71,10 +71,15 @@ def end(self):
return self.end_date

def get_dict(self, request=None):

datetime_end = self.end
if self.end_date and not self.end_time:
datetime_end += timedelta(days = 1)

return {
'title': self.title,
'start': self.start.isoformat(),
'end': self.end.isoformat() if self.end else None,
'end': datetime_end.isoformat() if self.end else None,
'url': self.get_url(request=request),
}

Expand Down

0 comments on commit 4b2bbc4

Please sign in to comment.