api.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:myweblog 作者: YuiJL 项目源码 文件源码
def api_delete_subcomment(comment_id, own_id):

    '''
    delete a subcomment from a certain comment
    '''

    if not g.__user__.get('admin'):
        return make_response('Permission denied.', 403)
    db.comments.update_one(
        {'_id': ObjectId(comment_id)},
        {
            '$pull': {'subcontent': {'_id': own_id}}
        })
    if not db.comments.find_one({'_id': ObjectId(comment_id)}).get('subcontent'):
        db.comments.update_one(
            {'_id': ObjectId(comment_id)},
            {
                '$set': {'subcomment': False}
            })
    blog_id = db.comments.find_one({'_id': ObjectId(comment_id)}).get('blog_id')
    return redirect(url_for('api.api_get_blog_comments', blog_id=blog_id))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号