From a34eab214094d25db787f2076b6a2afc1bad89c4 Mon Sep 17 00:00:00 2001 From: Ranjith Kurungadam Date: Mon, 5 Nov 2018 12:27:21 +0530 Subject: [PATCH 1/3] Add Bcc in Notification (#6392) * Notification - add Bcc * remove Bcc from email header * feat: Bcc in Notification --- .../doctype/notification/notification.json | 2 +- .../doctype/notification/notification.py | 31 ++++++++++------ .../notification_recipient.json | 37 ++++++++++++++++++- frappe/email/email_body.py | 1 - 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/frappe/email/doctype/notification/notification.json b/frappe/email/doctype/notification/notification.json index 845af2b8f1..692feb08de 100644 --- a/frappe/email/doctype/notification/notification.json +++ b/frappe/email/doctype/notification/notification.json @@ -1124,7 +1124,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-08-29 14:32:02.179599", + "modified": "2018-10-05 14:32:02.179599", "modified_by": "Administrator", "module": "Email", "name": "Notification", diff --git a/frappe/email/doctype/notification/notification.py b/frappe/email/doctype/notification/notification.py index 4fb40b2694..a3f43f716d 100644 --- a/frappe/email/doctype/notification/notification.py +++ b/frappe/email/doctype/notification/notification.py @@ -133,14 +133,16 @@ def get_context(context): subject = frappe.render_template(self.subject, context) attachments = self.get_attachment(doc) - recipients = self.get_list_of_recipients(doc, context) + recipients, cc, bcc = self.get_list_of_recipients(doc, context) sender = None if self.sender and self.sender_email: sender = formataddr((self.sender, self.sender_email)) - - frappe.sendmail(recipients=recipients, subject=subject, - sender=sender, - message= frappe.render_template(self.message, context), + frappe.sendmail(recipients = recipients, + subject = subject, + sender = sender, + cc = cc, + bcc = bcc, + message = frappe.render_template(self.message, context), reference_doctype = doc.doctype, reference_name = doc.name, attachments = attachments, @@ -156,6 +158,8 @@ def get_context(context): def get_list_of_recipients(self, doc, context): recipients = [] + cc = [] + bcc = [] for recipient in self.recipients: if recipient.condition: if not frappe.safe_eval(recipient.condition, None, context): @@ -173,7 +177,14 @@ def get_context(context): if recipient.cc: recipient.cc = recipient.cc.replace(",", "\n") - recipients = recipients + recipient.cc.split("\n") + cc = cc + recipient.cc.split("\n") + + if recipient.bcc and "{" in recipient.bcc: + recipient.bcc = frappe.render_template(recipient.bcc, context) + + if recipient.bcc: + recipient.bcc = recipient.bcc.replace(",", "\n") + bcc = bcc + recipient.bcc.split("\n") #For sending emails to specified role if recipient.email_by_role: @@ -182,10 +193,9 @@ def get_context(context): for email in emails: recipients = recipients + email.split("\n") - if not recipients: - return - - return list(set(recipients)) + if not recipients and not cc and not bcc: + return None, None, None + return list(set(recipients)), list(set(cc)), list(set(bcc)) def get_attachment(self, doc): """ check print settings are attach the pdf """ @@ -285,7 +295,6 @@ def evaluate_alert(doc, alert, event): # reload the doc for the latest values & comments, # except for validate type event. doc = frappe.get_doc(doc.doctype, doc.name) - alert.send(doc) except TemplateError: frappe.throw(_("Error while evaluating Notification {0}. Please fix your template.").format(alert)) diff --git a/frappe/email/doctype/notification_recipient/notification_recipient.json b/frappe/email/doctype/notification_recipient/notification_recipient.json index e79af0cc99..ec35dccc63 100644 --- a/frappe/email/doctype/notification_recipient/notification_recipient.json +++ b/frappe/email/doctype/notification_recipient/notification_recipient.json @@ -110,6 +110,38 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "bcc", + "fieldtype": "Code", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "BCC", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -153,7 +185,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-05-31 15:44:44.161293", + "modified": "2018-09-03 18:37:57.043251", "modified_by": "Administrator", "module": "Email", "name": "Notification Recipient", @@ -167,5 +199,6 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 0, - "track_seen": 0 + "track_seen": 0, + "track_views": 0 } \ No newline at end of file diff --git a/frappe/email/email_body.py b/frappe/email/email_body.py index 8ab7ae5c85..f41e6d76c9 100755 --- a/frappe/email/email_body.py +++ b/frappe/email/email_body.py @@ -209,7 +209,6 @@ class EMail: "To": ', '.join(self.recipients) if self.expose_recipients=="header" else "", "Date": email.utils.formatdate(), "Reply-To": self.reply_to if self.reply_to else None, - "Bcc": ', '.join(self.bcc) if self.bcc else None, "CC": ', '.join(self.cc) if self.cc and self.expose_recipients=="header" else None, 'X-Frappe-Site': get_url(), } From fe334d2c926332ad0457aab15370fdf9ad7c1094 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 5 Nov 2018 17:07:21 +0530 Subject: [PATCH 2/3] fix(Quill): Add all quill attributes that are required to render it --- frappe/utils/html_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frappe/utils/html_utils.py b/frappe/utils/html_utils.py index fe06ec7c43..0336bfe54a 100644 --- a/frappe/utils/html_utils.py +++ b/frappe/utils/html_utils.py @@ -158,7 +158,9 @@ acceptable_attributes = [ 'step', 'style', 'summary', 'suppress', 'tabindex', 'target', 'template', 'title', 'toppadding', 'type', 'unselectable', 'usemap', 'urn', 'valign', 'value', 'variable', 'volume', 'vspace', 'vrml', - 'width', 'wrap', 'xml:lang', 'data-row' + 'width', 'wrap', 'xml:lang', 'data-row', 'data-list', 'data-language', + 'data-value', 'role', 'frameborder', 'allowfullscreen', 'spellcheck', + 'data-mode', 'data-gramm', 'data-placeholder' ] mathml_attributes = [ From 889f0a27443a135fbee24f847f30cbefcfd09701 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Mon, 5 Nov 2018 11:43:04 +0000 Subject: [PATCH 3/3] bumped to version 11.0.3-beta.21 --- frappe/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/hooks.py b/frappe/hooks.py index f38f8b1ad8..9247f337e2 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -12,7 +12,7 @@ source_link = "https://github.com/frappe/frappe" app_license = "MIT" develop_version = '11.x.x-develop' -staging_version = '11.0.3-beta.20' +staging_version = '11.0.3-beta.21' app_email = "info@frappe.io"