[FIX] website, website_blog: fix wrong href on the top banner of /blog

Before this commit, following these steps:
- Go to /blog
- Activate the option Customize > Top banner - Name / Latest Post
- Disable the option Customize > Full Width Cover

The URL to which we are redirected when we click on the category of the
post presented at the top of the page leads to an error. In order to fix
the wrong url we had to patch QueryURL so that the url prefix is added
only if the url does not already start with the prefix.

opw-2882492

X-original-commit: https://github.com/odoo/odoo/commit/2b326de107b9b7a2013ee9ff174d81b645d6a623
Part-of: odoo/odoo#104639
This commit is contained in:
qsm-odoo
2022-11-07 13:49:58 +01:00
committed by Guillaume (gdi)
parent 1f3a392ffa
commit c771aa406c
2 changed files with 5 additions and 4 deletions
+4 -1
View File
@@ -43,7 +43,8 @@ class QueryURL(object):
self.path_args = OrderedSet(path_args or [])
def __call__(self, path=None, path_args=None, **kw):
path = path or self.path
path_prefix = path or self.path
path = ''
for key, value in self.args.items():
kw.setdefault(key, value)
path_args = OrderedSet(path_args or []) | self.path_args
@@ -65,6 +66,8 @@ class QueryURL(object):
path += '/' + key + '/' + value
if fragments:
path += '?' + '&'.join(fragments)
if not path.startswith(path_prefix):
path = path_prefix + path
return path
+1 -3
View File
@@ -215,9 +215,7 @@ class WebsiteBlog(http.Controller):
if blog:
values['main_object'] = blog
values['blog_url'] = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end, search=search)
else:
values['blog_url'] = QueryURL('/blog', ['tag'], date_begin=date_begin, date_end=date_end, search=search)
values['blog_url'] = QueryURL('/blog', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end, search=search)
return request.render("website_blog.blog_post_short", values)