[FIX] website_sale: filter controller and shop/?category=37 --> shop/category/37

bzr revid: chm@openerp.com-20131121130529-1zs3ioih5156ceit
This commit is contained in:
Christophe Matthieu 2013-11-21 14:05:29 +01:00
parent 31f64313c0
commit 07819834bb
2 changed files with 16 additions and 11 deletions

View File

@ -289,10 +289,10 @@ class Ecommerce(http.Controller):
filter[index.index(cat_id)].append( cat[2] )
post.pop(key)
return request.redirect("/shop/?filter=%s%s%s%s" % (
return request.redirect("/shop/?filter=%s%s%s" % (
simplejson.dumps(filter),
post.get("search") and "&search=%s" % post.get("search") or "",
post.get("category") and "&category=%s" % post.get("category") or ""
post.get("search") and ("&search=%s" % post.get("search")) or "",
post.get("category") and ("&category=%s" % post.get("category")) or ""
))
def attributes_to_ids(self, attributes):
@ -308,7 +308,12 @@ class Ecommerce(http.Controller):
att = obj.read(request.cr, request.uid, att_ids, ["product_id"], context=request.context)
return [r["product_id"][0] for r in att]
@website.route(['/shop/', '/shop/page/<int:page>/'], type='http', auth="public", multilang=True)
@website.route([
'/shop/',
'/shop/page/<int:page>/',
'/shop/category/<int:category>/',
'/shop/category/<int:category>/page/<int:page>/'
], type='http', auth="public", multilang=True)
def category(self, category=0, filter="", page=0, **post):
# TDE-NOTE: shouldn't we do somethign about product_template without variants ???
# TDE-NOTE: is there a reason to call a method category when the route is
@ -332,8 +337,8 @@ class Ecommerce(http.Controller):
('product_variant_ids.public_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))]
if category:
cat_id = int(category)
domain = [('product_variant_ids.public_categ_id.id', 'child_of', cat_id)] + domain
category_id = int(category)
domain = [('product_variant_ids.public_categ_id.id', 'child_of', category_id)] + domain
if filter:
filter = simplejson.loads(filter)

View File

@ -25,7 +25,7 @@
<template id="categories_recursive" name="Category list">
<li t-att-class="str(category.id) == search.get('category') and 'active' or ''">
<a t-att-class="category.id not in categ[1] and 'unpublish' or ''" t-href="/shop/?category=#{ category.id }" t-field="category.name" t-keep-query="search,facettes"></a>
<a t-att-class="category.id not in categ[1] and 'unpublish' or ''" t-href="/shop/category/#{ category.id }/" t-field="category.name"></a>
<ul t-if="category.child_id" class="nav nav-pills nav-stacked nav-hierarchy">
<t t-foreach="category.child_id" t-as="category">
<t t-if="category.id in categ[1] or editable">
@ -49,7 +49,7 @@
<div class="ribbon"><span contentEditable="true">Promo</span></div>
</div>
<div class="oe_product_description">
<a t-href="/shop/product/#{ product.id }/" t-keep-query="category,search,facettes">
<a t-href="/shop/product/#{ product.id }/" t-keep-query="category,search,filter">
<b t-field="product.name"/>
</a>
</div>
@ -69,7 +69,7 @@
</b>
</div>
<div class="oe_product_image text-center">
<a t-href="/shop/product/#{ product.id }/" t-keep-query="category,search,facettes">
<a t-href="/shop/product/#{ product.id }/" t-keep-query="category,search,filter">
<span t-field="product.image" t-field-options='{"widget": "image"}'/>
</a>
</div>
@ -245,7 +245,7 @@
<div class="col-sm-5">
<ol class="breadcrumb">
<li><a href="/shop">Products</a></li>
<li t-if="search.get('category')"><a t-href="/shop/" t-keep-query="category,search,facettes"><span t-field="category.name"/></a></li>
<li t-if="search.get('category')"><a t-href="/shop/" t-keep-query="category,search,filter"><span t-field="category.name"/></a></li>
<li class="active"><span t-field="product.name"></span></li>
</ol>
</div><div class="col-sm-3">
@ -509,7 +509,7 @@
<template id="products_attributes" inherit_option_id="website_sale.products" name="Product Filters and Attributes">
<xpath expr="//div[@id='products_grid_before']" position="inside">
<form t-action="/shop/filter/" method="post" t-keep-query="category,search,add_filter">
<form t-action="/shop/filter/" method="post" t-keep-query="category,search">
<ul class="nav nav-pills nav-stacked mt16">
<t t-set="attribute_ids" t-value="Ecommerce.get_attribute_ids()"/>
<t t-foreach="attribute_ids" t-as="attribute_id">