コード例 #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 Mailchimp 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(first_name, email)
    except _ActiveCampaignError:
        form.add_error('email', 'Email Inválido')
        raise UserCreationException(form)
    lead = _core_facade.register_lead(first_name, email, source)
    _discourse_facade.sync_user(lead)
    _email_marketing_facade.create_or_update_lead(first_name,
                                                  email,
                                                  id=lead.id)

    return lead
コード例 #2
0
def test_lead_creation_user_not_found(resps_user_not_found, grant_role_mock):
    facade.create_or_update_lead('Renzo Nuccitelli',
                                 '*****@*****.**',
                                 'turma',
                                 id=1)
    grant_role_mock.assert_called_once_with('*****@*****.**',
                                            '0000000001', '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 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:
        _email_marketing_facade.create_or_update_lead(first_name,
                                                      email,
                                                      id=user.id)
    except _ActiveCampaignError:
        pass
    return user