예제 #1
0
def register_lead(first_name: str,
                  email: str,
                  source: str = 'unknown') -> _User:
    """
    Create a new user on the system generation a random password.
    An Welcome email is sent to the user informing his password with the link to change it.
    User is also registered on Email Marketing and subscribed to LeadWorkflow and is not registered on system in case
    api call fails

    :param first_name: User's first name
    :param email: User's email
    :param source: source of User traffic
    :return: User
    """
    if not source:
        source = 'unknown'
    form = _core_facade.validate_user(first_name, email, source)
    try:
        _email_marketing_facade.create_or_update_lead.delay(first_name, email)
    except _ActiveCampaignError:
        form.add_error('email', 'Email Inválido')
        raise UserCreationException(form)
    lead = _core_facade.register_lead(first_name, email, source)
    sync_user_on_discourse.delay(lead.id)
    _email_marketing_facade.create_or_update_lead.delay(first_name,
                                                        email,
                                                        id=lead.id)

    return lead
예제 #2
0
def register_lead(first_name: str,
                  email: str,
                  source: str = 'unknown',
                  tags: list = []) -> _User:
    """
    Create a new user on the system generation a random password.
    An Welcome email is sent to the user informing his password with the link to change it.
    User is also registered on Email Marketing and subscribed to LeadWorkflow and is not registered on system in case
    api call fails

    :param first_name: User's first name
    :param email: User's email
    :param source: source of User traffic
    :return: User
    """
    if not source:
        source = 'unknown'
    _core_facade.validate_user(first_name, email, source)
    lead = _core_facade.register_lead(first_name, email, source)
    _email_marketing_facade.create_or_update_lead.delay(first_name,
                                                        email,
                                                        *tags,
                                                        id=lead.id)

    return lead
예제 #3
0
def force_register_lead(first_name: str, email: str, source: str = 'unknown') -> _User:
    """
    Create a new user on the system generation a random password.
    An Welcome email is sent to the user informing his password with the link to change it.
    User is also registered on Email Marketing. But she will be registered even if api call fails
    :param first_name: User's first name
    :param email: User's email
    :param source: source of User traffic
    :return: User
    """
    user = _core_facade.register_lead(first_name, email, source)
    _email_marketing_facade.create_or_update_lead.delay(first_name, email, id=user.id)
    return user
예제 #4
0
def force_register_lead(first_name: str, email: str, source: str = 'unknown') -> _User:
    """
    Create a new user on the system generation a random password.
    An Welcome email is sent to the user informing his password with the link to change it.
    User is also registered on Mailchimp. But she will be registeres even if api call fails
    :param first_name: User's first name
    :param email: User's email
    :param source: source of User traffic
    :return: User
    """
    user = _core_facade.register_lead(first_name, email, source)
    try:
        _mailchimp_facade.create_or_update_lead(first_name, email)
    except _MailChimpError:
        pass
    return user
예제 #5
0
def register_lead(first_name: str, email: str, source: str = 'unknown') -> _User:
    """
    Create a new user on the system generation a random password.
    An Welcome email is sent to the user informing his password with the link to change it.
    User is also registered on Mailchimp and subscribed to LeadWorkflow and is not registered on system in case api call
    fails

    Check force_register_lead if Maichimp validation is not mandatory
    :param first_name: User's first name
    :param email: User's email
    :param source: source of User traffic
    :return: User
    """
    if not source:
        source = 'unknown'
    form = _core_facade.validate_user(first_name, email, source)
    try:
        _mailchimp_facade.create_or_update_lead(first_name, email)
    except _MailChimpError:
        form.add_error('email', 'Email Inválido')
        raise UserCreationException(form)
    return _core_facade.register_lead(first_name, email, source)