Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @logout_required
- def register(request):
- """ Renders the register template
- GET /register renders the template
- POST /register creates new user
- """
- if request.count.get("/account/register/") > 5:
- Klass = CaptchaRegistrationForm
- else:
- Klass = RegistrationForm
- try:
- if request.method == "POST":
- # handle the registration process
- form = RegistrationForm(request.POST, instance=User())
- form.save()
- # Login newly created user
- user = auth.authenticate(username=request.POST['username'], password=request.POST['password'])
- if user is not None:
- request.messages.add('notice', 'Thanks for registration')
- request.messages.add('warning', 'You have to activate Your account')
- auth.login(request, user)
- # Bind na IP address
- profile = user.get_profile()
- profile.ip = request.META.get('REMOTE_ADDR', '255.255.255.255')
- profile.save()
- # send an activation email
- email.send_activation_email(request)
- # TODO: change this redirect to character creation page
- return redirect_to("account:index")
- # Here seems user was not created
- # TODO: handle this error -> raise500 ?
- return redirect_to("account:index")
- else:
- form = RegistrationForm(instance=User())
- except ValueError:
- tb()
- pass
- return render_to_response('account/register.html', {'form': form}, RequestContext(request))
Add Comment
Please, Sign In to add comment