refactor: moves notification toggle to individual code block

This commit is contained in:
Parth Kharwar 2021-03-05 14:35:34 +05:30
parent 0f42096e87
commit 7effd9db7a

View file

@ -141,16 +141,14 @@ class User(Document):
if not cint(self.enabled):
self.a_system_manager_should_exist()
# disable notifications if the user has been disabled
toggle_notifications(self.name, enable=False)
else:
# enable notifications if the user has been enabled
toggle_notifications(self.name, enable=True)
# clear sessions if disabled
if not cint(self.enabled) and getattr(frappe.local, "login_manager", None):
frappe.local.login_manager.logout(user=self.name)
# toggle notifications based on the user's status
toggle_notifications(self.name, enable=cint(self.enabled))
def add_system_manager_role(self):
# if adding system manager, do nothing
if not cint(self.enabled) or ("System Manager" in [user_role.role for user_role in