[WIP] website_contract: reference view

bzr revid: chm@openerp.com-20130823133604-ujkiu67hrjtj4qtg
This commit is contained in:
Christophe Matthieu 2013-08-23 15:36:04 +02:00
parent 651e511ed9
commit 3602641e1d
6 changed files with 119 additions and 27 deletions

View File

@ -6,24 +6,47 @@ from openerp.addons.web.http import request
class website_contract(http.Controller):
@http.route(['/references/'], type='http', auth="public")
def blog(self, **post):
@http.route(['/references/', '/references/page/<int:page>/'], type='http', auth="public")
def references(self, page=0, **post):
website = request.registry['website']
partner_obj = request.registry['res.partner']
account_obj = request.registry['account.analytic.account']
domain = []
if post.get('search'):
domain += ['|',
('name', 'ilike', "%%%s%%" % post.get("search")),
('website_description', 'ilike', "%%%s%%" % post.get("search"))]
# public partner profile
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('website_testimonial', "!=", False), ('website_published', '=', True)])
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, domain + [('website_published', '=', True)])
if request.uid != website.get_public_user().id:
contract_ids = account_obj.search(request.cr, openerp.SUPERUSER_ID, [(1, "=", 1)])
contract_project_ids = [contract.partner_id.id
for contract in account_obj.browse(request.cr, openerp.SUPERUSER_ID, contract_ids) if contract.partner_id]
# search for check access rules
partner_ids += partner_obj.search(request.cr, request.uid, ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)])
partner_ids += partner_obj.search(request.cr, request.uid, domain + ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)])
partner_ids = list(set(partner_ids))
step = 20
pager = website.pager(url="/references/", total=len(partner_ids), page=page, step=step, scope=7, url_args=post)
partner_ids = partner_obj.search(request.cr, request.uid, [('id', 'in', partner_ids)], limit=step, offset=pager['offset'])
values = website.get_rendering_context({
'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids)
'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids),
'pager': pager,
'search': post.get("search"),
})
return website.render("website_contract.index", values)
@http.route(['/references/<int:ref_id>/'], type='http', auth="public")
def references_ref(self, ref_id=0, **post):
website = request.registry['website']
partner_obj = request.registry['res.partner']
values = website.get_rendering_context({
'partner_id': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, ref_id, context={'show_address': True}),
})
return website.render("website_contract.details", values)

View File

