#NEWLINE# @ must_be_valid_project #NEWLINE# @ must_have_permission ( WRITE ) #NEWLINE# @ must_not_be_registration #NEWLINE# def project_new_node( auth , node , **kwargs ) : #NEWLINE# #INDENT# form = NewNodeForm ( request . form ) #NEWLINE# user = auth . user #NEWLINE# if form . validate ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# new_component = new_node ( title = strip_html ( form . title . data ) , user = user , category = form . category . data , parent = node ) #NEWLINE# #UNINDENT# except ValidationValueError as e : #NEWLINE# #INDENT# raise HTTPError ( http . BAD_REQUEST , data = dict ( message_long = e . message ) ) #NEWLINE# #UNINDENT# redirect_url = node . url #NEWLINE# message = 'Your component was created successfully. You can keep working on the project page below, or go to the new <u><a href={component_url}>component</a></u>.' . format ( component_url = new_component . url ) #NEWLINE# if ( form . inherit_contributors . data and node . has_permission ( user , WRITE ) ) : #NEWLINE# #INDENT# for contributor in node . contributors : #NEWLINE# #INDENT# perm = ( CREATOR_PERMISSIONS if ( contributor is user ) else node . get_permissions ( contributor ) ) #NEWLINE# new_component . add_contributor ( contributor , permissions = perm , auth = auth ) #NEWLINE# #UNINDENT# new_component . save ( ) #NEWLINE# redirect_url = ( new_component . url + 'contributors/' ) #NEWLINE# message = 'Your component was created successfully. You can edit the contributor permissions below, work on your <u><a href={component_url}>component</a></u> or return to the <u> <a href="{project_url}">project page</a></u>.' . format ( component_url = new_component . url , project_url = node . url ) #NEWLINE# #UNINDENT# status . push_status_message ( message , kind = 'info' , trust = True ) #NEWLINE# return ( { #NEWLINE# #INDENT# 'status' : 'success' , #NEWLINE# #UNINDENT# } , 201 , None , redirect_url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# status . push_errors_to_status ( form . errors ) #NEWLINE# #UNINDENT# raise HTTPError ( http . BAD_REQUEST , redirect_url = node . url )