fix(patch): create notification settings for all users
This commit is contained in:
parent
4bc4749d37
commit
d14ea23331
5 changed files with 22 additions and 19 deletions
|
|
@ -86,7 +86,7 @@
|
|||
}
|
||||
],
|
||||
"in_create": 1,
|
||||
"modified": "2019-11-14 11:55:09.198036",
|
||||
"modified": "2019-11-19 12:57:59.356786",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Notification Settings",
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ def is_email_notifications_enabled_for_type(user, notification_type):
|
|||
return enabled
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_notification_settings():
|
||||
def create_notification_settings(user):
|
||||
_doc = frappe.new_doc('Notification Settings')
|
||||
_doc.name = frappe.session.user
|
||||
_doc.name = user
|
||||
_doc.insert(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ frappe.patches.v12_0.move_email_and_phone_to_child_table
|
|||
frappe.patches.v12_0.delete_duplicate_indexes
|
||||
frappe.patches.v12_0.set_default_incoming_email_port
|
||||
frappe.patches.v12_0.update_global_search
|
||||
execute:frappe.reload_doc('desk', 'doctype', 'notification_settings')
|
||||
frappe.patches.v12_0.setup_tags
|
||||
frappe.patches.v12_0.update_auto_repeat_status_and_not_submittable
|
||||
frappe.patches.v12_0.copy_to_parent_for_tags
|
||||
frappe.patches.v12_0.create_notification_settings_for_user
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.desk.doctype.notification_settings.notification_settings import create_notification_settings
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('desk', 'doctype', 'notification_settings')
|
||||
|
||||
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)
|
||||
|
|
@ -35,24 +35,14 @@ frappe.ui.Notifications = class Notifications {
|
|||
frappe.search.utils.make_function_searchable(
|
||||
me.route_to_settings,
|
||||
__('Notification Settings'),
|
||||
[this.notifications_settings],
|
||||
);
|
||||
|
||||
this.setup_notifications();
|
||||
this.bind_events();
|
||||
}
|
||||
|
||||
route_to_settings(settings_doc) {
|
||||
let method =
|
||||
'frappe.desk.doctype.notification_settings.notification_settings.create_notification_settings';
|
||||
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
if (!settings_doc) return frappe.call(method);
|
||||
})
|
||||
.then(() => {
|
||||
frappe.set_route(`#Form/Notification Settings/${frappe.session.user}`);
|
||||
});
|
||||
route_to_settings() {
|
||||
frappe.set_route(`#Form/Notification Settings/${frappe.session.user}`);
|
||||
}
|
||||
|
||||
setup_notifications() {
|
||||
|
|
@ -375,7 +365,7 @@ frappe.ui.Notifications = class Notifications {
|
|||
let category_id = frappe.dom.get_unique_id();
|
||||
let settings_html =
|
||||
category.value === 'Notifications'
|
||||
? `<span class="notification-settings pull-right" data-action="make_and_route_to_settings">
|
||||
? `<span class="notification-settings pull-right" data-action="go_to_settings">
|
||||
${__('Settings')}
|
||||
</span>`
|
||||
: '';
|
||||
|
|
@ -417,11 +407,11 @@ frappe.ui.Notifications = class Notifications {
|
|||
);
|
||||
}
|
||||
|
||||
make_and_route_to_settings(e) {
|
||||
go_to_settings(e) {
|
||||
e.stopImmediatePropagation();
|
||||
this.$dropdown.removeClass('open');
|
||||
this.$dropdown.trigger('hide.bs.dropdown');
|
||||
this.route_to_settings(this.notifications_settings);
|
||||
this.route_to_settings();
|
||||
}
|
||||
|
||||
bind_events() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue