コード例 #1
0
ファイル: brand.py プロジェクト: yyt030/quanduoduo
def brand_modify():
    """修改品牌"""
    shop = {}
    url = request.values.get('current_url')
    print url
    brand_id = int(request.args.get("id", 0))
    act = request.args.get('act', '')
    if not brand_id:
        return render_template('account/error.html', error='页面不存在!')
    if act == 'audits':
        brand = Brand.query.filter(Brand.id == brand_id).first()
        brand.status = int(request.args.get('status', 1))
        if brand.status == 0:
            tip = '禁用成功'
        else:
            tip = '启用成功'
        db.session.add(brand)
        db.session.commit()
        return render_template('account/ok.html', tip=tip, url='manage?do=normal')
    form = BrandSetting()
    brand = Brand.query.get_or_404(brand_id)
    form.brand.data = brand.name
    form.industry_1.data = brand.industry_1
    form.industry_2.data = brand.industry_2
    form.intro.data = brand.intro
    form.image.data = brand.image
    form.thumb.data = brand.thumb
    if form.is_submitted():
        print request.form
        name = form.brand.data
        if name == "test":
            return render_template('account/error.html', error='您输入的品牌已存在!')
        else:
            return render_template('account/ok.html', tip='添加品牌成功,请添加一个门店!', url=url)
    return render_template('brand/setting.html', shop=shop, form=form)
コード例 #2
0
ファイル: brand.py プロジェクト: yyt030/quanduoduo
def brand_add():
    """添加品牌"""
    shop = {}
    form = BrandSetting()
    if form.is_submitted():
        print request.form
        exist = Brand.query.filter(Brand.name == form.brand.data).first()
        if exist:
            return render_template('account/error.html', error='您输入的品牌已存在!')
        else:
            brand = Brand(name=form.brand.data, industry_1=form.industry_1.data.decode('utf-8'),
                          industry_2=form.industry_2.data.decode('utf-8'), intro=form.intro.data, image=form.image.data,
                          thumb=form.thumb.data)
            db.session.add(brand)
            db.session.commit()
            session['brand'] = brand.id
            url = request.referrer
            return render_template('account/ok.html', tip='添加品牌成功,请添加一个门店!', url=url)
    return render_template('brand/setting.html', shop=shop, form=form)