Exemplo n.º 1
0
def category_json(name):
    productItems = []
    categories = access.getCategories()
    categories = access.getCategoryByName(name)
    for category in categories:
        category.Items = access.getProductCategory(category.category_id)
        for product in category.Items:
            product.category_name = access.getCategory(product.category_id)
    return jsonify(Category=[i.serialize for i in categories])
Exemplo n.º 2
0
def categories(name=""):
    """Returns the last 5 products for each category"""
    """Should have two panels - LHS lists categories, and initial RHS view lists
     most recent products across all categories plus price and category
    category and/or product are clickable, to return either the category page or
     the product page.
    Users can edit, create, or delete only the items that they created
    """
    productItems = []
    categories = access.getCategories()
    if name != "":
        categories = access.getCategoryByName(name)
        productItems = access.getProductCategoryByName(name)
    else:
        for category in categories:
            productItems += access.getProductCategory(category.category_id)
    for product in productItems:
        product.category = access.getCategory(product.category_id)
        if product.product_image:
            product.product_url = "uploads/" + product.product_image
    for category in categories:
        category.count = access.countItemsByCategory(category.category_name)
    return render_template("products.html", categories=categories, products=productItems)