|
|
@@ -8,7 +8,7 @@ from frappe.utils import cint, flt, has_gravatar, escape_html, format_datetime, |
|
|
|
from frappe import throw, msgprint, _ |
|
|
|
from frappe.utils.password import update_password as _update_password, check_password |
|
|
|
from frappe.desk.notifications import clear_notifications |
|
|
|
from frappe.desk.doctype.notification_settings.notification_settings import create_notification_settings, enable_disable_notifications |
|
|
|
from frappe.desk.doctype.notification_settings.notification_settings import create_notification_settings, toggle_notifications |
|
|
|
from frappe.utils.user import get_system_managers |
|
|
|
from bs4 import BeautifulSoup |
|
|
|
import frappe.permissions |
|
|
@@ -142,16 +142,15 @@ class User(Document): |
|
|
|
if not cint(self.enabled): |
|
|
|
self.a_system_manager_should_exist() |
|
|
|
# disable notifications if the user has been disabled |
|
|
|
enable_disable_notifications(self.name, enabled=False) |
|
|
|
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) |
|
|
|
|
|
|
|
# enable notifications if the user has been enabled |
|
|
|
if cint(self.enabled): |
|
|
|
enable_disable_notifications(self.name, enabled=True) |
|
|
|
|
|
|
|
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 |
|
|
|