diff --git a/webnotes/core/doctype/docperm/docperm.txt b/webnotes/core/doctype/docperm/docperm.txt index 505e186ad8..2b2e00b4c7 100644 --- a/webnotes/core/doctype/docperm/docperm.txt +++ b/webnotes/core/doctype/docperm/docperm.txt @@ -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", diff --git a/webnotes/core/page/permission_manager/permission_manager.js b/webnotes/core/page/permission_manager/permission_manager.js index d1575c5097..fc563d4096 100644 --- a/webnotes/core/page/permission_manager/permission_manager.js +++ b/webnotes/core/page/permission_manager/permission_manager.js @@ -9,7 +9,7 @@ wn.pages['permission-manager'].onload = function(wrapper) { \

"+wn._("Quick Help for Setting Permissions")+":

\
    \ -
  1. "+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.")+"
  2. \ +
  3. "+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.")+"
  4. \
  5. "+wn._("Permissions translate to Users based on what Role they are assigned")+".
  6. \
  7. "+wn._("To set user roles, just go to Setup > Users and click on the user to assign roles.")+"
  8. \
  9. "+wn._("The system provides pre-defined roles, but you can add new roles to set finer permissions")+".
  10. \ @@ -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"); diff --git a/webnotes/data/Framework.sql b/webnotes/data/Framework.sql index 525a8d55af..b27495ab61 100644 --- a/webnotes/data/Framework.sql +++ b/webnotes/data/Framework.sql @@ -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, diff --git a/webnotes/patches/4_0/add_delete_permission.py b/webnotes/patches/4_0/add_delete_permission.py new file mode 100644 index 0000000000..545ba77ad4 --- /dev/null +++ b/webnotes/patches/4_0/add_delete_permission.py @@ -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""") \ No newline at end of file diff --git a/webnotes/profile.py b/webnotes/profile.py index 600790b126..e84185659e 100644 --- a/webnotes/profile.py +++ b/webnotes/profile.py @@ -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"): diff --git a/webnotes/public/js/wn/model/model.js b/webnotes/public/js/wn/model/model.js index bdd16e9c87..f9a1ea295a 100644 --- a/webnotes/public/js/wn/model/model.js +++ b/webnotes/public/js/wn/model/model.js @@ -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; }, diff --git a/webnotes/public/js/wn/model/perm.js b/webnotes/public/js/wn/model/perm.js index c3b39deba8..207829a4a5 100644 --- a/webnotes/public/js/wn/model/perm.js +++ b/webnotes/public/js/wn/model/perm.js @@ -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: {},