From 84ff4b2308be31f9a51d2c5c097a6a141aeb2cc8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 7 Mar 2014 22:19:58 +0530 Subject: [PATCH] clear cache on new comment --- frappe/core/doctype/comment/comment.py | 8 ++++++++ frappe/public/js/frappe/ui/toolbar/recent.js | 1 + frappe/templates/includes/comments.py | 4 +++- frappe/templates/includes/contact.js | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/comment/comment.py b/frappe/core/doctype/comment/comment.py index ce875e2606..145625131a 100644 --- a/frappe/core/doctype/comment/comment.py +++ b/frappe/core/doctype/comment/comment.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe, json +from frappe.website.render import clear_cache class DocType: def __init__(self, d, dl): @@ -53,6 +54,13 @@ class DocType: # use sql, so that we do not mess with the timestamp frappe.db.sql("""update `tab%s` set `_comments`=%s where name=%s""" % (self.doc.comment_doctype, "%s", "%s"), (json.dumps(_comments), self.doc.comment_docname)) + + # clear parent cache if route exists: + route = frappe.db.get_value("Website Route", {"ref_doctype": self.doc.comment_doctype, + "docname": self.doc.comment_docname}) + + if route: + clear_cache(route) def on_trash(self): _comments = self.get_comments_from_parent() diff --git a/frappe/public/js/frappe/ui/toolbar/recent.js b/frappe/public/js/frappe/ui/toolbar/recent.js index ea3b709aa1..fbba036535 100644 --- a/frappe/public/js/frappe/ui/toolbar/recent.js +++ b/frappe/public/js/frappe/ui/toolbar/recent.js @@ -48,6 +48,7 @@ frappe.ui.toolbar.RecentDocs = Class.extend({ }, setup: function() { // add menu items + if(!profile) return; var rlist = JSON.parse(profile.recent||"[]"); var m = rlist.length; diff --git a/frappe/templates/includes/comments.py b/frappe/templates/includes/comments.py index 4f1b3d5697..abb05a2c90 100644 --- a/frappe/templates/includes/comments.py +++ b/frappe/templates/includes/comments.py @@ -43,9 +43,11 @@ def add_comment(args=None): ifnull(unsubscribed, 0)=0""", (comment.doc.comment_doctype, comment.doc.comment_docname))] owner = frappe.db.get_value(comment.doc.comment_doctype, comment.doc.comment_docname, "owner") + recipients = commentors if owner=="Administrator" else list(set(commentors + [owner])) + from frappe.utils.email_lib.bulk import send - send(recipients=list(set(commentors + [owner])), + send(recipients=recipients, doctype='Comment', email_field='comment_by', subject='New Comment on %s: %s' % (comment.doc.comment_doctype, diff --git a/frappe/templates/includes/contact.js b/frappe/templates/includes/contact.js index 5aefb787b3..fa43e350ca 100644 --- a/frappe/templates/includes/contact.js +++ b/frappe/templates/includes/contact.js @@ -26,7 +26,7 @@ $(document).ready(function() { sender: email, message: message, callback: function(r) { - if(r.status==="okay") { + if(r.message==="okay") { msgprint(r.message || "Thank you for your message.") } else { msgprint("There were errors");