From 03ef14b231f0205ed37d2c98d114bf0548428716 Mon Sep 17 00:00:00 2001 From: prssanna Date: Wed, 20 May 2020 18:03:49 +0530 Subject: [PATCH 1/3] fix: include docname in notification email --- .../desk/doctype/notification_log/notification_log.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index 90c663ef19..007173e7a6 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -83,13 +83,14 @@ def send_notification_email(doc): doc_link = get_url_to_form(doc.document_type, doc.document_name) header = get_email_header(doc) email_subject = strip_html(doc.subject) + body_content = get_email_body_content(doc) frappe.sendmail( recipients = doc.for_user, subject = email_subject, template = "new_notification", args = { - 'body_content': doc.subject, + 'body_content': body_content, 'description': doc.email_content, 'document_type': doc.document_type, 'document_name': doc.document_name, @@ -99,6 +100,13 @@ def send_notification_email(doc): now=frappe.flags.in_test ) +def get_email_body_content(doc): + #include document name in email content + title_html = get_title_html(get_title(doc.document_type, doc.document_name)) + subject_parts = doc.subject.partition(title_html) + body_content = "{0}{1} ({2}){3}".format(subject_parts[0], subject_parts[1], doc.document_name, subject_parts[2]) + return body_content + def get_email_header(doc): return { 'Default': _('New Notification'), From 42a7ee190aeffce1402a9babdf676fe8496e1ebb Mon Sep 17 00:00:00 2001 From: prssanna Date: Tue, 26 May 2020 12:09:02 +0530 Subject: [PATCH 2/3] fix: fix notification email template --- frappe/templates/emails/new_notification.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/templates/emails/new_notification.html b/frappe/templates/emails/new_notification.html index fb1fc98901..4eea49a712 100644 --- a/frappe/templates/emails/new_notification.html +++ b/frappe/templates/emails/new_notification.html @@ -8,6 +8,5 @@ {% endif %} - From 92391c10e6e3fd2c96db027e985d98a9018fe387 Mon Sep 17 00:00:00 2001 From: prssanna Date: Wed, 27 May 2020 11:27:07 +0530 Subject: [PATCH 3/3] fix: include docname in email header --- .../notification_log/notification_log.py | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py index 007173e7a6..12f2c41274 100644 --- a/frappe/desk/doctype/notification_log/notification_log.py +++ b/frappe/desk/doctype/notification_log/notification_log.py @@ -83,14 +83,13 @@ def send_notification_email(doc): doc_link = get_url_to_form(doc.document_type, doc.document_name) header = get_email_header(doc) email_subject = strip_html(doc.subject) - body_content = get_email_body_content(doc) frappe.sendmail( recipients = doc.for_user, subject = email_subject, template = "new_notification", args = { - 'body_content': body_content, + 'body_content': doc.subject, 'description': doc.email_content, 'document_type': doc.document_type, 'document_name': doc.document_name, @@ -100,22 +99,17 @@ def send_notification_email(doc): now=frappe.flags.in_test ) -def get_email_body_content(doc): - #include document name in email content - title_html = get_title_html(get_title(doc.document_type, doc.document_name)) - subject_parts = doc.subject.partition(title_html) - body_content = "{0}{1} ({2}){3}".format(subject_parts[0], subject_parts[1], doc.document_name, subject_parts[2]) - return body_content - def get_email_header(doc): - return { + docname = doc.document_name + header_map = { 'Default': _('New Notification'), - 'Mention': _('New Mention'), - 'Assignment': _('Assignment Update'), - 'Share': _('New Document Shared'), - 'Energy Point': _('Energy Point Update'), - }[doc.type or 'Default'] + 'Mention': _('New Mention on {0}').format(docname), + 'Assignment': _('Assignment Update on {0}').format(docname), + 'Share': _('New Document Shared {0}').format(docname), + 'Energy Point': _('Energy Point Update on {0}').format(docname), + } + return header_map[doc.type or 'Default'] @frappe.whitelist() def mark_all_as_read():