+def modify_recurring(ex_acct,gcal_acct,gcal_tz,
+ events,master,gcal_id="primary"):
+ if master.modified_occurrences is not None:
+ for mod in master.modified_occurrences:
+ instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
+ mod.original_start,gcal_id)
+ if instance is None: #give up after first failure
+ return
+ mod_event = get_ex_event_by_itemid(ex_acct.calendar,mod.item_id)
+ gevent = build_gcal_event_from_ex(mod_event,gcal_tz)
+ gevent = gcal_acct.events().update(calendarId=gcal_id,
+ eventId=instance.get('id'),
+ body=gevent,
+ sendUpdates="none").execute()
+ mod_event.gcal_link = gevent.get("id")
+ mod_event.save(update_fields=["gcal_link"])
+ if master.deleted_occurrences is not None:
+ for d in master.deleted_occurrences:
+ instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
+ d.start,gcal_id)
+ if instance is None: #give up after any failure
+ return
+ if instance["status"] != "cancelled":
+ instance["status"]="cancelled"
+ gcal_acct.events().update(calendarId=gcal_id,
+ eventId=instance.get('id'),
+ body=instance,
+ sendUpdates="none").execute()
+