Commit d813903b authored by Lars Kruse's avatar Lars Kruse

Calendar Export: handle events with missing "until_time" attribute

It is possible to specify events without an end.
These events currently trigger an exception during a calendar export.
parent 69bd17f0
......@@ -260,11 +260,14 @@ class GroupCalendarExportMember(memberships.AuthenticatedMemberMixin,
def test_unusual_event_export(self):
""" verify that incomplete and unusual events can be exported """
# "until_time" is the only optional event attribute
self.create_group_event(title='Missing End Time', missing_keys={'until_time'})
# "all_day" is not enabled by default
self.create_group_event(title='All Day Event', all_day=True)
calendar_url = self.get_calendar_export_url(False)
data = self.client.get(calendar_url).content.decode('utf8')
self.assertIn('BEGIN:VCALENDAR', data)
self.assertIn('Missing End Time', data)
self.assertIn('All Day Event', data)
......
......@@ -138,8 +138,12 @@ class BaseCalendarFeed(ICalFeed):
return item.content.first().time.astimezone(tz)
def item_end_datetime(self, item):
tz = django.utils.timezone.get_default_timezone()
return item.content.first().until_time.astimezone(tz)
end_time = item.content.first().until_time
if end_time is None:
return None
else:
tz = django.utils.timezone.get_default_timezone()
return end_time.astimezone(tz)
class GroupCalendarFeed(BaseCalendarFeed, features.groups.views.Mixin):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment