Merge pull request #7413 from netchampfaris/disable-portal-routes

fix: Disable Portal Routes
This commit is contained in:
Suraj Shetty 2019-05-07 14:08:01 +05:30 committed by GitHub
commit 09d36621c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,9 @@ def resolve_route(path):
The only exceptions are `/about` and `/contact` these will be searched in Web Pages
first before checking the standard pages."""
raise_if_disabled(path)
if path not in ("about", "contact"):
context = get_page_info_from_template(path)
if context:
@ -27,6 +30,21 @@ def resolve_route(path):
return context
return get_page_info_from_template(path)
def raise_if_disabled(path):
routes = frappe.db.get_all('Portal Menu Item',
fields=['route', 'enabled'],
filters={
'route': ['like', '%{0}'.format(path)],
'enabled': 0
}
)
for r in routes:
_path = r.route.lstrip('/')
if path == _path and not r.enabled:
raise frappe.PermissionError
def get_page_context(path):
page_context = None
if can_cache():