Ver a proveniência

[fix] allow context in frappe.respond_as_web_page

version-14
Anand Doshi há 9 anos
ascendente
cometimento
72abd6717a
2 ficheiros alterados com 8 adições e 1 eliminações
  1. +4
    -1
      frappe/__init__.py
  2. +4
    -0
      frappe/website/context.py

+ 4
- 1
frappe/__init__.py Ver ficheiro

@@ -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


+ 4
- 0
frappe/website/context.py Ver ficheiro

@@ -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):


Carregando…
Cancelar
Guardar