Merge pull request #7413 from netchampfaris/disable-portal-routes
fix: Disable Portal Routes
This commit is contained in:
commit
09d36621c7
1 changed files with 18 additions and 0 deletions
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue