Exemplo n.º 1
0
    def on_after_save(request, user):
        user.is_active = False
        user.set_password(request.POST['password'])

        # Email verification
        key = randstr(32)
        while User.objects.filter(verification_key=key).exists():
            key = randstr(32)
        user.verification_key = key

        send_mail_task.delay(
            title=_('Welcome to MootiroMaps'),
            receivers=[user.email],
            message=_('''
Hello, {name}.

Before using our tool, please confirm your e-mail visiting the link below.
{verification_url}

Thanks,
the IT3S team.
''').format(name=user.name, verification_url=request.build_absolute_uri(
                                reverse('user_verification', args=(key,))))
        )
        send_explanations_mail(user)

        user.save()
        redirect_url = reverse('user_check_inbox')
        return {'redirect': redirect_url}
Exemplo n.º 2
0
def send_explanations_mail(user, type='user'):
    if type == 'user':
        tpl = USER_EXPLANATIONS_MAIL_TPL
        title = "[MootiroMaps] Bem-vindo ao MootiroMaps"
    elif type == 'project':
        tpl = PROJ_EXPLANATIONS_MAIL_TPL
        title = "[MootiroMaps] Seu projeto foi criado"
    message = render_to_response(tpl, {'name': user.name}).content

    send_mail_task.delay(
            title=title,
            message=message,
            receivers=[user.email], html=True)