Beispiel #1
0
def delete():
    goods = GoodsForm().validate().goods.data
    member = Member.query.get_or_404_deleted(g.member.id, msg='找不到指定会员')
    with db.auto_commit():
        ids = [good['id'] for good in goods]
        carts = member.carts.filter(MemberCart.food_id.in_(ids)).all_or_404()
        for item in carts:
            db.session.delete(item)
    return DeleteSuccess()
Beispiel #2
0
def ops(id):
    form = OpsForm().validate()
    food = Food.query.get_or_404(id, msg='找不到指定商品')
    act = form.act.data
    with db.auto_commit():
        if act == 'remove':
            food.remove()
            msg = '删除成功'
        elif act == 'recover':
            food.recover()
            msg = '恢复成功'
        db.session.add(food)
    return DeleteSuccess(msg=msg)
Beispiel #3
0
def category_ops(id):
    form = CategoryOpsForm().validate()
    food_cat = FoodCat.query.get_or_404(id, msg='未找到指定分类')
    act = form.act.data
    with db.auto_commit():
        if act == 'remove':
            food_cat.remove()
            msg = '删除成功'
        elif act == 'recover':
            food_cat.recover()
            msg = '恢复成功'
        db.session.add(food_cat)
    return DeleteSuccess(msg=msg)
Beispiel #4
0
def ops(id):
    form = OpsForm().validate()
    act = form.act.data
    user = User.query.get_or_404(id, msg='对不起,找不到指定用户')
    msg = ''
    with db.auto_commit():
        if act == 'remove':
            user.remove()
            msg = '删除成功'
        if act == 'recover':
            user.recover()
            msg = '恢复成功'
        db.session.add(user)
    return DeleteSuccess(msg=msg)