From a8ce3075e929763e73d5279d9649b5e50993c98b Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 14 Apr 2016 13:17:38 +0200 Subject: * calendar entries are updated based on entry modification date, not calendar update date --- bin/fetch_cals.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fetch_cals.py b/bin/fetch_cals.py index 59dc0b7..30e7abc 100644 --- a/bin/fetch_cals.py +++ b/bin/fetch_cals.py @@ -19,6 +19,7 @@ def update_event_data(db_event, ical_event): db_event.begin_date.time() == datetime.time.min) if db_event.all_day: db_event.end_date = db_event.end_date - datetime.timedelta(days=1) + db_event.last_modified = get_last_modification_time(ical_event) return db_event @@ -56,20 +57,25 @@ def fetch_calendar(calendar, session): if u not in cal_events.keys()] mod_events = [{'ics': cal_events[u], 'db': e} for u, e in db_events.iteritems() if u in cal_events.keys()] + changes_present = False for event in mod_events: modified_date = get_last_modification_time(event['ics']) if not modified_date or \ - not calendar.last_updated or \ - modified_date > calendar.last_updated.replace(tzinfo=pytz.UTC): + not event['db'].last_modified or \ + modified_date > event['db'].last_modified.replace(tzinfo=pytz.UTC): print 'Updating event %s' % event['db'].uid update_event(event['db'], event['ics']) + changes_present = True for event in new_events: print 'Adding event %s' % event.uid add_event(event, calendar, session) + changes_present = True for event in old_events: print 'Removing event %s' % event.uid remove_event(event, session) - calendar.last_updated = datetime.datetime.now() + changes_present = True + if changes_present: + calendar.last_updated = datetime.datetime.now() def main(): -- cgit v1.2.3