#NEWLINE# @ c3bottles . route ( '/report' , methods = ( 'GET' , 'POST' ) ) #NEWLINE# @ c3bottles . route ( '/<int:number>' ) #NEWLINE# def report( number = None ) : #NEWLINE# #INDENT# if state : #NEWLINE# #INDENT# dp = DropPoint . get ( number ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dp = DropPoint . get ( request . values . get ( 'number' ) ) #NEWLINE# #UNINDENT# if ( ( not dp ) or dp . removed ) : #NEWLINE# #INDENT# return render_template ( 'error.html' , heading = 'Error!' , text = 'Drop point not found.' ) #NEWLINE# #UNINDENT# state = request . values . get ( 'state' ) #NEWLINE# if state : #NEWLINE# #INDENT# if ( g . no_anonymous_reporting and g . user . is_anonymous ) : #NEWLINE# #INDENT# abort ( 401 ) #NEWLINE# #UNINDENT# from model.report import Report #NEWLINE# try : #NEWLINE# #INDENT# Report ( dp = dp , state = state ) #NEWLINE# #UNINDENT# except ValueError as e : #NEWLINE# #INDENT# return render_template ( 'error.html' , text = 'Errors occurred while processing your report:' , errors = [ v for d in e . args for v in d . values ( ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# db . session . commit ( ) #NEWLINE# return render_template ( 'success.html' , heading = 'Thank you!' , text = 'Your report has been received successfully.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return render_template ( 'report.html' , dp = dp )