Browse Source

[fix] website permission

version-14
Anand Doshi 10 years ago
parent
commit
ce00ecfc54
2 changed files with 14 additions and 5 deletions
  1. +12
    -4
      frappe/__init__.py
  2. +2
    -1
      frappe/templates/pages/print.py

+ 12
- 4
frappe/__init__.py View File

@@ -426,11 +426,19 @@ def has_website_permission(doctype, ptype="read", doc=None, user=None, verbose=F
if not user:
user = session.user

for method in (get_hooks("has_website_permission") or {}).get(doctype, []):
if not call(get_attr(method), doc=doc, ptype=ptype, user=user, verbose=verbose):
return False
hooks = (get_hooks("has_website_permission") or {}).get(doctype, [])
if hooks:
for method in hooks:
result = call(get_attr(method), doc=doc, ptype=ptype, user=user, verbose=verbose)
# if even a single permission check is Falsy
if not result:
return False

return True
# else it is Truthy
return True

else:
return False

def is_table(doctype):
"""Returns True if `istable` property (indicating child Table) is set for given DocType."""


+ 2
- 1
frappe/templates/pages/print.py View File

@@ -121,7 +121,8 @@ def validate_print_permission(doc):
return

for ptype in ("read", "print"):
if not frappe.has_permission(doc.doctype, ptype, doc):
if (not frappe.has_permission(doc.doctype, ptype, doc)
and not frappe.has_website_permission(doc.doctype, ptype, doc)):
raise frappe.PermissionError(_("No {0} permission").format(ptype))

def get_letter_head(doc, no_letterhead):


Loading…
Cancel
Save