コード例 #1
0
def send_activation_code(request):
    """
    Resends tangleon.com account activation code to the user
    """
    send_activation_error = None
    email = request.GET.get('email', None)
    if email:
        try:
            user = User.generate_activation_code(email)
            msg_text = get_template('app/email/activation.html').render(
                Context({
                    'domain': get_current_site(request).domain,
                    'user': user
                }))
            msg = EmailMessage('tangleon.com account activation', msg_text,
                               'TangleOn <*****@*****.**>', [user.email])
            msg.content_subtype = "html"
            msg.send()

        except TangleOnError as e:
            send_activation_error = e.message
    else:
        send_activation_error = 'Invalid link for resend activation code'

    return render_response(request, 'app/send_activation.html',
                           {'send_activation_error': send_activation_error})
コード例 #2
0
ファイル: views.py プロジェクト: PKUbuntu/tangleon
def signup(request):
    """
    Creates a new user in database and send activation to his email address
    """    
    error = None
    successful_signup = None
    if request.method == 'POST':
        form = SignUp(request.POST)
        if form.is_valid():
            try:
                data = form.cleaned_data
                user = User.sign_up(data['username'], data['email'], data['password'])
                domain = get_current_site(request).domain
                msg_text = get_template('app/email/activation.html').render(Context({ 'domain': domain, 'user': user }))
                msg = EmailMessage('tangleon.com account activation', msg_text, 'TangleOn <*****@*****.**>', [user.email])
                msg.content_subtype = "html"
                msg.send()
                                
                msg_text = get_template('app/email/welcome.html').render(Context({ 'domain': domain, 'user': user }))
                msg = EmailMessage('tangleon.com Welcome! Lets get started!!', msg_text, 'TangleOn <*****@*****.**>', [user.email])
                msg.content_subtype = "html"
                msg.send()
                successful_signup = True                
            except TangleOnError as e:            
                error = e.message
    else:
        form = SignUp()
    
    if request.is_ajax():
        return render_response(request, 'app/webparts/signup.html', {'signup_form': form, 'error': error, 'successful_signup': successful_signup })
    
    return render_response(request, 'app/signup.html', {'signup_form': form, 'error': error, 'successful_signup': successful_signup })
コード例 #3
0
def signup(request):
    """
    Creates a new user in database and send activation to his email address
    """
    error = None
    successful_signup = None
    if request.method == 'POST':
        form = SignUp(request.POST)
        if form.is_valid():
            try:
                data = form.cleaned_data
                user = User.sign_up(data['username'], data['email'],
                                    data['password'])
                domain = get_current_site(request).domain
                msg_text = get_template('app/email/activation.html').render(
                    Context({
                        'domain': domain,
                        'user': user
                    }))
                msg = EmailMessage('tangleon.com account activation', msg_text,
                                   'TangleOn <*****@*****.**>',
                                   [user.email])
                msg.content_subtype = "html"
                msg.send()

                msg_text = get_template('app/email/welcome.html').render(
                    Context({
                        'domain': domain,
                        'user': user
                    }))
                msg = EmailMessage('tangleon.com Welcome! Lets get started!!',
                                   msg_text, 'TangleOn <*****@*****.**>',
                                   [user.email])
                msg.content_subtype = "html"
                msg.send()
                successful_signup = True
            except TangleOnError as e:
                error = e.message
    else:
        form = SignUp()

    if request.is_ajax():
        return render_response(
            request, 'app/webparts/signup.html', {
                'signup_form': form,
                'error': error,
                'successful_signup': successful_signup
            })

    return render_response(
        request, 'app/signup.html', {
            'signup_form': form,
            'error': error,
            'successful_signup': successful_signup
        })
コード例 #4
0
ファイル: views.py プロジェクト: PKUbuntu/tangleon
def send_activation_code(request):
    """
    Resends tangleon.com account activation code to the user
    """
    send_activation_error = None
    email = request.GET.get('email', None)
    if email:
        try:
            user = User.generate_activation_code(email)
            msg_text = get_template('app/email/activation.html').render(Context({ 'domain': get_current_site(request).domain, 'user': user }))
            msg = EmailMessage('tangleon.com account activation', msg_text, 'TangleOn <*****@*****.**>', [user.email])
            msg.content_subtype = "html"
            msg.send()
                
        except TangleOnError as e:
            send_activation_error = e.message
    else:
        send_activation_error = 'Invalid link for resend activation code'
    
    return render_response(request, 'app/send_activation.html', { 'send_activation_error': send_activation_error })
コード例 #5
0
ファイル: views.py プロジェクト: PKUbuntu/tangleon
def activation(request):
    """
    Activates the new user
    """
    activation_error = None
    if request.method == 'GET':
        email = request.GET.get('email', None)
        activation_code = request.GET.get('activation_code', None)
        if email and activation_code:
            try:
                user = User.activate(email, activation_code)
                login_user(request, user)
                return HttpResponseRedirect(reverse('app_index'))
            except TangleOnError as error:
                activation_error = error.message
        else:
            activation_error = 'TangleOn account activation url is not correct; please try to copy and paste complete url from email.'
    else:
        activation_error = 'Invalid activation request.'       
    
    return render_response(request, 'app/activation.html', {'activation_error': activation_error})
コード例 #6
0
def activation(request):
    """
    Activates the new user
    """
    activation_error = None
    if request.method == 'GET':
        email = request.GET.get('email', None)
        activation_code = request.GET.get('activation_code', None)
        if email and activation_code:
            try:
                user = User.activate(email, activation_code)
                login_user(request, user)
                return HttpResponseRedirect(reverse('app_index'))
            except TangleOnError as error:
                activation_error = error.message
        else:
            activation_error = 'TangleOn account activation url is not correct; please try to copy and paste complete url from email.'
    else:
        activation_error = 'Invalid activation request.'

    return render_response(request, 'app/activation.html',
                           {'activation_error': activation_error})