From 766f7d48086d19b011ec2e4bc856de2116619e77 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 5 Feb 2014 11:15:00 +0100 Subject: [FIX] website.menu#url shall not be required=True A parent node's url is not clickable in the website front-end bzr revid: fme@openerp.com-20140205101500-ghmkfkpvkojv81kf --- addons/website/models/website.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/models/website.py') diff --git a/addons/website/models/website.py b/addons/website/models/website.py index e3c683861f9..87dbb5b16ad 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -517,7 +517,7 @@ class website_menu(osv.osv): _description = "Website Menu" _columns = { 'name': fields.char('Menu', size=64, required=True, translate=True), - 'url': fields.char('Url', required=True, translate=True), + 'url': fields.char('Url', translate=True), 'new_window': fields.boolean('New Window'), 'sequence': fields.integer('Sequence'), # TODO: support multiwebsite once done for ir.ui.views -- cgit v1.2.3 From f487fbb298b5af27587af747f4392ed58fc3e0d1 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 6 Feb 2014 11:39:29 +0100 Subject: [FIX] website: urljoin from urlparse cannot handle unicode. Therefore, We decode before passing the arg to urljoin then we (re-)encode the result bzr revid: dle@openerp.com-20140206103929-oe289oilz08n1msk --- addons/website/models/website.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addons/website/models/website.py') diff --git a/addons/website/models/website.py b/addons/website/models/website.py index e3c683861f9..a3d7e154678 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -36,12 +36,18 @@ def keep_query(*args, **kw): return werkzeug.urls.url_encode(params) def url_for(path_or_uri, lang=None): + if isinstance(path_or_uri, unicode): + path_or_uri = path_or_uri.encode('utf-8') + current_path = request.httprequest.path + if isinstance(current_path, unicode): + current_path = current_path.encode('utf-8') location = path_or_uri.strip() force_lang = lang is not None url = urlparse.urlparse(location) if request and not url.netloc and not url.scheme and (url.path or force_lang): - location = urlparse.urljoin(request.httprequest.path, location) + location = urlparse.urljoin(current_path, location) + lang = lang or request.context.get('lang') langs = [lg[0] for lg in request.website.get_languages()] @@ -59,7 +65,7 @@ def url_for(path_or_uri, lang=None): ps.insert(1, lang) location = '/'.join(ps) - return location + return location.decode('utf-8') def is_multilang_url(path, langs=None): if not langs: -- cgit v1.2.3 From b112d5d2f1e8a6b4d457b0693f213a2e35510cfb Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 6 Feb 2014 15:39:19 +0100 Subject: [FIX] ir ui view should have rendering context on request.website_enabled bzr revid: fme@openerp.com-20140206143919-f6vz8rpx9mb4798g --- addons/website/models/website.py | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'addons/website/models/website.py') diff --git a/addons/website/models/website.py b/addons/website/models/website.py index a3d7e154678..96605000bba 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -221,7 +221,6 @@ class website(osv.osv): request.redirect = lambda url: werkzeug.utils.redirect(url_for(url)) request.context.update( - is_master_lang=is_master_lang, editable=is_website_publisher, translatable=not is_master_lang, ) @@ -234,37 +233,8 @@ class website(osv.osv): return self.pool["ir.ui.view"].browse(cr, uid, view_id, context=context) def _render(self, cr, uid, ids, template, values=None, context=None): - user = self.pool.get("res.users") - if not context: - context = {} - - # Take a context - qweb_values = context.copy() - # add some values - if values: - qweb_values.update(values) - # fill some defaults - qweb_values.update( - request=request, - json=simplejson, - website=request.website, - url_for=url_for, - keep_query=keep_query, - slug=slug, - res_company=request.website.company_id, - user_id=user.browse(cr, uid, uid), - quote_plus=werkzeug.url_quote_plus, - ) - qweb_values.setdefault('editable', False) - - # in edit mode ir.ui.view will tag nodes - context['inherit_branding'] = qweb_values['editable'] - - view = self.get_template(cr, uid, ids, template) - - if 'main_object' not in qweb_values: - qweb_values['main_object'] = view - return view.render(qweb_values, engine='website.qweb', context=context) + # TODO: remove this. (just kept for backward api compatibility for saas-3) + return self.pool['ir.ui.view'].render(cr, uid, template, values=values, context=context) def render(self, cr, uid, ids, template, values=None, status_code=None, context=None): def callback(template, values, context): -- cgit v1.2.3 From 2f682975bce5e6eb12123188b7797d7faf61d7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Feb 2014 15:56:38 +0100 Subject: [FIX] website: fixed call to slugify - python-slugify: max_length is an optional keyword - slugify library also exists and does not accepts max_length -> if this very simple library is used, fall back on our own implementation bzr revid: tde@openerp.com-20140206145638-entdcqsawrqf1nnq --- addons/website/models/website.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/website/models/website.py') diff --git a/addons/website/models/website.py b/addons/website/models/website.py index a3d7e154678..26cf4822a33 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -84,7 +84,11 @@ def is_multilang_url(path, langs=None): def slugify(s, max_length=None): if slugify_lib: - return slugify_lib.slugify(s, max_length) + # There are 2 different libraries only python-slugify is supported + try: + return slugify_lib.slugify(s, max_length=max_length) + except TypeError: + pass spaceless = re.sub(r'\s+', '-', s) specialless = re.sub(r'[^-_A-Za-z0-9]', '', spaceless) return specialless[:max_length] -- cgit v1.2.3 From 2d4fb9769601a32db2ab13f448c8da6bcd86eca4 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 6 Feb 2014 17:13:16 +0100 Subject: [IMP] Move some qweb rendering context vars from website#ir.qweb to server#ir.ui.view bzr revid: fme@openerp.com-20140206161316-jw7luqon476widcm --- addons/website/models/website.py | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'addons/website/models/website.py') diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 96605000bba..ec194686464 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import fnmatch import inspect import itertools import logging @@ -7,7 +6,6 @@ import math import re import urlparse -import simplejson import werkzeug import werkzeug.exceptions import werkzeug.wrappers @@ -24,17 +22,6 @@ from openerp.addons.web.http import request, LazyResponse logger = logging.getLogger(__name__) -def keep_query(*args, **kw): - if not args and not kw: - args = ('*',) - params = kw.copy() - query_params = frozenset(werkzeug.url_decode(request.httprequest.query_string).keys()) - for keep_param in args: - for param in fnmatch.filter(query_params, keep_param): - if param not in params and param in request.params: - params[param] = request.params[param] - return werkzeug.urls.url_encode(params) - def url_for(path_or_uri, lang=None): if isinstance(path_or_uri, unicode): path_or_uri = path_or_uri.encode('utf-8') -- cgit v1.2.3