diff --git a/frappe/website/router.py b/frappe/website/router.py index e60d17a7d9..ebdbe0116f 100644 --- a/frappe/website/router.py +++ b/frappe/website/router.py @@ -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():