[perms] allow email/print if has read access via share

This commit is contained in:
Nabin Hait 2015-06-08 17:46:51 +05:30
parent 20642a0f37
commit 6d7c1da29e
2 changed files with 7 additions and 4 deletions

View file

@ -39,13 +39,16 @@ def has_permission(doctype, ptype="read", doc=None, verbose=False, user=None):
return True
def false_if_not_shared():
if ptype in ("read", "write", "share"):
shared = frappe.share.get_shared(doctype, user, [ptype])
if ptype in ("read", "write", "share", "email", "print"):
shared = frappe.share.get_shared(doctype, user,
["read" if ptype in ("email", "print") else ptype])
if doc:
doc_name = doc if isinstance(doc, basestring) else doc.name
if doc_name in shared:
if verbose: print "Shared"
return True
if ptype in ("read", "write", "share") or meta.permissions[0].get(ptype):
return True
else:
if verbose: print "Has a shared document"
return True

View file

@ -69,7 +69,7 @@ $.extend(frappe.perm, {
perm[0]["write"] = s.write;
perm[0]["share"] = s.share;
if(s.write) {
if(s.read) {
// also give print, email permissions if read
// and these permissions exist at level [0]
perm[0].email = meta.permissions[0].email;