#NEWLINE# def activate_account( request , token ) : #NEWLINE# #INDENT# '\n    Allow a user to activate their account with the token sent to them\n    by email.\n    ' #NEWLINE# user = get_object_or_404 ( User , auth_token = token ) #NEWLINE# if ( not user . auth_token_is_used ) : #NEWLINE# #INDENT# if request . POST : #NEWLINE# #INDENT# form = ActivateAccountForm ( request . POST , user = user ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# user . full_name = form . cleaned_data [ 'full_name' ] #NEWLINE# user . password = make_password ( form . cleaned_data [ 'password' ] ) #NEWLINE# user . is_active = True #NEWLINE# user . activated_datetime = now ( ) #NEWLINE# user . auth_token_is_used = True #NEWLINE# user . save ( ) #NEWLINE# email = user . email #NEWLINE# password = request . POST [ 'password' ] #NEWLINE# user = authenticate ( username = email , password = password ) #NEWLINE# login ( request , form ) #NEWLINE# request . session [ 'show_welcome' ] = True #NEWLINE# return redirect ( reverse ( 'dashboard' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = ActivateAccountForm ( user = user ) #NEWLINE# #UNINDENT# context = { #NEWLINE# #INDENT# 'user' : user , #NEWLINE# 'form' : form , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# token_is_used = True #NEWLINE# context = { #NEWLINE# #INDENT# 'token_is_used' : token_is_used , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return render ( request , 'accounts/activate_account.html' , context )