[minor] add unread email count in notification toolbar

This commit is contained in:
mbauskar 2017-03-12 22:46:46 +05:30
parent aa6c26bd7f
commit bdd45d538a
2 changed files with 17 additions and 0 deletions

View file

@ -16,6 +16,7 @@ def get_notification_config():
"for_other": {
"Likes": "frappe.core.notifications.get_unseen_likes",
"Chat": "frappe.core.notifications.get_unread_messages",
"Email": "frappe.core.notifications.get_unread_emails",
}
}
@ -63,3 +64,18 @@ def get_unseen_likes():
and owner is not null and owner!=%(user)s
and reference_owner=%(user)s
and seen=0""", {"user": frappe.session.user})[0][0]
def get_unread_emails():
"returns unread emails for a user"
return frappe.db.sql("""\
SELECT count(*)
FROM `tabCommunication`
WHERE communication_type='Communication'
AND communication_medium="Email"
AND email_account in (
SELECT distinct email_account from `tabUser Email` WHERE parent=%(user)s
)
AND modified >= DATE_SUB(NOW(),INTERVAL 1 YEAR)
AND seen=0
""", {"user": frappe.session.user})[0][0]

View file

@ -83,6 +83,7 @@ frappe.ui.notifications.config = {
"ToDo": { label: __("To Do") },
"Chat": { label: __("Chat"), route: "chat"},
"Event": { label: __("Calendar"), route: "List/Event/Calendar" },
"Email": { label: __("Email"), route: "List/Communication/Inbox" },
"Likes": {
label: __("Likes"),
click: function() {