Ejemplo n.º 1
0
def get_banner(id):
    banner = Banner.get_banner_by_id(id=id)
    return jsonify(banner)
Ejemplo n.º 2
0
def get_banner(id):
    '''获取「首页轮播图」'''
    id = IDMustBePositiveInt().validate_for_api().id.data
    banner = Banner.get_banner_by_id(id=id)
    # banner.hide('description') # 临时隐藏
    return Success(banner)
Ejemplo n.º 3
0
def delete(bid):
    Banner.remove_model(bid, throw=True)
    return Success(msg='横幅删除成功')
Ejemplo n.º 4
0
def get_one(id):
    '''获取「首页轮播图」'''
    banner = Banner.get_banner_by_id(id=id)
    # banner.hide('description') # 可以隐藏某个字段
    return Success(banner)
Ejemplo n.º 5
0
def hide(bid):
    Banner.hide_model(bid, throw=True)
    return Success(msg='横幅隐藏成功')
Ejemplo n.º 6
0
def show(bid):
    Banner.show_model(bid, throw=True)
    return Success(msg='横幅显示成功')
Ejemplo n.º 7
0
def create():
    form = BannerContent().validate_for_api()
    Banner.add_model(form.data, throw=True)
    return Success(msg='添加横幅成功')
Ejemplo n.º 8
0
def update(bid):
    form = BannerContent().validate_for_api()
    Banner.edit_model(bid, form.data, throw=True)
    return Success(msg='修改横幅成功')
Ejemplo n.º 9
0
def get_all():
    models = Banner.get_all_models(throw=True)
    for model in models:
        model._fields = ['id', 'name']
    return jsonify(models)
Ejemplo n.º 10
0
def get_paginate():
    start, count = paginate()
    q = request.args.get('q', None)
    res = Banner.get_paginate_models(start, count, q, soft=False, throw=True)
    return jsonify(res)
Ejemplo n.º 11
0
def get(bid):
    model = Banner.get_model(bid, throw=True)
    return jsonify(model)
Ejemplo n.º 12
0
def delete_banner(bid):
    """删除id=bid的轮播图"""
    Banner.remove_banner(bid)
    return Success()
Ejemplo n.º 13
0
def update_banner(bid):
    """更新id=bid轮播图的信息"""
    form = UpdateBannerForm().validate_for_api()
    Banner.update_banner(bid, form.data)
    return Success()
Ejemplo n.º 14
0
def create_banner():
    """创建一个轮播图"""
    form = CreateBannerForm().validate_for_api()
    Banner.create_banner(form.data)
    return Success()
Ejemplo n.º 15
0
def get_banner(id):
	id = IDMustBePositiveInt().validate_for_api().id.data
	banner = Banner.get_banner_by_id(id=id)
	# banner.hide('description') # 临时隐藏
	return Success(banner)