コード例 #1
0
ファイル: product_views.py プロジェクト: gmist/1businka
def filter_value(request):
    is_available = bool(request.values.get('available'))
    value_key = request.values.get('value')
    products = []
    if value_key:
        value_ = ProductPropertyValue.get_by_id(int(value_key))
        if is_available:
            products = value_.get_available_products()
        else:
            products = value_.get_not_available_products()
    else:
        if is_available:
            products_tmp = Product.available_list()
            products = []
            for prop in products_tmp:
                if not prop.properties_:
                    products.append(prop)
        else:
            products_tmp = Product.not_available_list()
            products = []
            for prop in products_tmp:
                if not prop.properties_:
                    products.append(prop)

    return render_to_response('shop/admin/product_filter.html', {
        'products':products,
        'available':is_available
    })
コード例 #2
0
ファイル: product_views.py プロジェクト: gmist/1businka
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()
    )