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('/')
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("/")