diff options
author | emkael <emkael@tlen.pl> | 2016-04-14 13:17:38 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-04-14 13:17:38 +0200 |
commit | a8ce3075e929763e73d5279d9649b5e50993c98b (patch) | |
tree | 6896da67e4c2344a3e7faac03ef16de5122215a5 /bin | |
parent | 60342c7d0e70f569f12dbf5def2343ed5d010511 (diff) |
* calendar entries are updated based on entry modification date, not calendar update date
Diffstat (limited to 'bin')
-rw-r--r-- | bin/fetch_cals.py | 12 |
1 files changed, 9 insertions, 3 deletions
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(): |