[permission model] Redesign

Conflicts:

	patches/patch_list.py
This commit is contained in:
Rushabh Mehta 2013-11-26 17:54:53 +05:30 committed by Anand Doshi
parent 74f64b67db
commit 497d363fc1
10 changed files with 60 additions and 11 deletions

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-30 12:49:46",
"docstatus": 0,
"modified": "2013-09-24 11:22:18",
"modified": "2013-11-26 17:35:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -138,6 +138,7 @@
"doctype": "DocField",
"fieldname": "parent_account",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Account",
"oldfieldname": "parent_account",
"oldfieldtype": "Link",
@ -154,7 +155,6 @@
"oldfieldname": "account_type",
"oldfieldtype": "Select",
"options": "\nFixed Asset Account\nBank or Cash\nExpense Account\nTax\nIncome Account\nChargeable\nWarehouse",
"permlevel": 0,
"search_index": 0
},
{

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-23 19:57:17",
"docstatus": 0,
"modified": "2013-07-22 15:23:10",
"modified": "2013-11-26 17:34:50",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -74,6 +74,7 @@
"doctype": "DocField",
"fieldname": "parent_cost_center",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Cost Center",
"oldfieldname": "parent_cost_center",
"oldfieldtype": "Link",
@ -171,6 +172,7 @@
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
"ignore_restriction": 1,
"label": "old_parent",
"no_copy": 1,
"oldfieldname": "old_parent",

View File

@ -43,9 +43,11 @@ class DocType:
self.update_profile()
def update_user_default(self):
if not "HR User" in webnotes.local.user.get_roles():
webnotes.conn.set_default("Employee", self.doc.name, self.doc.user_id, "Restriction")
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
webnotes.conn.set_default("employee_name", self.doc.employee_name, self.doc.user_id)
webnotes.conn.set_default("company", self.doc.company, self.doc.user_id)
self.set_default_leave_approver()
def set_default_leave_approver(self):

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-07 09:04:18",
"docstatus": 0,
"modified": "2013-11-03 11:19:10",
"modified": "2013-11-26 16:36:34",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -415,6 +415,7 @@
"doctype": "DocField",
"fieldname": "reports_to",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Reports to",
"oldfieldname": "reports_to",
"oldfieldtype": "Link",
@ -749,7 +750,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "employee",
"role": "Employee",
"write": 0
},
@ -757,7 +757,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"match": "company",
"role": "HR User",
"write": 1
},

View File

@ -0,0 +1,38 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
def execute():
update_user_properties()
update_permissions()
webnotes.clear_cache()
def update_user_properties():
webnotes.reload_doc("core", "doctype", "docfield")
for d in webnotes.conn.sql("""select parent, defkey, defvalue from tabDefaultValue
where parent not in ('__global', 'Control Panel')""", as_dict=True):
df = webnotes.conn.sql("""select options from tabDocField
where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
if df:
webnotes.conn.sql("""update tabDefaultValue
set defkey=%s, parenttype='Restriction'
where defkey=%s and
parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey))
# remove duplicate restrictions (if they exist)
for d in webnotes.conn.sql("""select parent, defkey, substr(defvalue,0,10),
count(*) as cnt from tabDefaultValue
where parent not in ('__global', 'Control Panel')
group by parent, defkey, defvalue""", as_dict=1):
if d.cnt > 1:
webnotes.conn.sql("""delete from tabDefaultValue where parent=%s, defkey=%s,
defvalue=%s limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))
def update_permissions():
# clear match conditions other than owner
webnotes.conn.sql("""update tabDocPerm set `match`=''
where ifnull(`match`,'') not in ('', 'owner')""")

View File

@ -254,6 +254,7 @@ patch_list = [
"patches.1311.p04_update_comments",
"patches.1311.p05_website_brand_html",
"patches.1311.p06_fix_report_columns",
"patches.1311.p06_update_user_properties",
"execute:webnotes.delete_doc('DocType', 'Documentation Tool')",
"execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29",
"patches.1312.p01_delete_old_stock_reports",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:23",
"docstatus": 0,
"modified": "2013-11-02 16:52:51",
"modified": "2013-11-26 17:35:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -66,6 +66,7 @@
"doctype": "DocField",
"fieldname": "parent_customer_group",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Customer Group",
"oldfieldname": "parent_customer_group",
"oldfieldtype": "Link",
@ -127,6 +128,7 @@
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
"ignore_restriction": 1,
"label": "old_parent",
"no_copy": 1,
"oldfieldname": "old_parent",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:29",
"docstatus": 0,
"modified": "2013-11-02 19:41:37",
"modified": "2013-11-26 17:36:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -71,6 +71,7 @@
"doctype": "DocField",
"fieldname": "parent_item_group",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Item Group",
"no_copy": 0,
"oldfieldname": "parent_item_group",
@ -166,6 +167,7 @@
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
"ignore_restriction": 1,
"label": "old_parent",
"no_copy": 1,
"oldfieldname": "old_parent",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
"modified": "2013-09-10 10:53:28",
"modified": "2013-11-26 17:35:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -65,6 +65,7 @@
"doctype": "DocField",
"fieldname": "parent_sales_person",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Sales Person",
"oldfieldname": "parent_sales_person",
"oldfieldtype": "Link",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
"modified": "2013-11-02 16:59:08",
"modified": "2013-11-26 17:36:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -68,6 +68,7 @@
"doctype": "DocField",
"fieldname": "parent_territory",
"fieldtype": "Link",
"ignore_restriction": 1,
"label": "Parent Territory",
"oldfieldname": "parent_territory",
"oldfieldtype": "Link",
@ -136,6 +137,7 @@
"fieldname": "old_parent",
"fieldtype": "Link",
"hidden": 1,
"ignore_restriction": 1,
"label": "old_parent",
"no_copy": 1,
"oldfieldname": "old_parent",