예제 #1
0
def to_meal_list():
    """菜品列表"""
    package_id = request.args.get('package_id')
    brand_id = request.args.get('brand_id')
    # user_id = request.args.get('user_id')
    dish = get_session_dish()
    package = None
    if package_id:
        temp = str(package_id)
        if temp != 'None':
            package = Package.get_package_by_id(package_id)
            #dish = PackageServiceView.get_dish_by_brand_id(package)
            if dish is None:
                dish_sort, dish = PackageServiceView.get_dish_sort_by_package(
                    package_id)
            dish_sort = DishSort.get_dish_sort_by_brand(brand_id, package_id)
    if package:
        set_session_value('yes', None)
        return render_template('reception/food_list.html',
                               dish_sort=dish_sort,
                               package=package,
                               package_id=package_id,
                               brand_id=brand_id)
    else:
        dish_sort = DishSort.get_dish_sort_by_brand_id(brand_id)
        if dish is None:
            dish = Dish.get_dish_by_brand(brand_id)
            temp = []
            for d in dish:
                try:
                    d.number = 0
                except:
                    d['number'] = 0
                d_pic = flatten(d)
                temp.append(d_pic)
            set_session_dish(temp)
        set_session_value('yes', 'yes')
        return render_template('reception/food_list.html',
                               dish_sort=dish_sort,
                               package='',
                               package_id=package_id,
                               brand_id=brand_id)
예제 #2
0
def to_meal_list():
    """菜品列表"""
    package_id = request.args.get('package_id')
    brand_id = request.args.get('brand_id')
   # user_id = request.args.get('user_id')
    dish = get_session_dish()
    package = None
    if package_id:
        temp = str(package_id)
        if temp != 'None':
            package = Package.get_package_by_id(package_id)
            #dish = PackageServiceView.get_dish_by_brand_id(package)
            if dish is None:
                dish_sort, dish = PackageServiceView.get_dish_sort_by_package(package_id)
            dish_sort = DishSort.get_dish_sort_by_brand(brand_id,package_id)
    if package:
        set_session_value('yes', None)
        return render_template('reception/food_list.html',
                               dish_sort = dish_sort,
                               package = package,
                               package_id=package_id,
                               brand_id=brand_id)
    else:
        dish_sort = DishSort.get_dish_sort_by_brand_id(brand_id)
        if dish is None:
            dish = Dish.get_dish_by_brand(brand_id)
            temp = []
            for d in dish:
                try:
                    d.number = 0
                except:
                    d['number'] = 0
                d_pic = flatten(d)
                temp.append(d_pic)
            set_session_dish(temp)
        set_session_value('yes', 'yes')
        return render_template('reception/food_list.html',
                               dish_sort =  dish_sort,
                               package='',
                               package_id=package_id,
                               brand_id=brand_id)
 def get_dish_by_brand_id(package):
     '''根据分类获取菜品'''
     if package:
         dish = Dish.get_dish_by_package(package)
         return dish
     return None