def patch(self, model_id, topic_id):
"""
Edit the topic topic_id in model model_id changing some additional information (e.g. topic_label)
:param model_id:
:param topic_id:
:return:
"""
parser = reqparse.RequestParser(bundle_errors=True)
parser.add_argument('label', default=None, required=False, type=str,
help='The human readable label of the topic.')
parser.add_argument('description', default=None, required=False, type=str,
help='The human readable description of the topic.')
args = parser.parse_args()
if args['label'] is not None or args['description'] is not None:
topic = db_utils.update_topic(model_id, int(topic_id), args['label'], args['description'])
if topic is None:
return api_utils.prepare_error_response(500, 'Error during the update, check the provided topic id.')
else:
return api_utils.prepare_success_response(200, 'Topic updated.', data=marshal(topic, api_utils.topic_fields))
else:
return api_utils.prepare_error_response(500, 'Provide the label or the description to set.')
评论列表
文章目录