コード例 #1
0
ファイル: views.py プロジェクト: jidewu/flask_project
def blog_delete():
    if request.method == 'GET':
        login_user_id = g.user.get_id()
        # 权限判断,只能删除自己的 blog todo
        if login_user_id is None:
            return jsonify(result=False)
        blog_id = request.args.get('blog_id', 0, type=int)
        from blog import delete_blog
        result = delete_blog(blog_id)
        if result == 1:
            return jsonify(result=True)
        else:
            return jsonify(result=False)
コード例 #2
0
ファイル: views.py プロジェクト: zhanghe06/flask_project
def blog_delete():
    """
    博客删除
    """
    if request.method == 'GET':
        login_user_id = g.user.get_id()
        # 权限判断,只能删除自己的 blog todo
        if login_user_id is None:
            return jsonify(result=False)
        blog_id = request.args.get('blog_id', 0, type=int)
        from blog import delete_blog
        result = delete_blog(blog_id)
        if result == 1:
            return jsonify(result=True)
        else:
            return jsonify(result=False)
コード例 #3
0
    # Bob then signs in, checks Alice's blog and comment.
    # He commented under Alice's comment and checks it shows up in only the correct locations
    # (For instance, not Alice's comments)
    sign_in(driver, users[0]['email'], users[0]['password'])
    new_comment_content = create_new_comment(driver, blog_id)
    go_to_profile(driver, uid)
    locate_blog(driver, blog_id, False, safe=False)
    locate_comment(driver, comment_content, False, safe=False)
    # Shouldn't find other people's comment inside your post
    assert_comment_not_found(new_comment_content)
    locate_comment(driver, new_comment_content, True, safe=False)
    sign_out(driver)

    # Alice then signs in, deletes her original post
    # Then she checks the post is gone and her comment is gone
    sign_in(driver, users[1]['email'], users[1]['password'])
    delete_blog(driver, blog_id)
    # Make sure comments are deleted
    go_to_profile(driver, uid)
    assert (locate_blog(driver, blog_id, True, safe=True) == None)
    assert_comment_not_found(comment_content)
    sign_out(driver)

    # Bob finally verifies his comment is gone as well
    sign_in(driver, users[0]['email'], users[0]['password'])
    assert_comment_not_found(new_comment_content, True)
    sign_out(driver)

    driver.close()