Beispiel #1
0
def registration(request):
    pass_is_correct='true'
    user_exist = 'true'
    form=RegistrationForm()

    if request.method=='POST':
        user=sUser()
        user.username=request.POST.get('username')


        if request.POST.get('confirm')==request.POST.get('password'):
            user.set_password(request.POST.get('password'))
            try:
                user.save()
            except:
                user_exist = 'false'
                return render_to_response ('sprof/registration.html',{'form':form,'user_exist':user_exist}, context_instance=RequestContext(request))

            newuser=authenticate(
                username=user.username,
                password=user.password,
            )
            if user and user.is_active:
                dlogin(request)
                print user.is_anonymous()
                return redirect_to(request,'/profile/')
        pass_is_correct='false'




#    if(request.method=='POST'):
#        post=Post()
#        post.title=request.POST.get('title')
#        post.text=request.POST.get('text')
#        post.author=Author.objects.get(id=request.POST.get('author'))
#        post.save()
#        return redirect_to(request,'/posts/')
#

    return render_to_response('sprof/registration.html',{'form':form,'ok':pass_is_correct}, context_instance=RequestContext(request))
Beispiel #2
0
def login(request):
    pass_is_correct=True
    if request.method=='POST':
        #user=User()
        user=authenticate(
            username=request.POST.get('username'),
            password=request.POST.get('password'),
        )

        if user and user.is_active:
            dlogin(request)
            if not user.get_profile().profile_completed():

                return redirect_to(request,'/profile/')
            else:
                return redirect_to(request,'/')
        pass_is_correct=False


    form=LoginForm()


    return render_to_response('sprof/login.html',{'form':form,'ok':pass_is_correct}, context_instance=RequestContext(request))