@@ -59,6 +59,17 @@ def add_comment(doc): | |||||
return doc.as_dict() | return doc.as_dict() | ||||
@frappe.whitelist() | |||||
def update_comment(name, content): | |||||
"""allow only owner to update comment""" | |||||
doc = frappe.get_doc('Communication', name) | |||||
if frappe.session.user not in ['Administrator', doc.owner]: | |||||
frappe.throw(_('Comment can only be edited by the owner'), frappe.PermissionError) | |||||
doc.content = content | |||||
doc.save(ignore_permissions=True) | |||||
@frappe.whitelist() | @frappe.whitelist() | ||||
def get_next(doctype, value, prev, filters=None, order_by="modified desc"): | def get_next(doctype, value, prev, filters=None, order_by="modified desc"): | ||||
@@ -612,15 +612,10 @@ frappe.ui.form.Timeline = Class.extend({ | |||||
*/ | */ | ||||
update_comment: function(name, content) | update_comment: function(name, content) | ||||
{ | { | ||||
// TODO: is there a frappe.client.update function? | |||||
return frappe.call({ | return frappe.call({ | ||||
method: 'frappe.client.set_value', | |||||
args: { | |||||
doctype: 'Communication', | |||||
name: name, | |||||
fieldname: 'content', | |||||
value: content, | |||||
}, callback: function(r) { | |||||
method: 'frappe.desk.form.utils.update_comment', | |||||
args: { name, content }, | |||||
callback: function(r) { | |||||
if(!r.exc) { | if(!r.exc) { | ||||
frappe.utils.play_sound('click'); | frappe.utils.play_sound('click'); | ||||
} | } | ||||