From 72abd6717a36d2f6cc766b32ed1e8dc965568a4b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 7 Apr 2016 16:31:30 +0530 Subject: [PATCH] [fix] allow context in frappe.respond_as_web_page --- frappe/__init__.py | 5 ++++- frappe/website/context.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index ddade9062c..20b17a83b3 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -884,7 +884,7 @@ def compare(val1, condition, val2): import frappe.utils return frappe.utils.compare(val1, condition, val2) -def respond_as_web_page(title, html, success=None, http_status_code=None): +def respond_as_web_page(title, html, success=None, http_status_code=None, context=None): """Send response as a web page with a message rather than JSON. Used to show permission errors etc. :param title: Page title and heading. @@ -899,6 +899,9 @@ def respond_as_web_page(title, html, success=None, http_status_code=None): if http_status_code: local.response['http_status_code'] = http_status_code + if context: + local.response['context'] = context + def build_match_conditions(doctype, as_condition=True): """Return match (User permissions) for given doctype as list or SQL.""" import frappe.desk.reportview diff --git a/frappe/website/context.py b/frappe/website/context.py index 16671c176a..a09eb75809 100644 --- a/frappe/website/context.py +++ b/frappe/website/context.py @@ -16,6 +16,10 @@ def get_context(path, args=None): context = build_context(context) context["path"] = path + # set using frappe.respond_as_web_page + if hasattr(frappe.local, 'response') and frappe.local.response.get('context'): + context.update(frappe.local.response.context) + return context def build_context(context):