#NEWLINE# @ must_be_logged_in #NEWLINE# def project_new_post( auth , **kwargs ) : #NEWLINE# #INDENT# user = auth . user #NEWLINE# data = request . get_json ( ) #NEWLINE# title = strip_html ( data . get ( 'title' ) ) #NEWLINE# title = title . strip ( ) #NEWLINE# category = data . get ( 'category' , 'project' ) #NEWLINE# template = data . get ( 'template' ) #NEWLINE# description = strip_html ( data . get ( 'description' ) ) #NEWLINE# new_project = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if template : #NEWLINE# #INDENT# original_node = Node . load ( template ) #NEWLINE# changes = { #NEWLINE# #INDENT# 'title' : title , #NEWLINE# 'category' : category , #NEWLINE# 'template_node' : original_node , #NEWLINE# #UNINDENT# } #NEWLINE# if description : #NEWLINE# #INDENT# changes [ 'description' ] = description #NEWLINE# #UNINDENT# project = original_node . use_as_template ( auth = auth , changes = { #NEWLINE# #INDENT# template : changes , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# project = new_node ( category , title , user , description ) #NEWLINE# #UNINDENT# except ValidationValueError as e : #NEWLINE# #INDENT# raise HTTPError ( http . BAD_REQUEST , data = dict ( message_long = e . message ) ) #NEWLINE# #UNINDENT# new_project = _view_project ( changes , auth ) #NEWLINE# #UNINDENT# return ( { #NEWLINE# #INDENT# 'projectUrl' : project . url , #NEWLINE# 'newNode' : ( new_project [ 'node' ] if new_project else None ) , #NEWLINE# #UNINDENT# } , http . CREATED )