#NEWLINE# @ put ( '/s/topics/{topic_id}' ) #NEWLINE# def update_topic_route( request , topic_id ) : #NEWLINE# #INDENT# '\n    Update the topic.\n    - Only the name can be changed.\n    - Only by original author.\n    ' #NEWLINE# db_conn = request [ 'db_conn' ] #NEWLINE# current_user = get_current_user ( request ) #NEWLINE# if ( not current_user ) : #NEWLINE# #INDENT# return abort ( 401 ) #NEWLINE# #UNINDENT# topic = Topic . get ( db_conn , id = topic_id ) #NEWLINE# if ( not topic ) : #NEWLINE# #INDENT# return abort ( 404 ) #NEWLINE# #UNINDENT# if ( topic [ 'user_id' ] != current_user [ 'id' ] ) : #NEWLINE# #INDENT# return abort ( 403 ) #NEWLINE# #UNINDENT# topic_data = request [ 'params' ] [ 'topic' ] #NEWLINE# topic_data = pick ( topic_data , ( 'name' , ) ) #NEWLINE# ( topic , errors ) = topic . update ( db_conn , topic_data ) #NEWLINE# if errors : #NEWLINE# #INDENT# errors = prefix_error_names ( 'topic.' , errors ) #NEWLINE# return ( 400 , { #NEWLINE# #INDENT# 'errors' : errors , #NEWLINE# 'ref' : 'k7ItNedf0I0vXfiIUcDtvHgQ' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return ( 200 , { #NEWLINE# #INDENT# 'topic' : topic . deliver ( ) , #NEWLINE# #UNINDENT# } )