|
|
@@ -17,6 +17,7 @@ def get_notifications(): |
|
|
|
cache = frappe.cache() |
|
|
|
|
|
|
|
notification_count = {} |
|
|
|
|
|
|
|
for name in groups: |
|
|
|
count = cache.hget("notification_count:" + name, frappe.session.user) |
|
|
|
if count is not None: |
|
|
@@ -108,12 +109,16 @@ def get_notifications_for_doctypes(config, notification_count): |
|
|
|
|
|
|
|
return open_count_doctype |
|
|
|
|
|
|
|
def clear_notifications(user="*"): |
|
|
|
if user=="*": |
|
|
|
frappe.cache().delete_keys("notification_count:") |
|
|
|
else: |
|
|
|
# delete count for user |
|
|
|
frappe.cache().hdel_keys("notification_count:", user) |
|
|
|
def clear_notifications(user=None): |
|
|
|
config = get_notification_config() |
|
|
|
groups = config.get("for_doctype").keys() + config.get("for_module").keys() |
|
|
|
cache = frappe.cache() |
|
|
|
|
|
|
|
for name in groups: |
|
|
|
if user: |
|
|
|
cache.hdel("notification_count:" + name, user) |
|
|
|
else: |
|
|
|
cache.delete_key("notification_count:" + name) |
|
|
|
|
|
|
|
def delete_notification_count_for(doctype): |
|
|
|
frappe.cache().delete_key("notification_count:" + doctype) |
|
|
@@ -126,9 +131,6 @@ def clear_doctype_notifications(doc, method=None, *args, **kwargs): |
|
|
|
delete_notification_count_for(doctype) |
|
|
|
return |
|
|
|
|
|
|
|
if doctype in config.for_module_doctypes: |
|
|
|
delete_notification_count_for(config.for_module_doctypes[doctype]) |
|
|
|
|
|
|
|
def get_notification_info_for_boot(): |
|
|
|
out = get_notifications() |
|
|
|
config = get_notification_config() |
|
|
@@ -156,7 +158,7 @@ def get_notification_config(): |
|
|
|
config = frappe._dict() |
|
|
|
for notification_config in frappe.get_hooks().notification_config: |
|
|
|
nc = frappe.get_attr(notification_config)() |
|
|
|
for key in ("for_doctype", "for_module", "for_module_doctypes", "for_other"): |
|
|
|
for key in ("for_doctype", "for_module", "for_other"): |
|
|
|
config.setdefault(key, {}) |
|
|
|
config[key].update(nc.get(key, {})) |
|
|
|
return config |
|
|
|