Ejemplo n.º 1
0
def promote_client(user: _User, source: str) -> None:
    """
    Promote a user to Client role and change it's role on Mailchimp. Will not fail in case API call fails.
    Email welcome email is sent to user
    :param source: source of traffic
    :param user:
    :return:
    """
    _core_facade.promote_to_client(user, source)
    try:
        _mailchimp_facade.create_or_update_client(user.first_name, user.email)
    except _MailChimpError:
        pass
    email_msg = render_to_string(
        'payments/pytools_email.txt',
        {
            'user': user,
            'ty_url': build_absolute_uri(reverse('payments:pytools_thanks'))
        }
    )
    _send_mail(
        'Inscrição no curso Pytools realizada! Confira o link com detalhes.',
        email_msg,
        _settings.DEFAULT_FROM_EMAIL,
        [user.email]
    )
Ejemplo n.º 2
0
def force_register_client(first_name: str, email: str, source: str = 'unknown') -> _User:
    """
    Create a new user on the system generation a random password or update existing one based on email.
    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 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_client(first_name, email, source)
    try:
        _mailchimp_facade.create_or_update_client(first_name, email)
    except _MailChimpError:
        pass
    return user
Ejemplo n.º 3
0
def promote_client(user: _User, email_msg: str) -> None:
    """
    Promote a user to Client role and change it's role on Mailchimp. Will not fail in case API call fails.
    Email welcome email is sent to user
    :param email_msg:
    :param user:
    :return:
    """
    _core_facade.promote_to_client(user)
    try:
        _mailchimp_facade.create_or_update_client(user.first_name, user.email)
    except _MailChimpError:
        pass
    _send_mail(
        'Inscrição no curso Pytools realizada! Confira o link com detalhes.',
        email_msg, _settings.DEFAULT_FROM_EMAIL, [user.email])
Ejemplo n.º 4
0
def _promote_client(user):
    remove_role(user, 'lead')
    assign_role(user, 'client')
    mailchimp_facade.create_or_update_client(user.first_name, user.email)