started separate delete permissions

This commit is contained in:
Rushabh Mehta 2014-01-20 17:36:23 +05:30
parent af041d7713
commit e2fe0a989b
7 changed files with 32 additions and 5 deletions

View file

@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:27:33",
"docstatus": 0,
"modified": "2014-01-04 22:26:35",
"modified": "2014-01-20 15:32:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -102,6 +102,12 @@
"search_index": 0,
"width": "32px"
},
{
"doctype": "DocField",
"fieldname": "delete",
"fieldtype": "Check",
"label": "Delete"
},
{
"doctype": "DocField",
"fieldname": "submit",

View file

@ -9,7 +9,7 @@ wn.pages['permission-manager'].onload = function(wrapper) {
<tr><td>\
<h4><i class='icon-question-sign'></i> "+wn._("Quick Help for Setting Permissions")+":</h4>\
<ol>\
<li>"+wn._("Permissions are set on Roles and Document Types (called DocTypes) by restricting read, edit, make new, submit, cancel, amend, report, import, export, print, email and restrict rights.")+"</li>\
<li>"+wn._("Permissions are set on Roles and Document Types (called DocTypes) by restricting read, edit, make new, delete, submit, cancel, amend, report, import, export, print, email and restrict rights.")+"</li>\
<li>"+wn._("Permissions translate to Users based on what Role they are assigned")+".</li>\
<li>"+wn._("To set user roles, just go to <a href='#List/Profile'>Setup > Users</a> and click on the user to assign roles.")+"</li>\
<li>"+wn._("The system provides pre-defined roles, but you can <a href='#List/Role'>add new roles</a> to set finer permissions")+".</li>\
@ -243,6 +243,7 @@ wn.PermissionEngine = Class.extend({
add_check(perm_container, d, "read");
add_check(perm_container, d, "write");
add_check(perm_container, d, "create");
add_check(perm_container, d, "delete");
add_check(perm_container, d, "submit");
add_check(perm_container, d, "cancel");
add_check(perm_container, d, "amend");

View file

@ -77,6 +77,7 @@ CREATE TABLE `tabDocPerm` (
`create` int(1) DEFAULT NULL,
`submit` int(1) DEFAULT NULL,
`cancel` int(1) DEFAULT NULL,
`delete` int(1) DEFAULT NULL,
`amend` int(1) DEFAULT NULL,
`report` int(1) DEFAULT NULL,
`export` int(1) DEFAULT NULL,

View file

@ -0,0 +1,10 @@
import webnotes
def execute():
webnotes.reload_doc("core", "doctype", "docperm")
# delete same as cancel (map old permissions)
webnotes.conn.sql("""update tabDocPerm set `delete`=ifnull(`cancel`,0)""")
# can't cancel if can't submit
webnotes.conn.sql("""update tabDocPerm set `cancel`=0 where `submit`=0""")

View file

@ -20,6 +20,7 @@ class Profile:
self.can_read = []
self.can_write = []
self.can_cancel = []
self.can_delete = []
self.can_search = []
self.can_get_report = []
self.can_import = []
@ -93,6 +94,9 @@ class Profile:
if p.get('cancel'):
self.can_cancel.append(dt)
if p.get('delete'):
self.can_delete.append(dt)
if (p.get('read') or p.get('write') or p.get('create')):
if p.get('report'):
self.can_get_report.append(dt)
@ -159,7 +163,7 @@ class Profile:
d['roles'] = self.get_roles()
d['defaults'] = self.get_defaults()
for key in ("can_create", "can_write", "can_read", "can_cancel",
for key in ("can_create", "can_write", "can_read", "can_cancel", "can_delete",
"can_get_report", "allow_modules", "all_read", "can_search",
"in_create", "can_export", "can_import", "can_print", "can_email",
"can_restrict"):

View file

@ -137,6 +137,11 @@ $.extend(wn.model, {
},
can_delete: function(doctype) {
if(!doctype) return false;
return wn.boot.profile.can_delete.indexOf(doctype)!==-1;
},
can_cancel: function(doctype) {
if(!doctype) return false;
return wn.boot.profile.can_cancel.indexOf(doctype)!==-1;
},

View file

@ -4,12 +4,12 @@
wn.provide("wn.perm");
// backward compatibilty
var READ = "read", WRITE = "write", CREATE = "create";
var READ = "read", WRITE = "write", CREATE = "create", DELETE = "delete";
var SUBMIT = "submit", CANCEL = "cancel", AMEND = "amend";
$.extend(wn.perm, {
rights: ["read", "write", "create", "submit", "cancel", "amend",
"report", "import", "export", "print", "email", "restrict"],
"report", "import", "export", "print", "email", "restrict", "delete"],
doctype_perm: {},