Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(self):
self.attendee = None
self.organizer = None
self.categories = None
self.status = None
self.url = None

def time_left(self, time=None):
"""
Expand Down Expand Up @@ -141,6 +143,8 @@ def copy_to(self, new_start=None, uid=None):
ne.created = self.created
ne.last_modified = self.last_modified
ne.categories = self.categories
ne.status = self.status
ne.url = self.url

return ne

Expand Down Expand Up @@ -227,6 +231,12 @@ def create_event(component, tz=UTC):
encoded_categories.append(encode(category))
event.categories = encoded_categories

if component.get("status"):
event.status = encode(component.get("status"))

if component.get("url"):
event.url = encode(component.get("url"))

return event


Expand Down
41 changes: 41 additions & 0 deletions test/test_data/status_and_url.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:Europe/Berlin
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:Event with Status and URL
SUMMARY:Tentative Event w/ Recurrance to test copy
STATUS:TENTATIVE
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
RRULE:FREQ=WEEKLY;BYDAY=TU
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status and URL
SUMMARY:Confirmed Event
STATUS:CONFIRMED
URL:https://example.com/
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status
SUMMARY:Cancelled Event
STATUS:CANCELLED
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status
SUMMARY:XPARAM Event
STATUS;X-SOMETHING=IGNOREME:CANCELLED
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event without Status
SUMMARY:Event
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
END:VCALENDAR
14 changes: 14 additions & 0 deletions test/test_icalevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,17 @@ def test_transparent(self):

self.assertEqual(e1.transparent, True, "respect transparency")
self.assertEqual(e2.transparent, False, "respect opaqueness")

def test_status_and_url(self):
ical = "test/test_data/status_and_url.ics"
start = date(2018, 10, 30)
end = date(2018, 10, 31)

[ev1, ev2, ev3, ev4, ev5] = icalevents.events(file=ical, start=start, end=end)
self.assertEqual(ev1.status, "TENTATIVE")
self.assertEqual(ev1.url, None)
self.assertEqual(ev2.status, "CONFIRMED")
self.assertEqual(ev2.url, "https://example.com/")
self.assertEqual(ev3.status, "CANCELLED")
self.assertEqual(ev4.status, "CANCELLED")
self.assertEqual(ev5.status, None)