From 73f1dc4edf268ae44aef6f0134ebdbec17c76c18 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 2 Oct 2015 17:02:20 +0530 Subject: [PATCH] [cleanup] added unsubscribe to email digest --- .../setup/doctype/email_digest/email_digest.json | 8 ++++---- erpnext/setup/doctype/email_digest/email_digest.py | 14 +++++++++++--- .../doctype/email_digest/templates/default.html | 4 +--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.json b/erpnext/setup/doctype/email_digest/email_digest.json index 5659cd90ac0..6f37ae1c890 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.json +++ b/erpnext/setup/doctype/email_digest/email_digest.json @@ -247,7 +247,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "Income booked for the digest period", + "description": "", "fieldname": "income", "fieldtype": "Check", "hidden": 0, @@ -269,7 +269,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "Expenses booked for the digest period", + "description": "", "fieldname": "expenses_booked", "fieldtype": "Check", "hidden": 0, @@ -291,7 +291,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "description": "Balances of Accounts of type \"Bank\" or \"Cash\"", + "description": "", "fieldname": "bank_balance", "fieldtype": "Check", "hidden": 0, @@ -428,7 +428,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-10-02 07:07:25.518002", + "modified": "2015-10-02 07:33:27.334888", "modified_by": "Administrator", "module": "Setup", "name": "Email Digest", diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index c367584d796..1dc317132bf 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -56,9 +56,14 @@ class EmailDigest(Document): frappe.set_user(user_id) msg_for_this_receipient = self.get_msg_html() if msg_for_this_receipient: - frappe.sendmail(recipients=user_id, + frappe.sendmail( + recipients=user_id, subject="{frequency} Digest".format(frequency=self.frequency), - message=msg_for_this_receipient, bulk=True) + message=msg_for_this_receipient, + bulk=True, + reference_doctype = self.doctype, + reference_name = self.name, + unsubscribe_message = _("Unsubscribe from this Email Digest")) frappe.set_user(original_user) @@ -76,6 +81,9 @@ class EmailDigest(Document): context.todo_list = self.get_todo_list() context.notifications = self.get_notifications() + if not (context.events or context.todo_list or context.notifications or context.cards): + return None + # style return frappe.render_template("erpnext/setup/doctype/email_digest/templates/default.html", context, is_path=True) @@ -110,7 +118,7 @@ class EmailDigest(Document): lambda a, b: 1 if a[1] < b[1] else -1) notifications = [{"key": n[0], "value": n[1], - "link": get_url_to_list(n[0])} for n in notifications] + "link": get_url_to_list(n[0])} for n in notifications if n[1]] return notifications diff --git a/erpnext/setup/doctype/email_digest/templates/default.html b/erpnext/setup/doctype/email_digest/templates/default.html index 4b377742e56..460e8fa2a35 100644 --- a/erpnext/setup/doctype/email_digest/templates/default.html +++ b/erpnext/setup/doctype/email_digest/templates/default.html @@ -88,10 +88,9 @@ {% if notifications %} -

{{ _("Pending Activities") }}

+

{{ _("Open Notifications") }}

{% for n in notifications %} - {% if n.value %}
@@ -106,7 +105,6 @@
- {% endif %} {% endfor %}
{% endif %}