kopia lustrzana https://github.com/jazzband/icalevents
commit
c368ad8ec4
|
@ -50,6 +50,8 @@ class Event:
|
|||
self.attendee = None
|
||||
self.organizer = None
|
||||
self.categories = None
|
||||
self.status = None
|
||||
self.url = None
|
||||
|
||||
def time_left(self, time=None):
|
||||
"""
|
||||
|
@ -141,6 +143,8 @@ class Event:
|
|||
ne.created = self.created
|
||||
ne.last_modified = self.last_modified
|
||||
ne.categories = self.categories
|
||||
ne.status = self.status
|
||||
ne.url = self.url
|
||||
|
||||
return ne
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
|
@ -436,3 +436,17 @@ class ICalEventsTests(unittest.TestCase):
|
|||
|
||||
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)
|
||||
|
|
Ładowanie…
Reference in New Issue