Esempio n. 1
0
def account_create(request):
    
    print 'Account create request'
    
    if request.method == 'POST':
        form = UserAccountCreateForm(request.POST)
        if form.is_valid():
            print u'Account Form is valid'
            
            user_account = form.save()
            
            username = form.cleaned_data.get('email')
            password = form.cleaned_data.get('password')
            
            if auto_login_user(request, username, password):
                return redirect('account', user_account.slug)
            else:
                view_error(request, u'There was an error in creating your account')
        else:
            print u'Account Form is invalid'
    else:
        form = UserAccountCreateForm()
    
    
    context = {'path':request.path, 'form':form}
    t = loader.get_template('account-create.html')
    c = RequestContext(request, context)
    return HttpResponse(t.render(c))
Esempio n. 2
0
def account_create(request):
    from core.views import view_error

    print "Account create request"

    if request.method == "POST":
        form = UserAccountCreateForm(request.POST)
        if form.is_valid():
            print u"Account Form is valid"

            user_account = form.save()

            username = form.cleaned_data.get("email")
            password = form.cleaned_data.get("password")

            if auto_login_user(request, username, password):
                return redirect("account", user_account.slug)
            else:
                view_error(request, u"There was an error in creating your account")
        else:
            print u"Account Form is invalid"
    else:
        form = UserAccountCreateForm()

    context = {"path": request.path, "form": form}
    t = loader.get_template("account-create.html")
    c = RequestContext(request, context)
    return HttpResponse(t.render(c))
Esempio n. 3
0
def mobileCreateAccount(request):
    from core.views import view_error

    print "Account create request"

    print request.POST

    if request.method == "POST":
        form = PostAccountCreateForm(request.POST)
        if form.is_valid():
            print u"Account Form is valid"

            user_account = form.save()

            username = form.cleaned_data.get("username")
            password = form.cleaned_data.get("password")

            if auto_login_user(request, username, password):

                response = EncodeJSON()
                response.add("user", user_account.to_dict())
                return HttpResponse(response.encode())

            else:
                view_error(request, u"There was an error in creating your account")
        else:
            print u"Account Form is invalid"
            response = EncodeJSON()
            response.add("errors", form.errors)
            return HttpResponse(response.encode())
    else:
        form = PostAccountCreateForm()

    #    context = {'path':request.path, 'form':form}
    #    t = loader.get_template('account-create.html')
    #    c = RequestContext(request, context)
    #    return HttpResponse(t.render(c))
    return HttpResponse()
Esempio n. 4
0
def mobile_account_create(request):
    print 'Account create request'
    
    print request.POST
    
    if request.method == 'POST':
        form = BetAccountCreateForm(request.POST)
        if form.is_valid():
            print u'Account Form is valid'
            
            user_account = form.save()
            
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            
            if auto_login_user(request, username, password):
                
                response = EncodeJSON()
                response.add('user', user_account.to_dict())
                return HttpResponse(response.encode()) 
                
            else:
                view_error(request, u'There was an error in creating your account')
        else:
            print u'Account Form is invalid'
            response = EncodeJSON()
            response.add('errors', form.errors)
            return HttpResponse(response.encode()) 
    else:
        form = BetAccountCreateForm()
    
    
#    context = {'path':request.path, 'form':form}
#    t = loader.get_template('account-create.html')
#    c = RequestContext(request, context)
#    return HttpResponse(t.render(c))
    return HttpResponse()