fix: ignore perm while updating notification settings

If you can update user, do you should be able to update notif settings.
This commit is contained in:
Ankush Menat 2023-10-25 11:22:05 +05:30
parent 65e859c938
commit d196dfeac4
2 changed files with 3 additions and 3 deletions

View file

@ -248,7 +248,7 @@ class User(Document):
frappe.local.login_manager.logout(user=self.name)
# toggle notifications based on the user's status
toggle_notifications(self.name, enable=cint(self.enabled))
toggle_notifications(self.name, enable=cint(self.enabled), ignore_permissions=True)
def add_system_manager_role(self):
if self.is_system_manager_disabled():

View file

@ -70,7 +70,7 @@ def create_notification_settings(user):
_doc.insert(ignore_permissions=True)
def toggle_notifications(user: str, enable: bool = False):
def toggle_notifications(user: str, enable: bool = False, ignore_permissions=False):
try:
settings = frappe.get_doc("Notification Settings", user)
except frappe.DoesNotExistError:
@ -79,7 +79,7 @@ def toggle_notifications(user: str, enable: bool = False):
if settings.enabled != enable:
settings.enabled = enable
settings.save()
settings.save(ignore_permissions=ignore_permissions)
@frappe.whitelist()