예제 #1
0
파일: shop.py 프로젝트: hnney/aidingcan
def shop_explore():
    city_id = utils.get_currentt_user_group().city_id

    city = City.query.filter_by(id=city_id).first()

    if city:
        shops = Shop.query.filter(Shop.city_id == city_id).all()
        return render_template('/shop/explore.html', shops=shops, city=city, city_id=city_id)
    else:
        return redirect('/')
예제 #2
0
파일: shop.py 프로젝트: hnney/aidingcan
def add():
    """添加店铺页面"""
    if request.method == "GET":
        return render_template('/shop/add.html')
    elif request.method == "POST":
        if utils.get_currentt_user_group_id():
            name = request.form['name']
            tel = request.form['tel']
            address = request.form['address']
            city_id = utils.get_currentt_user_group().city_id

            if not name or not tel or not address or not city_id:
                return redirect("/action=add_shop_fail")

            shop = Shop(name, address, tel, city_id, utils.get_currentt_user_id())
            utils.get_currentt_user_group().shops.append(shop)
            db.session.add(shop)
            db.session.commit()

            return redirect(url_for('shop.edit_food', id=shop.id))
        else:
            return redirect("/")
예제 #3
0
def shop_explore():
    city_id = utils.get_currentt_user_group().city_id

    city = City.query.filter_by(id=city_id).first()

    if city:
        shops = Shop.query.filter(Shop.city_id == city_id).all()
        return render_template('/shop/explore.html',
                               shops=shops,
                               city=city,
                               city_id=city_id)
    else:
        return redirect('/')
예제 #4
0
def add():
    """添加店铺页面"""
    if request.method == "GET":
        return render_template('/shop/add.html')
    elif request.method == "POST":
        if utils.get_currentt_user_group_id():
            name = request.form['name']
            tel = request.form['tel']
            address = request.form['address']
            city_id = utils.get_currentt_user_group().city_id

            if not name or not tel or not address or not city_id:
                return redirect("/action=add_shop_fail")

            shop = Shop(name, address, tel, city_id,
                        utils.get_currentt_user_id())
            utils.get_currentt_user_group().shops.append(shop)
            db.session.add(shop)
            db.session.commit()

            return redirect(url_for('shop.edit_food', id=shop.id))
        else:
            return redirect("/")