summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/fetch_cals.py12
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():