#NEWLINE# @ tasks . route ( '/create' , methods = [ 'GET' , 'POST' ] ) #NEWLINE# @ must_be_able_to ( 'create_task' ) #NEWLINE# def create( ) : #NEWLINE# #INDENT# stage_id = request . args . get ( 'stage_id' , None ) #NEWLINE# stage = ( get_or_404 ( Stage , id = stage_id ) if stage_id else None ) #NEWLINE# form = TaskForm ( stages = [ stage ] ) #NEWLINE# if form . validate_on_submit ( ) : #NEWLINE# #INDENT# task = Task ( ) #NEWLINE# form . populate_obj ( task ) #NEWLINE# db . session . add ( task ) #NEWLINE# db . session . commit ( ) #NEWLINE# notify ( 'Task "{0}" has been created.' . format ( stage_id . name ) , category = 'success' , action = 'create_task' ) #NEWLINE# return redirect ( url_for ( 'tasks.view' , id = task . id ) ) #NEWLINE# #UNINDENT# return render_template ( 'tasks/create.html' , form = form , stage_id = stage_id )