fix: code cleanup
This commit is contained in:
parent
6f00c83e74
commit
7bf1e09327
4 changed files with 8 additions and 9 deletions
|
|
@ -48,8 +48,7 @@ class User(Document):
|
|||
throttle_user_creation()
|
||||
|
||||
def after_insert(self):
|
||||
if not frappe.db.exists("Notification Settings", self.name):
|
||||
create_notification_settings(self.name)
|
||||
create_notification_settings(self.name)
|
||||
|
||||
def validate(self):
|
||||
self.check_demo()
|
||||
|
|
@ -371,6 +370,7 @@ class User(Document):
|
|||
|
||||
if frappe.db.exists("Notification Settings", old_name):
|
||||
frappe.rename_doc("Notification Settings", old_name, new_name, force=True)
|
||||
|
||||
# set email
|
||||
frappe.db.sql("""UPDATE `tabUser`
|
||||
SET email = %s
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ def mark_all_as_read():
|
|||
filters = {'name': ['in', unread_docnames]}
|
||||
frappe.db.set_value('Notification Log', filters, 'read', 1, update_modified=False)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def mark_as_read(docname):
|
||||
if docname:
|
||||
|
|
|
|||
|
|
@ -32,10 +32,11 @@ def is_email_notifications_enabled_for_type(user, notification_type):
|
|||
return enabled
|
||||
|
||||
def create_notification_settings(user):
|
||||
_doc = frappe.new_doc('Notification Settings')
|
||||
_doc.name = user
|
||||
_doc.insert(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
if not frappe.db.exists("Notification Settings", user):
|
||||
_doc = frappe.new_doc('Notification Settings')
|
||||
_doc.name = user
|
||||
_doc.insert(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,4 @@ def execute():
|
|||
|
||||
users = frappe.db.get_all('User', fields=['name'])
|
||||
for user in users:
|
||||
if frappe.db.exists("Notification Settings", user.name):
|
||||
continue
|
||||
|
||||
create_notification_settings(user.name)
|
||||
Loading…
Add table
Reference in a new issue