예제 #1
0
 def post(self, request):
     form = RegistrationForm(request.POST)
     if form.is_valid():
         username = form.cleaned_data['username']
         password = form.cleaned_data['password']
         email = form.cleaned_data['email']
         User.objects.create_user(username=username,
                                  password=password,
                                  email=email)
         return HttpResponseRedirect('/')
예제 #2
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)

        if form.is_valid():
            new_user = form.save()
            new_user.is_active = False
            new_user.save()

            confirmation_code = sha.new(new_user.username).hexdigest()
            profile = UserProfile(user=new_user, confirmation_code=confirmation_code[0:9])
            profile.save()

            send_registration_confirmation(new_user)

            return render_to_response("account/registration_complete.html")
    else:
        form = RegistrationForm()
    return render_to_response("account/register.html", {'form': form}, context_instance=RequestContext(request))
예제 #3
0
def user_register(request):
	context_dict={}
	if request.method=='POST':
		print request.POST
		registration_form = RegistrationForm(request.POST)
		if registration_form.is_valid():
			registerd_user = registration_form.save()
			print registerd_user.password
			registerd_user.set_password(registerd_user.password)
			registerd_user.save()
			context_dict['msg']="successfully registered"
			user_login(request)
			return HttpResponseRedirect('/survey/')

		else:
			print registration_form.errors
			context_dict['msg']=registration_form.errors
			return render(request,'survey/register.html',context_dict)
	elif request.method=='GET': 
		return render(request,'survey/register.html',context_dict)
예제 #4
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)

        if form.is_valid():
            new_user = form.save()
            new_user.is_active = False
            new_user.save()

            confirmation_code = sha.new(new_user.username).hexdigest()
            profile = UserProfile(user=new_user, confirmation_code=confirmation_code[0:9])
            profile.save()

            send_registration_confirmation(new_user)

            return render_to_response("account/registration_complete.html")
    else:
        form = RegistrationForm()
    return render_to_response("account/register.html", {'form': form}, context_instance=RequestContext(request))
예제 #5
0
 def get(self, request):
     form = RegistrationForm()
     return render(request, "add_elements_surfey.html",
                   {"form": form})  # todo zmienić template