Skip to content

Commit

Permalink
calendar: Fix all day events
Browse files Browse the repository at this point in the history
All time events are stored without a time in the database. The method
event.start returns a date instead of a datetime in that case. If so,
set the ics event to all_day.
  • Loading branch information
donald committed Nov 14, 2019
1 parent fc46f27 commit 6411d79
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mpicms/events/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import datetime
from datetime import datetime, date
from ics import Calendar, Event as ICSEvent

from django.db import models
Expand Down Expand Up @@ -138,6 +138,8 @@ def ics(self):
url=event.full_url,
location=event.room
)
if type(event.start) is date:
e.make_all_day()
c.events.add(e)
return '\n'.join(c)

Expand Down

0 comments on commit 6411d79

Please sign in to comment.