From 84c3eb3d62c40e40ec8c19c3c3f0516f0db4d4aa Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Tue, 27 Aug 2019 19:36:44 +0530 Subject: [PATCH] fix: Disable caching for respond_as_web_page response (#8276) * fix: Do not cache workflow approval confirmation page * fix: Make it readable * fix: Disable caching for respond_as_web_page * fix: Remove info about no_cache from docstring --- frappe/__init__.py | 4 +++- .../doctype/workflow_action/workflow_action.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 650ae7b71f..741aae1b06 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -1162,7 +1162,7 @@ def respond_as_web_page(title, html, success=None, http_status_code=None, :param context: web template context :param indicator_color: color of indicator in title :param primary_action: route on primary button (default is `/`) - :param primary_label: label on primary button (defaut is "Home") + :param primary_label: label on primary button (default is "Home") :param fullpage: hide header / footer :param width: Width of message in pixels :param template: Optionally pass view template @@ -1171,6 +1171,8 @@ def respond_as_web_page(title, html, success=None, http_status_code=None, local.message = html local.response['type'] = 'page' local.response['route'] = template + local.no_cache = 1 + if http_status_code: local.response['http_status_code'] = http_status_code diff --git a/frappe/workflow/doctype/workflow_action/workflow_action.py b/frappe/workflow/doctype/workflow_action/workflow_action.py index 53ab1073f9..f32b1dfc03 100644 --- a/frappe/workflow/doctype/workflow_action/workflow_action.py +++ b/frappe/workflow/doctype/workflow_action/workflow_action.py @@ -94,7 +94,8 @@ def confirm_action(doctype, docname, user, action): return_success_page(newdoc) # reset session user - frappe.set_user(logged_in_user) + if logged_in_user == 'Guest': + frappe.set_user(logged_in_user) def return_success_page(doc): frappe.respond_as_web_page(_("Success"), @@ -116,9 +117,10 @@ def return_action_confirmation_page(doc, action, action_link, alert_doc_change=F template_params['pdf_link'] = get_pdf_link(doc.get('doctype'), doc.get('name')) - frappe.respond_as_web_page(None, None, - indicator_color="blue", - template="confirm_workflow_action", + frappe.respond_as_web_page(title=None, + html=None, + indicator_color='blue', + template='confirm_workflow_action', context=template_params) def return_link_expired_page(doc, doc_workflow_state):