[FIX] website: see versionning changes
Website Versioning module (website_version) is applied when displaying views by interfering when doing the "render the view of this `key`" and showing the view with the same `key` but of the currently displayed version. The website.page model when directly rendering a page would directly specify its `id`, thus website version was bypassed and just the master page was displayed. With this commit website.page has a "get_view_identifier" that can be overrided in website_version and has the same previous behavior otherwise. This changeset also solves a conflict (`website().get_current_website` also modify `request.context`) when modifying the context which also disabled versions. opw-1824957 closes #23847
This commit is contained in:
@@ -70,15 +70,15 @@ class Http(models.AbstractModel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _add_dispatch_parameters(cls, func):
|
def _add_dispatch_parameters(cls, func):
|
||||||
|
|
||||||
context = dict(request.context)
|
context = {}
|
||||||
if not context.get('tz'):
|
if not request.context.get('tz'):
|
||||||
context['tz'] = request.session.get('geoip', {}).get('time_zone')
|
context['tz'] = request.session.get('geoip', {}).get('time_zone')
|
||||||
|
|
||||||
request.website = request.env['website'].get_current_website() # can use `request.env` since auth methods are called
|
request.website = request.env['website'].get_current_website() # can use `request.env` since auth methods are called
|
||||||
context['website_id'] = request.website.id
|
context['website_id'] = request.website.id
|
||||||
|
|
||||||
# bind modified context
|
# modify bound context
|
||||||
request.context = context
|
request.context = dict(request.context, **context)
|
||||||
|
|
||||||
super(Http, cls)._add_dispatch_parameters(func)
|
super(Http, cls)._add_dispatch_parameters(func)
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ class Http(models.AbstractModel):
|
|||||||
mypage = pages[0] if pages else False
|
mypage = pages[0] if pages else False
|
||||||
_, ext = os.path.splitext(req_page)
|
_, ext = os.path.splitext(req_page)
|
||||||
if mypage:
|
if mypage:
|
||||||
return request.render(mypage.view_id.id, {
|
return request.render(mypage.get_view_identifier(), {
|
||||||
# 'path': req_page[1:],
|
# 'path': req_page[1:],
|
||||||
'deletable': True,
|
'deletable': True,
|
||||||
'main_object': mypage,
|
'main_object': mypage,
|
||||||
|
|||||||
@@ -658,6 +658,11 @@ class Page(models.Model):
|
|||||||
item = self.search_read(domain, fields=['id', 'name', 'url', 'website_published', 'website_indexed', 'date_publish', 'menu_ids', 'is_homepage'], limit=1)
|
item = self.search_read(domain, fields=['id', 'name', 'url', 'website_published', 'website_indexed', 'date_publish', 'menu_ids', 'is_homepage'], limit=1)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_view_identifier(self):
|
||||||
|
""" Get identifier of this page view that may be used to render it """
|
||||||
|
return self.view_id.id
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def save_page_info(self, website_id, data):
|
def save_page_info(self, website_id, data):
|
||||||
website = self.env['website'].browse(website_id)
|
website = self.env['website'].browse(website_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user