#NEWLINE# def request_password_reset( request , template_name = 'emailauth/request_password.html' ) : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = PasswordResetRequestForm ( request . POST ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# email = form . cleaned_data [ 'email' ] #NEWLINE# user_email = UserEmail . objects . get ( email = email ) #NEWLINE# user_email . make_new_key ( ) #NEWLINE# user_email . save ( ) #NEWLINE# current_site = Site . objects . get_current ( ) #NEWLINE# subject = render_to_string ( 'emailauth/request_password_email_subject.txt' , { #NEWLINE# #INDENT# 'site' : current_site , #NEWLINE# #UNINDENT# } ) #NEWLINE# subject = '' . join ( subject . splitlines ( ) ) #NEWLINE# message = render_to_string ( 'emailauth/request_password_email.txt' , { #NEWLINE# #INDENT# 'reset_code' : user_email . verification_key , #NEWLINE# 'expiration_days' : email_verification_days ( ) , #NEWLINE# 'site' : current_site , #NEWLINE# 'first_name' : user_email . user . first_name , #NEWLINE# #UNINDENT# } ) #NEWLINE# django . core . mail . send_mail ( subject , message , settings . DEFAULT_FROM_EMAIL , [ email ] ) #NEWLINE# return HttpResponseRedirect ( reverse ( 'emailauth_request_password_reset_continue' , args = [ quote_plus ( email ) ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = PasswordResetRequestForm ( ) #NEWLINE# #UNINDENT# context = RequestContext ( request ) #NEWLINE# return render_to_response ( template_name , { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# 'expiration_days' : email_verification_days ( ) , #NEWLINE# #UNINDENT# } , context_instance = context )