[cleanup] added unsubscribe to email digest
diff --git a/erpnext/setup/doctype/email_digest/email_digest.json b/erpnext/setup/doctype/email_digest/email_digest.json
index 5659cd9..6f37ae1 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 c367584..1dc3171 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -56,9 +56,14 @@
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 @@
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 @@
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 4b37774..460e8fa 100644
--- a/erpnext/setup/doctype/email_digest/templates/default.html
+++ b/erpnext/setup/doctype/email_digest/templates/default.html
@@ -88,10 +88,9 @@
<!-- notifications -->
{% if notifications %}
-<h4 style="{{ section_head }}">{{ _("Pending Activities") }}</h4>
+<h4 style="{{ section_head }}">{{ _("Open Notifications") }}</h4>
<div>
{% for n in notifications %}
- {% if n.value %}
<div style="{{ line_item }}">
<table style="width: 100%;">
<tr>
@@ -106,7 +105,6 @@
</tr>
</table>
</div>
- {% endif %}
{% endfor %}
</div>
{% endif %}