#NEWLINE# def process_form( request , form_definition , extra_context = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , disable_redirection = False ) : #NEWLINE# #INDENT# context = extra_context #NEWLINE# success_message = ( form_definition . success_message or _ ( 'Thank you, the data was submitted successfully.' ) ) #NEWLINE# error_message = ( form_definition . error_message or _ ( 'The data could not be submitted, please try again.' ) ) #NEWLINE# form_error = False #NEWLINE# form_success = False #NEWLINE# is_submit = False #NEWLINE# if ( ( request . method == 'POST' ) and request . POST . get ( form_definition . submit_flag_name ) ) : #NEWLINE# #INDENT# form = DesignedForm ( form_definition , None , request . POST , request . FILES ) #NEWLINE# is_submit = True #NEWLINE# #UNINDENT# if ( ( request . method == 'GET' ) and request . GET . get ( form_definition . submit_flag_name ) ) : #NEWLINE# #INDENT# form = DesignedForm ( form_definition , None , request . GET ) #NEWLINE# is_submit = True #NEWLINE# #UNINDENT# if is_submit : #NEWLINE# #INDENT# designedform_submit . send ( sender = process_form , context = context , form_definition = form_definition , request = request ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# files = handle_uploaded_files ( form_definition , form ) #NEWLINE# messages . success ( request , success_message ) #NEWLINE# form_success = True #NEWLINE# designedform_success . send ( sender = process_form , context = context , form_definition = logs , request = request ) #NEWLINE# if form_definition . log_data : #NEWLINE# #INDENT# form_definition . log ( form , request . user ) #NEWLINE# #UNINDENT# if form_definition . mail_to : #NEWLINE# #INDENT# form_definition . send_mail ( form , files ) #NEWLINE# #UNINDENT# if ( form_definition . success_redirect and ( not disable_redirection ) ) : #NEWLINE# #INDENT# return HttpResponseRedirect ( ( form_definition . action or '?' ) ) #NEWLINE# #UNINDENT# if form_definition . success_clear : #NEWLINE# #INDENT# form = DesignedForm ( form_definition ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form_error = True #NEWLINE# designedform_error . send ( sender = process_form , context = context , form_definition = form_definition , request = request ) #NEWLINE# messages . error ( request , error_message ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if form_definition . allow_get_initial : #NEWLINE# #INDENT# form = DesignedForm ( form_definition , initial_data = request . GET ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# form = DesignedForm ( form_definition ) #NEWLINE# #UNINDENT# designedform_render . send ( sender = process_form , context = context , form_definition = form_definition , request = request ) #NEWLINE# #UNINDENT# context . update ( { #NEWLINE# #INDENT# 'form_error' : form_error , #NEWLINE# 'form_success' : form_success , #NEWLINE# 'form' : form , #NEWLINE# 'form_definition' : form_definition , #NEWLINE# #UNINDENT# } ) #NEWLINE# context . update ( csrf ( request ) ) #NEWLINE# if form_definition . display_logged : #NEWLINE# #INDENT# logs = form_definition . logs . all ( ) . order_by ( 'created' ) #NEWLINE# context . update ( { #NEWLINE# #INDENT# 'logs' : logs , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return context