Ejemplo n.º 1
0
def get(pid):
    model = Product.get_model(pid, throw=True)
    desc_imgs = ProductImage.get_by_product_id_with_image(pid)
    if desc_imgs:
        model.desc_imgs = desc_imgs
        model._fields.append('desc_imgs')
    properties = ProductProperty.get_by_product_id(pid)
    if properties:
        model.properties = properties
        model._fields.append('properties')
    model.hide('img_id', 'delete_time', 'category_id', 'category')
    return jsonify(model)
Ejemplo n.º 2
0
def get(pid):
    model = Product.get_model(pid, throw=True)
    product_propertes = ProductProperty.get_by_product_id(model.id)
    product_themes = Product.get_themes_by_id(model.id)
    product_desc_imgs = ProductImage.get_by_product_id_with_image(model.id)
    if product_propertes:
        model.params = product_propertes
        model._fields.append('params')
    if product_themes:
        model.theme_ids = [item.id for item in product_themes]
        model._fields.append('theme_ids')
    if product_desc_imgs:
        model.desc_imgs = product_desc_imgs
        model._fields.append('desc_imgs')
    model.hide('delete_time', 'category')
    return jsonify(model)