diff options
| author | Christophe Matthieu <chm@openerp.com> | 2013-09-06 10:35:00 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2013-09-06 10:35:00 +0200 |
| commit | 8a3f1742e0e9c7acaae726e5c7106d2d7df7e970 (patch) | |
| tree | 78ae5d981fcd25677caea5c8b3999b1e77bf4547 /addons/website_contract | |
| parent | 6f6c59ec1de1881a70e4bf728ea5d8b56bd609f9 (diff) | |
| parent | c80cf7d0646463b290137c26fbada568a6942b00 (diff) | |
[MERGE] from website-al
bzr revid: chm@openerp.com-20130906083500-4n5knaxiqt4cg2ht
Diffstat (limited to 'addons/website_contract')
| -rw-r--r-- | addons/website_contract/__openerp__.py | 4 | ||||
| -rw-r--r-- | addons/website_contract/controllers/main.py | 59 | ||||
| -rw-r--r-- | addons/website_contract/views/website_contract.xml | 81 | ||||
| -rw-r--r-- | addons/website_contract/website_contract.py | 3 |
4 files changed, 90 insertions, 57 deletions
diff --git a/addons/website_contract/__openerp__.py b/addons/website_contract/__openerp__.py index 3be38778530..ef434effc93 100644 --- a/addons/website_contract/__openerp__.py +++ b/addons/website_contract/__openerp__.py @@ -1,7 +1,7 @@ { 'name': 'Public References', 'category': 'Website', - 'summary': 'Publish Your Public References', + 'summary': 'Publish Customer References', 'version': '1.0', 'description': """ OpenERP Blog @@ -9,7 +9,7 @@ OpenERP Blog """, 'author': 'OpenERP SA', - 'depends': ['website', 'sale'], + 'depends': ['website', 'sale', 'website_google_map'], 'data': [ 'views/website_contract.xml', ], diff --git a/addons/website_contract/controllers/main.py b/addons/website_contract/controllers/main.py index 5485fce5f7d..c911881e2fd 100644 --- a/addons/website_contract/controllers/main.py +++ b/addons/website_contract/controllers/main.py @@ -2,51 +2,72 @@ import openerp from openerp.addons.web import http +from openerp.tools.translate import _ from openerp.addons.web.http import request +from openerp.addons.website import website +import urllib class website_contract(http.Controller): - @http.route(['/references/', '/references/page/<int:page>/'], type='http', auth="public") + @website.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 = [] + # check contracts + 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] + domain = ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)] + 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, domain + [('website_published', '=', True)]) + google_map_partner_ids = ",".join([str(p) for p in partner_ids]) - 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, domain + ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)]) + if not request.webcontext.is_public_user: + # search without website_published + partner_ids += partner_obj.search(request.cr, request.uid, domain) partner_ids = list(set(partner_ids)) + # group by country + countries = partner_obj.read_group(request.cr, request.uid, domain, ["id", "country_id"], groupby="country_id", orderby="country_id") + countries.insert(0, {'country_id_count': partner_obj.search(request.cr, request.uid, domain, count=True), 'country_id': ("all", _("All Countries"))}) + + + if post.get("country", "all") != 'all': + partner_ids = partner_obj.search(request.cr, request.uid, [('id', 'in', partner_ids), ('country_id', '=', int(post.get('country')))]) + + 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']) + partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('id', 'in', partner_ids)], limit=step, offset=pager['offset']) - values = website.get_rendering_context({ + values = { + 'countries': countries, 'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids), + 'google_map_partner_ids': google_map_partner_ids, 'pager': pager, - 'search': post.get("search"), - }) - return website.render("website_contract.index", values) + 'searches': post, + 'search_path': "?%s" % urllib.urlencode(post), + } + return request.webcontext.render("website_contract.index", values) - @http.route(['/references/<int:ref_id>/'], type='http', auth="public") + @website.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) + partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('website_published', '=', True), ('id', '=', ref_id)]) + if not request.webcontext.is_public_user: + partner_ids += partner_obj.search(request.cr, request.uid, [('id', '=', ref_id)]) + values = { + 'partner_id': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids[0], context={'show_address': True}), + } + return request.webcontext.render("website_contract.details", values) diff --git a/addons/website_contract/views/website_contract.xml b/addons/website_contract/views/website_contract.xml index a8ef26000bf..9517e809ec2 100644 --- a/addons/website_contract/views/website_contract.xml +++ b/addons/website_contract/views/website_contract.xml @@ -6,7 +6,7 @@ <!-- Layout add nav and footer --> <template id="footer_custom" inherit_id="website.layout" name="Custom Footer"> - <xpath expr="//body/footer//a[@href='/page/website.aboutus']" position="after"> + <xpath expr="//body/footer//div[@name='info']/ul" position="inside"> <li><a href="/references/">References</a></li> </xpath> </template> @@ -27,28 +27,44 @@ <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> + <h1 class="col-md-12 text-center"> + Customer References<br/> + <small>Trusted by millions worldwide</small> + </h1> + <div class="col-md-12" id="ref_content"> + <div class='navbar'> + <div> + <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 action="/references/" method="get" class="navbar-search pull-right pagination form-inline"> + <div class="form-group"> + <input type="text" name="search" class="search-query form-control" placeholder="Search" t-att-value="searches.get('search') or '' or ''" /> + </div> + <div class="form-group"> + <select class="search-query form-control" name="country" t-if="len(countries) > 1" onchange="submit()"> + <t t-foreach="countries"> + <t t-if="country_id"> + <option t-att-selected="searches.get('country') == str(country_id and country_id[0]) and 'selected'" t-att-value="country_id[0]"> + <t t-esc="country_id[1]"/> (<t t-esc="country_id_count"/>) + </option> + </t> + </t> + </select> + </div> </form> </div> </div> + <div> - <div t-foreach="partner_ids" t-as="partner" class="media thumbnail"> + <div t-foreach="partner_ids" t-as="partner" class="media thumbnail" data-publish=""> + <t t-call="website.publish"><t t-set="object" t-value="partner"/></t> <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 class="media-body" style="min-height: 64px;"> + <a class="media-heading" t-attf-href="/references/#{ partner.id }/"><span t-field="partner.parent_id"/> <span t-field="partner.name"/></a> + <div t-field="partner.website_short_description"/> </div> </div> </div> @@ -57,21 +73,18 @@ </t> </template> - <template id="ref_country" inherit_id="website_contract.index" inherit_option_id="website_contract.index" name="Left Country Categories"> + <template id="ref_country" inherit_id="website_contract.index" inherit_option_id="website_contract.index" name="Left World Map"> <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 }&country=#{ country_id[0] }"><t t-esc="country_id[1]"/><small>(<t t-esc="country_id_count"/>)</small></a> - </li> - </t--> + <div class="col-md-4"> + <ul class="nav nav-pills nav-stacked"> + <li class="nav-header">World Map</li> + <iframe t-attf-src="/google_map/?width=320&height=240&partner_ids=#{ google_map_partner_ids }&partner_url=/references/" + style="width:320px; height:260px; border:0; padding:0; margin:0;"></iframe> </ul> </div> </xpath> <xpath expr="//div[@id='ref_content']" position="attributes"> - <attribute name="class">span8</attribute> + <attribute name="class">col-md-8</attribute> </xpath> </template> @@ -79,8 +92,8 @@ <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"> + <h1 class="col-md-12 text-center" t-field="partner_id.name"/> + <div class="col-md-4"> <div class="text-center"> <img t-att-src="partner_id.img('image_medium')"/> </div> @@ -92,17 +105,17 @@ </colgroup> <tbody> <t t-set="address" t-value="'<br/>'.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> + <tr t-if="address or editable"><th>Address</th><td class="col-md-2" t-raw="address"/></tr> + <tr t-if="partner_id.website or editable"><th>Website</th><td class="col-md-2" t-field="partner_id.website"/></tr> + <tr t-if="partner_id.phone or editable"><th>Tel</th><td class="col-md-2" t-field="partner_id.phone"/></tr> + <tr t-if="partner_id.mobile or editable"><th>Tel</th><td class="col-md-2" t-field="partner_id.mobile"/></tr> + <tr t-if="partner_id.fax or editable"><th>Fax</th><td class="col-md-2" t-field="partner_id.fax"/></tr> + <tr t-if="partner_id.email or editable"><th>Email</th><td class="col-md-2" t-field="partner_id.email"/></tr> </tbody> </table> </address> </div> - <div class="span8 mt32" t-field="partner_id.website_description"/> + <div class="col-md-8 mt32" t-field="partner_id.website_description"/> </t> </t> </template> diff --git a/addons/website_contract/website_contract.py b/addons/website_contract/website_contract.py index 10d12f08015..1d89a2bdf4e 100644 --- a/addons/website_contract/website_contract.py +++ b/addons/website_contract/website_contract.py @@ -5,9 +5,8 @@ from openerp.osv import osv, fields class res_partner(osv.osv): _inherit = 'res.partner' _columns = { - 'website_published': fields.boolean('Available in the website'), 'website_description': fields.html('Description for the website'), - 'website_sort_description': fields.text('Sort description for the website'), + 'website_short_description': fields.text('Sort description for the website'), } def img(self, cr, uid, ids, field='image_small', context=None): |
