[minor] expire notification in popup note

This commit is contained in:
Rushabh Mehta 2016-08-30 09:59:23 +05:30
parent 05a1e55bf9
commit 80ca5fecad
3 changed files with 36 additions and 3 deletions

View file

@ -168,6 +168,6 @@ def load_print_css(bootinfo, print_settings):
def get_unseen_notes():
return frappe.db.sql('''select name, title, content from tabNote where notify_on_login=1
and %s not in
and expire_notification_on > %s and %s not in
(select user from `tabNote Seen By` nsb
where nsb.parent=tabNote.name)''', frappe.session.user, as_dict=True)
where nsb.parent=tabNote.name)''', (frappe.utils.now(), frappe.session.user), as_dict=True)

View file

@ -89,6 +89,33 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.notify_on_login && doc.public",
"fieldname": "expire_notification_on",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Expire Notification On",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 1,
@ -180,7 +207,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-08-29 06:00:27.360336",
"modified": "2016-08-30 00:28:57.094889",
"modified_by": "Administrator",
"module": "Desk",
"name": "Note",

View file

@ -11,6 +11,12 @@ class Note(Document):
import re
self.name = re.sub("[%'\"#*?`]", "", self.title.strip())
def validate(self):
if self.notify_on_login and not self.expire_notification_on:
# expire this notification in a week (default)
self.expire_notification_on = frappe.utils.add_days(self.creation, 7)
def before_print(self):
self.print_heading = self.name
self.sub_heading = ""