Ejemplo n.º 1
0
def product(request):
    all_product = Product.available_list()
    all_hide_product = Product.not_available_list()

    available_product_without_properties_count = 0
    for pr in all_product:
        if  not len(pr.properties_):
            available_product_without_properties_count += 1


    unavailable_product_without_properties_count = 0
    for pr in all_hide_product:
        if not len(pr.properties_):
            unavailable_product_without_properties_count += 1

    brand_all_available_product = Product.available_list().filter(Product.brand != None)
    logging.warning(brand_all_available_product.count())
    brand_all_not_available_product = Product.not_available_list().filter(Product.brand != None)

    no_brand_all_available_product_count = Product.available_list().filter(Product.brand == None).count()
    no_brand_all_not_available_product_count = Product.not_available_list().filter(Product.brand == None).count()

    available_brand = {}
    for product_ in brand_all_available_product:
        if not product_.brand in available_brand:
            count = Product.available_list().filter(Product.brand == product_.brand).count()
            available_brand[product_.brand] = count

    not_available_brand = {}
    for product_ in brand_all_not_available_product:
        if not product_.brand in not_available_brand:
            count = Product.not_available_list().filter(Product.brand == product_.brand).count()
            not_available_brand[product_.brand] = count

    categories = Category.query(Category.parent_category == None).order(Category.title)
    properties = ProductProperty.query().order(ProductProperty.title)
    brands = Brand.query().order(Brand.title)

    available_uncategories = all_product
    available_uncategories = available_uncategories.filter(Product.category == None)
    unavailable_uncategories = all_hide_product
    unavailable_uncategories = unavailable_uncategories.filter(Product.category == None)
    return render_to_response('shop/admin/product.html',
        locals()
    )
Ejemplo n.º 2
0
def get_brands(request):
    brands = [brand.to_json() for brand in Brand.query()]
    return render_json_response(brands)
Ejemplo n.º 3
0
def brands_json(request):
    brands = [brand.to_json() for brand in Brand.query().order(Brand.title)]
    return render_json_response(brands)