예제 #1
0
def pre_mailinglist_save(instance, **kwargs):
    sync_service = GSuiteSyncService()
    group = sync_service.mailinglist_to_group(instance)
    old_list = MailingList.objects.filter(pk=instance.pk).first()
    try:
        if old_list is None:
            sync_service.create_group(group)
        else:
            sync_service.update_group(old_list.name, group)
    except HttpError:
        # Cannot do direct create or update, do full sync for list
        sync_service.sync_mailinglists([group])
예제 #2
0
def pre_mailinglist_save(instance, **kwargs):
    if settings.GSUITE_ADMIN_CREDENTIALS == {}:
        logger.warning(
            "Cannot sync mailinglists because there are no GSuite credentials available"
        )
        return
    sync_service = GSuiteSyncService()
    group = sync_service.mailinglist_to_group(instance)
    old_list = MailingList.objects.filter(pk=instance.pk).first()
    try:
        if old_list is None:
            sync_service.create_group(group)
        else:
            sync_service.update_group(old_list.name, group)
    except HttpError:
        # Cannot do direct create or update, do full sync for list
        sync_service.sync_mailinglists([group])