8000 fix(UX): Notify if newly created user has no roles by ankush · Pull Request #21251 · frappe/frappe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(UX): Notify if newly created user has no roles #21251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frappe/core/doctype/user/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"read_only": 1
},
{
"allow_in_quick_entry": 1,
"fieldname": "role_profile_name",
"fieldtype": "Link",
"label": "Role Profile",
Expand Down Expand Up @@ -761,7 +762,7 @@
"link_fieldname": "user"
}
],
"modified": "2023-05-24 15:20:06.434506",
"modified": "2023-06-05 17:26:04.127555",
"modified_by": "Administrator",
"module": "Core",
"name": "User",
Expand Down
16 changes: 16 additions & 0 deletions frappe/core/doctype/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def validate(self):
self.validate_email_type(self.email)
self.validate_email_type(self.name)
self.add_system_manager_role()
self.check_roles_added()
self.set_system_user()
self.set_full_name()
self.check_enable_disable()
Expand Down Expand Up @@ -673,6 +674,21 @@ def set_time_zone(self):
if not self.time_zone:
self.time_zone = get_system_timezone()

def check_roles_added(self):
if self.user_type != "System User" or self.roles or not self.is_new():
return

frappe.msgprint(
_("Newly created user {0} has no roles enabled.").format(frappe.bold(self.name)),
title=_("No Roles Specified"),
indicator="orange",
primary_action={
"label": _("Add Roles"),
"client_action": "frappe.set_route",
"args": ["Form", self.doctype, self.name],
},
)


@frappe.whitelist()
def get_timezones():
Expand Down
0