cabot/app/cabotapp/calendar.py
2014-01-29 00:18:18 +00:00

25 lines
646 B
Python

from django.conf import settings
from icalendar import Calendar, Event
import requests
def get_calendar_data():
feed_url = settings.CALENDAR_ICAL_URL
resp = requests.get(feed_url)
cal = Calendar.from_ical(resp.content)
return cal
def get_events():
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