[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:
committed by
Jeremy Kersten
parent
d2b5af9ba7
commit
41897f0dba
@@ -105,11 +105,12 @@ class Http(models.AbstractModel):
|
|||||||
req_page = request.httprequest.path
|
req_page = request.httprequest.path
|
||||||
|
|
||||||
domain = [('url', '=', req_page), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False)]
|
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:
|
if not request.website.is_publisher():
|
||||||
domain += [('is_visible', '=', True)]
|
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)
|
_, ext = os.path.splitext(req_page)
|
||||||
if mypage:
|
if mypage:
|
||||||
return request.render(mypage.view_id.id, {
|
return request.render(mypage.view_id.id, {
|
||||||
|
|||||||
Reference in New Issue
Block a user