Пример #1
0
def delete(task_id):
    st = Query(SmsTask).equal_to('user_id', request.user.get('id')).get(task_id)
    if not st: abort(404)

    st.destroy()
    flash(u'删除成功', 'danger')
    return redirect(url_for('index'))
Пример #2
0
def todo(id):
    if request.method == 'GET':
        try:
            todo = Query(Todo).get(id)
            return jsonify(todo.dump()), 200, AccessControl
        except:
            abort(404)
    elif request.method == 'PUT':
        try:
            todo = Query(Todo).get(id)
            title = request.form.get('title')
            todo.set('title', title)
            todo.save()
            return jsonify(todo.dump()), 200, AccessControl
        except:
            abort(404)
    elif request.method == 'DELETE':
        try:
            todo = Query(Todo).get(id)
            todo.destroy()
            return jsonify({}), 204, AccessControl
        except:
            abort(404)
    elif request.method == 'OPTIONS':
        return 'ok', 200, AccessControl
Пример #3
0
def updateTopic(from_page, to_page):
    t = TiebaTopic()
    count = 0
    err = 0
    for data in t.find_to_page(from_page, to_page):
        try:
            query = Query(Topic).equal_to('pid', data['pid']).first()
            query.destroy()
        except LeanCloudError as e:
            if e.code != 101:
                err += 1
                raise e
        finally:
            Topic(**data).save()
            count += 1
    return count, err
Пример #4
0
def delete_comment(comment_id):
    comment = Query(Comments).get(comment_id)
    if comment is None:
        raise Err('value:notfound', 'comment', 'comment not found.')
    comment.destroy()
    return comment
Пример #5
0
def delete_blog(blog_id):
    blog = Query(Blog).get(blog_id)
    if blog is None:
        raise Err('value:notfound', 'blog', 'blog not found.')
    blog.destroy()
    return blog
Пример #6
0
def delete_comment(comment_id):
    comment = Query(Comments).get(comment_id)
    if comment is None:
        raise Err('value:notfound', 'comment', 'comment not found.')
    comment.destroy()
    return comment
Пример #7
0
def delete_blog(blog_id):
    blog = Query(Blog).get(blog_id)
    if blog is None:
        raise Err('value:notfound', 'blog', 'blog not found.')
    blog.destroy()
    return blog