updates for restriction

This commit is contained in:
Rushabh Mehta 2014-01-24 11:10:01 +05:30
parent 93eab5521c
commit 1cd96a136f
7 changed files with 20 additions and 15 deletions

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-01-10 16:34:12", "creation": "2013-01-10 16:34:12",
"docstatus": 0, "docstatus": 0,
"modified": "2014-01-20 17:48:22", "modified": "2014-01-22 16:05:34",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "ashwini@webnotestech.com" "owner": "ashwini@webnotestech.com"
}, },
@ -233,7 +233,7 @@
"cancel": 0, "cancel": 0,
"delete": 0, "delete": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"match": "owner", "restricted": 1,
"role": "Employee", "role": "Employee",
"submit": 0 "submit": 0
}, },

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-01-10 16:34:14", "creation": "2013-01-10 16:34:14",
"docstatus": 0, "docstatus": 0,
"modified": "2014-01-20 17:48:44", "modified": "2014-01-22 16:05:34",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "harshada@webnotestech.com" "owner": "harshada@webnotestech.com"
}, },
@ -223,7 +223,7 @@
{ {
"delete": 0, "delete": 0,
"doctype": "DocPerm", "doctype": "DocPerm",
"match": "owner", "restricted": 1,
"role": "Employee" "role": "Employee"
}, },
{ {

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-02-20 19:10:38", "creation": "2013-02-20 19:10:38",
"docstatus": 0, "docstatus": 0,
"modified": "2014-01-20 17:48:54", "modified": "2014-01-22 16:05:35",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -171,7 +171,7 @@
}, },
{ {
"doctype": "DocPerm", "doctype": "DocPerm",
"match": "owner", "restricted": 1,
"role": "HR User" "role": "HR User"
}, },
{ {

View File

@ -45,7 +45,11 @@ def update_user_match():
for profile in webnotes.conn.sql_list("""select name from `tabProfile` for profile in webnotes.conn.sql_list("""select name from `tabProfile`
where enabled=1 and user_type='System User'"""): where enabled=1 and user_type='System User'"""):
perms = webnotes.permissions.get_user_perms(meta, "read", profile) user_roles = webnotes.get_roles(profile)
perms = meta.get({"doctype": "DocPerm", "permlevel": 0,
"role": ["in", [["All"] + user_roles]], "read": 1})
# user does not have required roles # user does not have required roles
if not perms: if not perms:
continue continue

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-04-03 16:38:41", "creation": "2013-04-03 16:38:41",
"docstatus": 0, "docstatus": 0,
"modified": "2014-01-20 17:49:34", "modified": "2014-01-22 16:05:35",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -205,7 +205,7 @@
{ {
"create": 1, "create": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
"match": "owner", "restricted": 1,
"role": "Projects User" "role": "Projects User"
}, },
{ {

View File

@ -7,17 +7,17 @@ import webnotes
@webnotes.whitelist() @webnotes.whitelist()
def get_children(): def get_children():
ctype = webnotes.form_dict.get('ctype') ctype = webnotes.local.form_dict.get('ctype')
webnotes.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_') webnotes.local.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_')
if not webnotes.form_dict.get('parent'): if not webnotes.form_dict.get('parent'):
webnotes.form_dict['parent'] = '' webnotes.local.form_dict['parent'] = ''
return webnotes.conn.sql("""select name as value, return webnotes.conn.sql("""select name as value,
if(is_group='Yes', 1, 0) as expandable if(is_group='Yes', 1, 0) as expandable
from `tab%(ctype)s` from `tab%(ctype)s`
where docstatus < 2 where docstatus < 2
and ifnull(%(parent_field)s,'') = "%(parent)s" and ifnull(%(parent_field)s,'') = "%(parent)s"
order by name""" % webnotes.form_dict, as_dict=1) order by name""" % webnotes.local.form_dict, as_dict=1)
@webnotes.whitelist() @webnotes.whitelist()
def add_node(): def add_node():

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 13:41:00", "creation": "2013-05-24 13:41:00",
"docstatus": 0, "docstatus": 0,
"modified": "2014-01-20 17:48:58", "modified": "2014-01-22 16:05:35",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -25,7 +25,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"cancel": 1, "cancel": 0,
"create": 1, "create": 1,
"delete": 1, "delete": 1,
"doctype": "DocPerm", "doctype": "DocPerm",
@ -37,6 +37,7 @@
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
"restricted": 1,
"role": "All", "role": "All",
"write": 1 "write": 1
}, },