@ -13,31 +13,99 @@
<!-- Page -->
<template id="index" name="Projects">
<template id="layout" name="References Layout">
<t t-call="website.layout">
<t t-set="title">References</t>
<div class="container">
<h1>Testimonial</h1>
<div class="thumbnails grid grid-align-top">
<div t-foreach="partner_ids" t-as="partner" class="span6">
<div class="media thumbnail">
<a class="pull-left" href="#">
<img class="media-object" t-att-src="partner.img('image_small')"/>
</a>
<div class="media-body">
<t t-call="website.publish"><t t-set="object" t-value="partner"/></t>
<h5 class="media-heading" t-field="partner.name"/>
<pre t-field="partner.website_testimonial"/>
<small t-field="partner.country_id"/>
<small t-field="partner.parent_id"/>
</div>
</div>
</div>
<div class="row">
<t t-raw="ref_content" />
</div>
</div>
</t>
</template>
<template id="index" name="References">
<t t-call="website_contract.layout">
<t t-set="ref_content">
<h1 class="span12 text-center">Trusted by millions worldwide</h1>
<h2 class="span12 text-center">Our public references</h2>
<div class="span12" id="ref_content">
<div class='navbar navbar-inverse'>
<div class='navbar-inner'>
<t t-call="website.pager" >
<t t-set="classname">pull-left</t>
</t>
<form action="/references/" method="get" class="navbar-search pull-right pagination">
<input type="text" name="search" class="search-query span2" placeholder="Search" t-att-value="search or '' or ''"/>
</form>
</div>
</div>
<div>
<div t-foreach="partner_ids" t-as="partner" class="media thumbnail">
<a class="pull-left" t-attf-href="/references/#{ partner.id }/">
<img class="media-object" t-att-src="partner.img('image_small')"/>
</a>
<div class="media-body">
<t t-call="website.publish"><t t-set="object" t-value="partner"/></t>
<a class="media-heading" t-attf-href="/references/#{ partner.id }/"><small t-field="partner.parent_id"/> <small t-field="partner.name"/></a>
<div t-field="partner.website_sort_description"/>
</div>
</div>
</div>
</div>
</t>
</t>
</template>
<template id="ref_country" inherit_id="website_contract.index" inherit_option_id="website_contract.index" name="Left Country Categories">
<xpath expr="//div[@id='ref_content']" position="before">
<div class="span4">
<ul class="nav nav-list">
<li class="nav-header">Location</li>
<!--t t-foreach="countries">
<li t-if="country_id" t-att-class="searches.get('country') == str(country_id and country_id[0]) and 'active' or ''">
<a t-attf-href="/event/#{ search_path }&amp;country=#{ country_id[0] }"><t t-esc="country_id[1]"/><small>(<t t-esc="country_id_count"/>)</small></a>
</li>
</t-->
</ul>
</div>
</xpath>
<xpath expr="//div[@id='ref_content']" position="attributes">
<attribute name="class">span8</attribute>
</xpath>
</template>
<template id="details" name="Reference Detail">
<t t-call="website_contract.layout">
<t t-set="ref_content">
<t t-call="website.publish"><t t-set="object" t-value="partner_id"/></t>
<h1 class="span12 text-center" t-field="partner_id.name"/>
<div class="span4">
<div class="text-center">
<img t-att-src="partner_id.img('image_medium')"/>
</div>
<address>
<table style="margin: auto;" class="well">
<colgroup>
<col width="100"/>
<col/>
</colgroup>
<tbody>
<t t-set="address" t-value="'&lt;br/&gt;'.join(partner_id.name_get()[0][1].split('\n')[1:])"/>
<tr t-if="address or editable"><th>Address</th><td class="span2" t-raw="address"/></tr>
<tr t-if="partner_id.website or editable"><th>Website</th><td class="span2" t-field="partner_id.website"/></tr>
<tr t-if="partner_id.phone or editable"><th>Tel</th><td class="span2" t-field="partner_id.phone"/></tr>
<tr t-if="partner_id.mobile or editable"><th>Tel</th><td class="span2" t-field="partner_id.mobile"/></tr>
<tr t-if="partner_id.fax or editable"><th>Fax</th><td class="span2" t-field="partner_id.fax"/></tr>
<tr t-if="partner_id.email or editable"><th>Email</th><td class="span2" t-field="partner_id.email"/></tr>
</tbody>
</table>
</address>
</div>
<div class="span8 mt32" t-field="partner_id.website_description"/>
</t>
</t>
</template>
</data>
</openerp>

View File

@ -6,7 +6,8 @@ class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'website_published': fields.boolean('Available in the website'),
'website_testimonial': fields.text('Recommandation'),
'website_description': fields.html('Description for the website'),
'website_sort_description': fields.text('Sort description for the website'),
}
def img(self, cr, uid, ids, field='image_small', context=None):

View File

@ -72,7 +72,7 @@ class Ecommerce(http.Controller):
domain += ['|', '|', '|',
('name', 'ilike', "%%%s%%" % post.get("search")),
('description', 'ilike', "%%%s%%" % post.get("search")),
('description_website', 'ilike', "%%%s%%" % post.get("search")),
('website_description', 'ilike', "%%%s%%" % post.get("search")),
('product_variant_ids.pos_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))]
if cat_id:
cat_id = int(cat_id)

View File

@ -62,7 +62,7 @@
</div>
</t>
</template>
<template id="products_categories" inherit_id="website_sale.layout" inherit_option_id="website_sale.layout" name="Products Left Categories">
<template id="products_categories" inherit_id="website_sale.layout" inherit_option_id="website_sale.layout" name="Left Product Categories">
<xpath expr="//div[@id='shop_content']" position="before">
<div class="span4">
<ul class="nav nav-list">
@ -162,7 +162,7 @@
<button class="btn btn-small btn-success">Add to cart</button>
</form>
<img class="media-object" t-att-src="product.img('image')"/>
<div t-field="product.description_website"></div>
<div t-field="product.website_description"></div>
<div>
<t t-if="product.product_variant_ids[0].lst_price != product.product_variant_ids[0].price">
<h5 class="text-error" style="text-decoration: line-through;"><t t-esc="product.product_variant_ids[0].lst_price" /></h5>

View File

@ -32,7 +32,7 @@ class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'website_published': fields.boolean('Available in the website'),
'description_website': fields.html('Description for the website'),
'website_description': fields.html('Description for the website'),
'suggested_product_id': fields.many2one('product.product', 'Suggested For Product'),
'suggested_product_ids': fields.one2many('product.product', 'suggested_product_id', 'Suggested Products'),
}