Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

44 lignes
1.3 KiB

  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # License: GNU General Public License v3. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. def get_notification_config():
  6. return {
  7. "for_module_doctypes": {
  8. "ToDo": "To Do",
  9. "Event": "Calendar",
  10. "Comment": "Messages"
  11. },
  12. "for_module": {
  13. "To Do": "webnotes.core.notifications.get_things_todo",
  14. "Calendar": "webnotes.core.notifications.get_todays_events",
  15. "Messages": "webnotes.core.notifications.get_unread_messages"
  16. }
  17. }
  18. def get_things_todo():
  19. """Returns a count of incomplete todos"""
  20. incomplete_todos = webnotes.conn.sql("""\
  21. SELECT COUNT(*) FROM `tabToDo`
  22. WHERE status="Open"
  23. AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
  24. return incomplete_todos[0][0]
  25. def get_todays_events():
  26. """Returns a count of todays events in calendar"""
  27. from webnotes.core.doctype.event.event import get_events
  28. from webnotes.utils import nowdate
  29. today = nowdate()
  30. return len(get_events(today, today))
  31. def get_unread_messages():
  32. "returns unread (docstatus-0 messages for a user)"
  33. return webnotes.conn.sql("""\
  34. SELECT count(*)
  35. FROM `tabComment`
  36. WHERE comment_doctype IN ('My Company', 'Message')
  37. AND comment_docname = %s
  38. AND ifnull(docstatus,0)=0
  39. """, (webnotes.user.name,))[0][0]