Browse Source

Merge pull request #15037 from resilient-tech/standard_roles

fix: set `Script Manager` as a standard role
version-14
mergify[bot] 3 years ago
committed by GitHub
parent
commit
164ff60ceb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      frappe/core/doctype/role/role.py

+ 10
- 3
frappe/core/doctype/role/role.py View File

@@ -2,15 +2,22 @@
# License: MIT. See LICENSE

import frappe

from frappe.model.document import Document

desk_properties = ("search_bar", "notifications", "list_sidebar",
"bulk_actions", "view_switcher", "form_sidebar", "timeline", "dashboard")

STANDARD_ROLES = (
"Administrator",
"System Manager",
"Script Manager",
"All",
"Guest"
)

class Role(Document):
def before_rename(self, old, new, merge=False):
if old in ("Guest", "Administrator", "System Manager", "All"):
if old in STANDARD_ROLES:
frappe.throw(frappe._("Standard roles cannot be renamed"))

def after_insert(self):
@@ -23,7 +30,7 @@ class Role(Document):
self.set_desk_properties()

def disable_role(self):
if self.name in ("Guest", "Administrator", "System Manager", "All"):
if self.name in STANDARD_ROLES:
frappe.throw(frappe._("Standard roles cannot be disabled"))
else:
self.remove_roles()


Loading…
Cancel
Save