diff --git a/frappe/build.py b/frappe/build.py index d65efc538a..b91f8e85e4 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -174,6 +174,10 @@ def files_dirty(): return False def compile_less(): + from distutils.spawn import find_executable + if not find_executable("lessc"): + return + for path in app_paths: less_path = os.path.join(path, "public", "less") if os.path.exists(less_path): @@ -189,4 +193,4 @@ def compile_less(): print "compiling {0}".format(fpath) css_path = os.path.join(path, "public", "css", fname.rsplit(".", 1)[0] + ".css") - os.system("which lessc && lessc {0} > {1}".format(fpath, css_path)) + os.system("lessc {0} > {1}".format(fpath, css_path)) diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index 6125464ed8..da81b7fe15 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -33,6 +33,16 @@ class Communication(Document): else: self.status = "Open" + def after_insert(self): + # send new comment to listening clients + comment = self.as_dict() + comment["comment"] = comment["content"] + comment["comment_by"] = comment["sender"] + comment["comment_type"] = comment["communication_medium"] + + frappe.publish_realtime('new_comment', comment, doctype = self.reference_doctype, + docname = self.reference_name) + def on_update(self): """Update parent status as `Open` or `Replied`.""" self.update_parent() @@ -49,7 +59,7 @@ class Communication(Document): to_status = "Open" if self.sent_or_received=="Received" else "Replied" if to_status in status_field.options.splitlines(): - frappe.db.set_value(parent.doctype, parent.name, "status", to_status) + parent.db_set("status", to_status) parent.notify_update() diff --git a/frappe/public/js/frappe/model/model.js b/frappe/public/js/frappe/model/model.js index 86105afc39..ac4d72f3e0 100644 --- a/frappe/public/js/frappe/model/model.js +++ b/frappe/public/js/frappe/model/model.js @@ -154,10 +154,11 @@ $.extend(frappe.model, { }, new_comment: function(comment) { - if (frappe.model.docinfo[comment.comment_doctype] - && frappe.model.docinfo[comment.comment_doctype][comment.comment_docname]) { - var comments = frappe.model.docinfo[comment.comment_doctype][comment.comment_docname].comments; + var reference_doctype = comment.comment_doctype || comment.reference_doctype; + var reference_name = comment.comment_docname || comment.reference_name; + if (frappe.model.docinfo[reference_doctype] && frappe.model.docinfo[reference_doctype][reference_name]) { + var comments = frappe.model.docinfo[reference_doctype][reference_name].comments; var comment_exists = false; for (var i=0, l=comments.length; i