From 492da9dc027a42384b286593c61e6951089bc013 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 5 Sep 2017 21:40:08 +0200 Subject: Correction de détails --- feeds.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/feeds.py b/feeds.py index f3ccaf3..4b42c47 100644 --- a/feeds.py +++ b/feeds.py @@ -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) -- cgit v1.2.1