fix: nable email for notification types
This commit is contained in:
parent
6905588e68
commit
446f7ec739
3 changed files with 40 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ import frappe
|
|||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.core.doctype.notification_settings.notification_settings import (is_notifications_enabled,
|
||||
is_email_notifications_enabled)
|
||||
is_email_notifications_enabled, is_email_notifications_enabled_for_type)
|
||||
|
||||
class NotificationLog(Document):
|
||||
|
||||
|
|
@ -48,6 +48,10 @@ def create_notification_log(names, doc, email_content = None):
|
|||
_doc.insert(ignore_permissions=True)
|
||||
|
||||
def send_notification_email(doc):
|
||||
is_type_enabled = is_email_notifications_enabled_for_type(doc.user, doc.type)
|
||||
if not is_type_enabled:
|
||||
return
|
||||
|
||||
from frappe.utils import get_url_to_form, strip_html, get_url
|
||||
|
||||
doc_link = get_url_to_form(doc.reference_doctype, doc.reference_name)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
"subscribed_documents",
|
||||
"column_break_3",
|
||||
"enable_email_notifications",
|
||||
"enable_email_mention",
|
||||
"enable_email_assignment",
|
||||
"enable_email_energy_point",
|
||||
"enable_email_doc_share",
|
||||
"user"
|
||||
],
|
||||
"fields": [
|
||||
|
|
@ -44,10 +48,33 @@
|
|||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Email Settings"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enable_email_mention",
|
||||
"fieldtype": "Check",
|
||||
"label": "Mention"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enable_email_assignment",
|
||||
"fieldtype": "Check",
|
||||
"label": "Assignment"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enable_email_energy_point",
|
||||
"fieldtype": "Check",
|
||||
"label": "Energy Point"
|
||||
},
|
||||
{
|
||||
"fieldname": "enable_email_doc_share",
|
||||
"fieldtype": "Data",
|
||||
"label": "Document Share"
|
||||
}
|
||||
],
|
||||
"in_create": 1,
|
||||
"modified": "2019-10-07 11:42:39.596589",
|
||||
"modified": "2019-10-07 12:57:35.130404",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Notification Settings",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@ def is_email_notifications_enabled(user):
|
|||
else:
|
||||
return True
|
||||
|
||||
def is_email_notifications_enabled_for_type(user, notification_type):
|
||||
type_field = 'enable_email_' + notification_type.lower()
|
||||
if frappe.db.count('Notification Settings', {'user': user}) > 0:
|
||||
return frappe.get_value('Notification Settings', {'user': user}, type_field)
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_notification_settings():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue