[FIX] website_membership, website_customer: keep search, country and assocations when jumping from each other of these filters + count fix between partners displayed and group by country count + fix country orders in website_customer

bzr revid: dle@openerp.com-20140130205713-09cbldm9r9pm6r1i
This commit is contained in:
Denis Ledoux 2014-01-30 21:57:13 +01:00
parent fc979b9a7a
commit 320b840341
3 changed files with 26 additions and 13 deletions

View File

@ -40,10 +40,6 @@ class WebsiteCustomer(http.Controller):
groupby="country_id", orderby="country_id", context=request.context)
country_count = partner_obj.search(
cr, openerp.SUPERUSER_ID, domain, count=True, context=request.context)
countries.insert(0, {
'country_id_count': country_count,
'country_id': (0, _("All Countries"))
})
if country_id:
domain += [('country_id', '=', country_id)]
@ -55,6 +51,11 @@ class WebsiteCustomer(http.Controller):
})
countries.sort(key=lambda d: d['country_id'][1])
countries.insert(0, {
'country_id_count': country_count,
'country_id': (0, _("All Countries"))
})
# search customers to display
partner_ids = partner_obj.search(cr, openerp.SUPERUSER_ID, domain, context=request.context)
google_map_partner_ids = ",".join([str(p) for p in partner_ids])

View File

@ -32,12 +32,14 @@ class WebsiteMembership(http.Controller):
def members(self, membership_id=None, country_name=None, country_id=0, page=0, **post):
cr, uid, context = request.cr, request.uid, request.context
product_obj = request.registry['product.product']
country_obj = request.registry['res.country']
membership_line_obj = request.registry['membership.membership_line']
partner_obj = request.registry['res.partner']
post_name = post.get('name', '')
current_country = None
# base domain for groupby / searches
base_line_domain = [('state', 'in', ['free', 'paid'])]
base_line_domain = [("partner.website_published", "=", True),('state', 'in', ['free', 'paid'])]
if membership_id:
base_line_domain.append(('membership_id', '=', membership_id))
membership = product_obj.browse(cr, uid, membership_id, context=context)
@ -53,16 +55,24 @@ class WebsiteMembership(http.Controller):
cr, uid, [('member_lines', 'in', membership_line_ids), ("website_published", "=", True)], ["id", "country_id"],
groupby="country_id", orderby="country_id", context=request.context)
countries_total = sum(country_dict['country_id_count'] for country_dict in countries)
line_domain = list(base_line_domain)
if country_id:
line_domain.append(('partner.country_id', '=', country_id))
current_country = country_obj.read(cr, uid, country_id, ['id', 'name'], context)
if not any(x['country_id'][0] == country_id for x in countries):
countries.append({
'country_id_count': 0,
'country_id': (country_id, current_country["name"])
})
countries.sort(key=lambda d: d['country_id'][1])
countries.insert(0, {
'country_id_count': countries_total,
'country_id': (0, _("All Countries"))
})
# displayed membership lines
line_domain = list(base_line_domain)
if country_id:
line_domain.append(('partner.country_id', '=', country_id))
membership_line_ids = membership_line_obj.search(cr, uid, line_domain, context=context)
membership_lines = membership_line_obj.browse(cr, uid, membership_line_ids, context=context)
membership_lines.sort(key=lambda x: x.membership_id.website_sequence)
@ -86,6 +96,8 @@ class WebsiteMembership(http.Controller):
'memberships': memberships,
'membership': membership,
'countries': countries,
'current_country': current_country and [current_country['id'], current_country['name']] or None,
'current_country_id': current_country and current_country['id'] or 0,
'google_map_partner_ids': google_map_partner_ids,
'pager': pager,
'post': post,

View File

@ -34,7 +34,7 @@
<li t-att-class="'' if membership else 'active'"><a href="/members/">All</a></li>
<t t-foreach="memberships" t-as="membership_id">
<li t-att-class="membership and membership_id.id == membership.id and 'active' or ''">
<a t-attf-href="/members/association/#{ membership_id.id }"><t t-esc="membership_id.name"/></a>
<a t-attf-href="/members/association/#{ membership_id.id }/#{current_country and 'country/%s/' % slug(current_country) or ''}#{ search }"><t t-esc="membership_id.name"/></a>
</li>
</t>
</ul>
@ -44,7 +44,7 @@
<t t-call="website.pager">
<t t-set="classname">pull-left</t>
</t>
<form action="/members/" method="get" class="navbar-search pull-right pagination form-inline">
<form action="" method="get" class="navbar-search pull-right pagination form-inline">
<div class="form-group">
<input type="text" name="name" class="search-query col-md-2 mt4 form-control" placeholder="Search" t-att-value="post.get('name', '')"/>
</div>
@ -86,9 +86,9 @@
<ul class="nav nav-pills nav-stacked mt16">
<li class="nav-header"><h3>Location</h3></li>
<t t-foreach="countries">
<li t-if="country_id" t-att-class="post.get('country_id', '0') == str(country_id and country_id[0]) and 'active' or ''">
<li t-if="country_id" t-att-class="country_id[0] == current_country_id and 'active' or ''">
<a t-attf-href="/members/#{ membership and 'association/%s/' % membership.id or '' }#{ country_id[0] and 'country/%s/' % slug(country_id) or '' }#{ search }"><t t-esc="country_id[1]"/>
<span class="badge pull-right"><t t-esc="country_id_count or ''"/></span>
<span class="badge pull-right"><t t-esc="country_id_count or '0'"/></span>
</a>
</li>
</t>