[FIX] website: respect website.page date_publish

Before this public users could see pages before their
date_publish.

request.website.is_publisher is a function that always exists. So the
if body will never be executed. Additionally, is_visible is a
non-stored computed field that can't be searched. So instead grab all
records that match and filter the ones that are visible.

This commit closes #20296
This commit is contained in:
Joren Van Onder
2017-10-19 10:06:50 +02:00
committed by Jeremy Kersten
parent d2b5af9ba7
commit 41897f0dba
+4 -3
View File
@@ -105,11 +105,12 @@ class Http(models.AbstractModel):
req_page = request.httprequest.path
domain = [('url', '=', req_page), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False)]
pages = request.env['website.page'].search(domain)
if not request.website.is_publisher:
domain += [('is_visible', '=', True)]
if not request.website.is_publisher():
pages = pages.filtered('is_visible')
mypage = request.env['website.page'].search(domain, limit=1)
mypage = pages[0] if pages else False
_, ext = os.path.splitext(req_page)
if mypage:
return request.render(mypage.view_id.id, {