#NEWLINE# @ fix_recaptcha_remote_ip #NEWLINE# @ render_to ( 'accounts/register.html' ) #NEWLINE# def register( request ) : #NEWLINE# #INDENT# if request . user . is_authenticated ( ) : #NEWLINE# #INDENT# return redirect ( reverse ( 'home' ) ) #NEWLINE# #UNINDENT# _request = None #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# _request = request . POST . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _request = request . GET . copy ( ) #NEWLINE# #UNINDENT# next_uri = _request . get ( 'next' , get_config ( 'FIRST_LOGIN_REDIRECT_URL' , reverse ( 'first_steps' ) ) ) #NEWLINE# if ( next_uri == get_config ( 'LOGIN_URL' , reverse ( 'login' ) ) ) : #NEWLINE# #INDENT# next_uri = get_config ( 'FIRST_LOGIN_REDIRECT_URL' , reverse ( 'first_steps' ) ) #NEWLINE# #UNINDENT# register_form = RegisterForm ( ) #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# register_form = RegisterForm ( request . POST ) #NEWLINE# if register_form . is_valid ( ) : #NEWLINE# #INDENT# register_form . save ( ) #NEWLINE# username = register_form . cleaned_data [ 'username' ] #NEWLINE# password = register_form . cleaned_data [ 'password1' ] #NEWLINE# user = authenticate ( username = username , password = password ) #NEWLINE# if ( user is not None ) : #NEWLINE# #INDENT# auth_login ( request , user ) #NEWLINE# messages . success ( request , 'Welcome aboard, {0}.' . format ( username ) ) #NEWLINE# badges . possibly_award_badge ( 'logged_in' , user = user ) #NEWLINE# #UNINDENT# return redirect ( next_uri ) #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# 'register_form' : register_form , #NEWLINE# 'next' : next_uri , #NEWLINE# #UNINDENT# }