Ejemplo n.º 1
0
def api_delete_comments(id, request):
    check_admin(request)
    c = yield from Comment.find(id)
    if c is None:
        raise APIResourceNotFoundError('Comment')
    yield from c.remove()
    return dict(id=id)
Ejemplo n.º 2
0
def apiCommentDelete(id, request):
    checkAdmin(request)
    c = yield from Comment.find(id)
    if c is None:
        raise APIResourceNotFoundError('评论不存在')
    yield from c.remove()
    return dict(id=id)
Ejemplo n.º 3
0
def find_model(model, id):
    if model == 'blog':
        blog = yield from Blog.find(id)
        return blog
    if model == 'user':
        user = yield from User.find(id)
        return user
    if model == 'comment':
        comment = yield from Comment.find(id)
        return comment
Ejemplo n.º 4
0
def api_delete_comments(id, request):
    #校验当前用户权限:
    check_admin(request)
    #数据库Comment表中查询指定评论信息:
    c = yield from Comment.find(id)
    #查询无结果则抛出异常:
    if c is None:
        raise APIResourceNotFoundError('Comment')
    #将Comment信息从数据库删除:
    yield from c.remove()
    return dict(id=id)