Преглед на файлове

[fix] allow context in frappe.respond_as_web_page

version-14
Anand Doshi преди 9 години
родител
ревизия
72abd6717a
променени са 2 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. +4
    -1
      frappe/__init__.py
  2. +4
    -0
      frappe/website/context.py

+ 4
- 1
frappe/__init__.py Целия файл

@@ -884,7 +884,7 @@ def compare(val1, condition, val2):
import frappe.utils import frappe.utils
return frappe.utils.compare(val1, condition, val2) 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. """Send response as a web page with a message rather than JSON. Used to show permission errors etc.


:param title: Page title and heading. :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: if http_status_code:
local.response['http_status_code'] = 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): def build_match_conditions(doctype, as_condition=True):
"""Return match (User permissions) for given doctype as list or SQL.""" """Return match (User permissions) for given doctype as list or SQL."""
import frappe.desk.reportview import frappe.desk.reportview


+ 4
- 0
frappe/website/context.py Целия файл

@@ -16,6 +16,10 @@ def get_context(path, args=None):
context = build_context(context) context = build_context(context)
context["path"] = path 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 return context


def build_context(context): def build_context(context):


Зареждане…
Отказ
Запис