From 80ca5fecade7e32feec9feb0e27f21b65a8dafb3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 30 Aug 2016 09:59:23 +0530 Subject: [PATCH] [minor] expire notification in popup note --- frappe/boot.py | 4 ++-- frappe/desk/doctype/note/note.json | 29 ++++++++++++++++++++++++++++- frappe/desk/doctype/note/note.py | 6 ++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index cb4d7db09a..4da78cc1ca 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -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) \ No newline at end of file + where nsb.parent=tabNote.name)''', (frappe.utils.now(), frappe.session.user), as_dict=True) \ No newline at end of file diff --git a/frappe/desk/doctype/note/note.json b/frappe/desk/doctype/note/note.json index b2d2bf2fc9..eb485d5371 100644 --- a/frappe/desk/doctype/note/note.json +++ b/frappe/desk/doctype/note/note.json @@ -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", diff --git a/frappe/desk/doctype/note/note.py b/frappe/desk/doctype/note/note.py index 5c86d0f582..cfe3fda052 100644 --- a/frappe/desk/doctype/note/note.py +++ b/frappe/desk/doctype/note/note.py @@ -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 = ""