cabot/app/cabotapp/calendar.py

25 lines
646 B
Python
Raw Normal View History

2014-01-05 17:24:04 +00:00
from django.conf import settings
from icalendar import Calendar, Event
import requests
def get_calendar_data():
2014-01-28 00:53:34 +00:00
feed_url = settings.CALENDAR_ICAL_URL
resp = requests.get(feed_url)
cal = Calendar.from_ical(resp.content)
return cal
2014-01-05 17:24:04 +00:00
def get_events():
2014-01-28 00:53:34 +00:00
events = []
for component in get_calendar_data().walk():
if component.name == 'VEVENT':
events.append({
'start': component.decoded('dtstart'),
'end': component.decoded('dtend'),
'summary': component.decoded('summary'),
'uid': component.decoded('uid'),
})
return events