@@ -168,6 +168,6 @@ def load_print_css(bootinfo, print_settings): | |||||
def get_unseen_notes(): | def get_unseen_notes(): | ||||
return frappe.db.sql('''select name, title, content from tabNote where notify_on_login=1 | 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 | (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) |
@@ -89,6 +89,33 @@ | |||||
"set_only_once": 0, | "set_only_once": 0, | ||||
"unique": 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, | "allow_on_submit": 0, | ||||
"bold": 1, | "bold": 1, | ||||
@@ -180,7 +207,7 @@ | |||||
"issingle": 0, | "issingle": 0, | ||||
"istable": 0, | "istable": 0, | ||||
"max_attachments": 0, | "max_attachments": 0, | ||||
"modified": "2016-08-29 06:00:27.360336", | |||||
"modified": "2016-08-30 00:28:57.094889", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Desk", | "module": "Desk", | ||||
"name": "Note", | "name": "Note", | ||||
@@ -11,6 +11,12 @@ class Note(Document): | |||||
import re | import re | ||||
self.name = re.sub("[%'\"#*?`]", "", self.title.strip()) | 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): | def before_print(self): | ||||
self.print_heading = self.name | self.print_heading = self.name | ||||
self.sub_heading = "" | self.sub_heading = "" | ||||