* Init workflow actions - WIP code - Add hooks to create and update workflow action on document status changes. - Tweak listview to show host document on list view item click - Add new doctype "Pending Workflow Action" - Add allow_self_approval check in Workflow master * Rename doctypes - Rename "Workflow Action" to "Workflow Action Master" - Rename "Pending Workflow Action" to "Workflow Action" - Remove irrelevant files * Clear old workflow action on docstatus change - Add check for user permission before creating a workflow action record - Make doctype changes to support the Workflow Action System * Show host document only if workflow action status is open * Send workflow action mail notifications * Add patch to rename `tabWorkflow Action` to `tab Workflow Master` - Rename table to retain data in `tabWorkflow Action` as it will be overwritten with new structure on migration * Enqueue email * Remove unused files * Add hook for custom has_permission * Optimize send_workflow_action_email method * Add permission_query_condition hook * Show notification based on status * Override get_form_link in list view * Refactor workflow action - Add action link - update workflow action hooks * Avoid repeated creation of Worklow Actions - Update hooks entry to avoid unwanted method call * Fix error with frappe.db.count usage * Fix ui/ux for Workflow Action - Fix action url and improve response on action button click - Fix workflow action template style * Fix Codacy * Add self approval check * Fix codacy * Fix test * Fix python version confilct and a permission error * Fix incorrect 'this' reference * Update with requested changes * Add next action email template option * Fix string formatting * Refactor workflow Action - Make process_workflow_action smaller * Fix bugs and errors due to refactor * Fix workflow field caching * Add a workflow action test * Fix bugs with email template
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
# MIT License. See license.txt
|
|
|
|
from __future__ import unicode_literals
|
|
import frappe
|
|
|
|
def get_notification_config():
|
|
return {
|
|
"for_doctype": {
|
|
"Error Log": {"seen": 0},
|
|
"Communication": {"status": "Open", "communication_type": "Communication"},
|
|
"ToDo": "frappe.core.notifications.get_things_todo",
|
|
"Event": "frappe.core.notifications.get_todays_events",
|
|
"Error Snapshot": {"seen": 0, "parent_error_snapshot": None},
|
|
"Workflow Action": {"status": 'Open'}
|
|
},
|
|
"for_other": {
|
|
"Likes": "frappe.core.notifications.get_unseen_likes",
|
|
"Email": "frappe.core.notifications.get_unread_emails",
|
|
}
|
|
}
|
|
|
|
def get_things_todo(as_list=False):
|
|
"""Returns a count of incomplete todos"""
|
|
data = frappe.get_list("ToDo",
|
|
fields=["name", "description"] if as_list else "count(*)",
|
|
filters=[["ToDo", "status", "=", "Open"]],
|
|
or_filters=[["ToDo", "owner", "=", frappe.session.user],
|
|
["ToDo", "assigned_by", "=", frappe.session.user]],
|
|
as_list=True)
|
|
|
|
if as_list:
|
|
return data
|
|
else:
|
|
return data[0][0]
|
|
|
|
def get_todays_events(as_list=False):
|
|
"""Returns a count of todays events in calendar"""
|
|
from frappe.desk.doctype.event.event import get_events
|
|
from frappe.utils import nowdate
|
|
today = nowdate()
|
|
events = get_events(today, today)
|
|
return events if as_list else len(events)
|
|
|
|
def get_unseen_likes():
|
|
"""Returns count of unseen likes"""
|
|
return frappe.db.sql("""select count(*) from `tabCommunication`
|
|
where
|
|
communication_type='Comment'
|
|
and modified >= DATE_SUB(NOW(),INTERVAL 1 YEAR)
|
|
and comment_type='Like'
|
|
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 sent_or_received="Received"
|
|
AND email_status not in ("Spam", "Trash")
|
|
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]
|