From a8e6ca89fde4bd70158e7b1617f71462ca507796 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Mon, 15 Sep 2014 11:12:04 +0200 Subject: [PATCH] Dirty catch all in GCAL handling --- eventplanner_gcal/signals.py | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/eventplanner_gcal/signals.py b/eventplanner_gcal/signals.py index ea0b225..11d880e 100644 --- a/eventplanner_gcal/signals.py +++ b/eventplanner_gcal/signals.py @@ -19,25 +19,36 @@ logger = logging.getLogger( __name__ ) def event_post_save_handler( **kwargs): event = kwargs['instance'] created = kwargs['created'] - if created: - logger.info("Creating Gcal event") - response = createGCalEvent( getServiceObject(), event ).execute() - onGcalEventCreated( None, response, None ) - else: - logger.info( "Updating Gcal event") - updateGCalEvent( getServiceObject(),event ).execute() + try: + if created: + logger.info("Creating Gcal event") + response = createGCalEvent( getServiceObject(), event ).execute() + onGcalEventCreated( None, response, None ) + else: + logger.info( "Updating Gcal event") + updateGCalEvent( getServiceObject(),event ).execute() + except: + logger.error( "Error updating Gcal event") + @receiver( pre_delete,sender= Event) def event_pre_delete_handler( **kwargs): - event = kwargs['instance'] - logger.info ("Deleting GCAL event") - deleteGCalEvent( getServiceObject(), event ).execute() + try: + event = kwargs['instance'] + logger.info ("Deleting GCAL event") + deleteGCalEvent( getServiceObject(), event ).execute() + except: + logger.error("Error deleting GCAL event") @receiver( post_save, sender=EventParticipation ) def participation_post_save_handler( **kwargs): - participation = kwargs['instance'] - logger.info("Participation post save -> update gcal") - updateGCalEvent( getServiceObject(), participation.event ).execute() + try: + participation = kwargs['instance'] + logger.info("Participation post save -> update gcal") + updateGCalEvent( getServiceObject(), participation.event ).execute() + except: + logger.error("Error deleting GCAL event") +