#NEWLINE# @ must_be_valid_project #NEWLINE# @ must_have_permission ( ADMIN ) #NEWLINE# @ must_not_be_registration #NEWLINE# def component_remove( auth , node , **kwargs ) : #NEWLINE# #INDENT# 'Remove component, and recursively remove its children. If node has a\n    parent, add log and redirect to parent; else redirect to user dashboard.\n\n    ' #NEWLINE# try : #NEWLINE# #INDENT# node . remove_node ( redirect_url ) #NEWLINE# #UNINDENT# except NodeStateError as e : #NEWLINE# #INDENT# raise HTTPError ( http . BAD_REQUEST , data = { #NEWLINE# #INDENT# 'message_short' : 'Error' , #NEWLINE# 'message_long' : ( 'Could not delete component: ' + e . message ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# node . save ( ) #NEWLINE# message = '{} has been successfully deleted.' . format ( node . project_or_component . capitalize ( ) ) #NEWLINE# status . push_status_message ( message , kind = 'success' , trust = False ) #NEWLINE# parent = node . parent_node #NEWLINE# if ( parent and parent . can_view ( auth ) ) : #NEWLINE# #INDENT# redirect_url = node . node__parent [ 0 ] . url #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redirect_url = '/dashboard/' #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'url' : redirect_url , #NEWLINE# #UNINDENT# }