Example #1
0
def posts_new():
    json_data = request.get_json()
    user_id = current_user.id
    author_name = json_data.get('author')
    category = json_data.get('category')
    title = json_data.get('title')
    content = json_data.get('content')

    if not all((author_name, category, title, content)):
        return error('没有提供所有参数')

    post = Post.create_post(user_id=user_id,
                            author_name=author_name,
                            category=category,
                            title=title,
                            content=content)
    return ok(dump_post(post, mode='only_id'))
Example #2
0
def posts_new():
    json_data = request.get_json()
    user_id = current_user.id
    author_name = json_data.get('author')
    category = json_data.get('category')
    title = json_data.get('title')
    content = json_data.get('content')

    if not all((author_name, category, title, content)):
        return error('没有提供所有参数')

    post = Post.create_post(
        user_id=user_id,
        author_name=author_name,
        category=category,
        title=title,
        content=content)
    return ok(dump_post(post, mode='only_id'))