From ef2979c7e777eb0a4cded3e995b3be99936611e3 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 6 May 2019 15:09:33 +0530 Subject: [PATCH] fix: Disable Portal Routes --- frappe/website/router.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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():