def api_update_blog(blog_id):
check_admin()
i = ctx.request.input(name='', summary='', content='')
name = i.name.strip()
summary = i.summary.strip()
content = i.content.strip()
if not name:
raise APIValueError('name', 'name cannot be empty.')
if not summary:
raise APIValueError('summary', 'summary cannot be empty.')
if not content:
raise APIValueError('content', 'content cannot be empty.')
blog = Blog.get(blog_id)
if blog is None:
raise APIResourceNotFoundError('Blog')
blog.name = name
blog.summary = summary
blog.content = content
blog.update()
return blog
评论列表
文章目录