(sender, instance, *args, **kwargs)
Creates a repeater object corresponding to the type of trigger (form or case)
Creates a repeater object corresponding to the type of trigger (form or case)
Creates a repeater object corresponding to the type of trigger ( form or case )
def zapier_subscription_pre_save(sender, instance, *args, **kwargs):
    """
    Creates a repeater object corresponding to the type of trigger (form or case)
    """
    if instance.pk:
        return

    if instance.event_name == EventTypes.NEW_FORM:
        repeater = FormRepeater(
            domain=instance.domain,
            url=instance.url,
            format='form_json',
            include_app_id_param=False,
            white_listed_form_xmlns=[instance.form_xmlns]
        )

    elif instance.event_name in CASE_TYPE_REPEATER_CLASS_MAP:
        repeater = CASE_TYPE_REPEATER_CLASS_MAP[instance.event_name](
            domain=instance.domain,
            url=instance.url,
            format='case_json',
            white_listed_case_types=[instance.case_type],
        )
    else:
        raise ImmediateHttpResponse(
            HttpBadRequest('The passed event type is not valid.')
        )

    repeater.save()
    instance.repeater_id = repeater.get_id
def zapier_subscription_pre_save ( sender , instance , * args , * * kwargs ) : if instance . pk : return if instance . event_name == EventTypes . NEW_FORM : repeater = FormRepeater ( domain = instance . domain , url = instance . url , format = 'form_json' , include_app_id_param = False , white_listed_form_xmlns = [ instance . form_xmlns ] ) elif instance . event_name in CASE_TYPE_REPEATER_CLASS_MAP : repeater = CASE_TYPE_REPEATER_CLASS_MAP [ instance . event_name ] ( domain = instance . domain , url = instance . url , format = 'case_json' , white_listed_case_types = [ instance . case_type ] , ) else : raise ImmediateHttpResponse ( HttpBadRequest ( 'The passed event type is not valid.' ) ) repeater . save ( ) instance . repeater_id = repeater . get_id