瀏覽代碼

[fix] clear notifications for user

version-14
Rushabh Mehta 8 年之前
父節點
當前提交
9484ea1af3
共有 2 個檔案被更改,包括 15 行新增10 行删除
  1. +12
    -10
      frappe/desk/notifications.py
  2. +3
    -0
      frappe/sessions.py

+ 12
- 10
frappe/desk/notifications.py 查看文件

@@ -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


+ 3
- 0
frappe/sessions.py 查看文件

@@ -18,6 +18,7 @@ import frappe.translate
from frappe.utils.change_log import get_change_log
import redis
from urllib import unquote
from frappe.desk.notifications import clear_notifications

@frappe.whitelist()
def clear(user=None):
@@ -45,6 +46,8 @@ def clear_cache(user=None):
clear_global_cache()
frappe.defaults.clear_cache()

clear_notifications(user)

def clear_global_cache():
frappe.model.meta.clear_cache()
frappe.cache().delete_value(["app_hooks", "installed_apps",


Loading…
取消
儲存