from django.db.models.signals import post_save,pre_delete from django.dispatch import receiver from eventplanner.models import Event, EventParticipation from eventplanner_gcal.models import createGCalEvent, updateGCalEvent, deleteGCalEvent @receiver( post_save,sender= Event) def event_post_save_handler(event, **kwargs): created = kwargs['created'] if created: createGCalEvent( event ).execute() else: updateGCalEvent( event ).execute() @receiver( pre_delete,sender= Event) def event_pre_delete_handler(event, **kwargs): deleteGCalEvent( event ).execute() @receiver( post_save, sender=EventParticipation ) def participation_post_save_handler(participation, **kwargs): updateGCalEvent( participation.event ).execute()