diff options
Diffstat (limited to 'feeds.py')
-rw-r--r-- | feeds.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -20,7 +20,7 @@ from django.utils.feedgenerator import SyndicationFeed from icalendar import Calendar, Event -class IcalFeed(SyndicationFeed): +class IcalFeedGenerator(SyndicationFeed): content_type = "text/calendar; charset=utf-8" __ical_names = {"name": "summary", "notes": "description", @@ -32,12 +32,14 @@ class IcalFeed(SyndicationFeed): calendar = Calendar() calendar.add("version", "2.0") - write_events(calendar) + self.write_events(calendar) outfile.write(calendar.to_ical()) def write_events(self, calendar): - for item in items: + print(self.items) + for item in self.items: event = Event() - for key, value in item.items(): - if key in __ical_names: - event.add(__ical_names[key], value) + for key, value in self.__ical_names.items(): + if item.get(key) is not None: + event.add(value, item[key]) + calendar.add_component(event) |