Exemplo n.º 1
0
def getThemeDetial(id):
    theme = Theme.query.get(id)
    isNotFind('/theme', theme)
    products = theme.productInTheme.all()
    backProducts = []
    for pt in products:
        backProduct = pt.backProduct
        bp = {
            'id': backProduct.id,
            'name': backProduct.name,
            'price': str(backProduct.price),
            'stock': backProduct.stock,
            'category_id': backProduct.category_id,
            'main_img_url':
            current_app.config.get('IMG_PREFIX') + backProduct.main_img_url,
            'come_from': backProduct.come_from
        }
        backProducts.append(bp)
    themeDetail = {
        'id': theme.id,
        'name': theme.name,
        'description': theme.description,
        'topic_img': theme.topic_img.totalUrl(),
        'head_img': theme.head_img.totalUrl(),
        'productInTheme': backProducts
    }

    return themeDetail
Exemplo n.º 2
0
def getTheme():
    ids = request.values.get('ids')
    isNotFind('/theme?ids=id1,id2,id3', ids)
    ids = ids.split(',')
    isAllInt('/theme', ids)
    results = themeModel.getThemeList(ids)
    return jsonify(results)
Exemplo n.º 3
0
def getOrderDetail(id):
    isInt('/order/<id>',id)
    id=int(id)
    order=Order.query.get(id)
    isNotFind('/order/<id>',order)
    order=order.to_json()
    return jsonify(order)
Exemplo n.º 4
0
def getThemeList(ls):
    results = []
    for l in ls:
        result = Theme.query.get(l)
        isNotFind('/theme', result)
        result = result.to_json()
        results.append(result)
    return results
Exemplo n.º 5
0
def getAllCategory():
    category = Category.query.all()
    isNotFind('/category/all', category)
    return [cg.to_json() for cg in category]
Exemplo n.º 6
0
def getBannerByid(id):
        banner=Banner.query.get(id)
        isNotFind('/banner/<id>',banner)
        banner_items=banner.banner_items
        return [banner_item.to_json() for banner_item in banner_items]