@frappe.whitelist(allow_guest=True)
def add_comment(args=None):
 if (not args):
  args = frappe.local.form_dict
 route = args.get(u'route')
 doc = frappe.get_doc(args[u'reference_doctype'], args[u'reference_name'])
 comment = doc.add_comment(u'Comment', args[u'comment'], comment_by=args[u'comment_by'])
 comment.flags.ignore_permissions = True
 comment.sender_full_name = args[u'comment_by_fullname']
 comment.save()
 clear_cache(route)
 commentors = [d[0] for d in frappe.db.sql(u"select sender from `tabCommunication`\n DCTB  DCTB where\n DCTB  DCTB  DCTB communication_type = 'Comment' and comment_type = 'Comment'\n DCTB  DCTB  DCTB and reference_doctype=%s\n DCTB  DCTB  DCTB and reference_name=%s", (comment.reference_doctype, comment.reference_name))]
 owner = frappe.db.get_value(doc.doctype, doc.name, u'owner')
 recipients = list(set((commentors if (owner == u'Administrator') else (commentors + [owner]))))
 message = _(u'{0} by {1}').format(frappe.utils.markdown(args.get(u'comment')), comment.sender_full_name)
 message += u"<p><a href='{0}/{1}' style='font-size: 80%'>{2}</a></p>".format(frappe.utils.get_request_site_address(), route, _(u'View it in your browser'))
 from frappe.email.queue import send
 send(recipients=recipients, subject=_(u'New comment on {0} {1}').format(doc.doctype, doc.name), message=message, reference_doctype=doc.doctype, reference_name=doc.name)
 template = frappe.get_template(u'templates/includes/comments/comment.html')
 return template.render({u'comment': comment.as_dict()})

@ frappe . whitelist ( allow_guest = True ) def add_comment ( args = None ) : if ( not args ) : args = frappe . local . form_dict route = args . get ( u'route' ) doc = frappe . get_doc ( args [ u'reference_doctype' ] , args [ u'reference_name' ] ) comment = doc . add_comment ( u'Comment' , args [ u'comment' ] , comment_by = args [ u'comment_by' ] ) comment . flags . ignore_permissions = True comment . sender_full_name = args [ u'comment_by_fullname' ] comment . save ( ) clear_cache ( route ) commentors = [ d [ 0 ] for d in frappe . db . sql ( u"select sender from `tabCommunication`\n DCTB  DCTB where\n DCTB  DCTB  DCTB communication_type = 'Comment' and comment_type = 'Comment'\n DCTB  DCTB  DCTB and reference_doctype=%s\n DCTB  DCTB  DCTB and reference_name=%s" , ( comment . reference_doctype , comment . reference_name ) ) ] owner = frappe . db . get_value ( doc . doctype , doc . name , u'owner' ) recipients = list ( set ( ( commentors if ( owner == u'Administrator' ) else ( commentors + [ owner ] ) ) ) ) message = _ ( u'{0} by {1}' ) . format ( frappe . utils . markdown ( args . get ( u'comment' ) ) , comment . sender_full_name ) message += u"<p><a href='{0}/{1}' style='font-size: 80%'>{2}</a></p>" . format ( frappe . utils . get_request_site_address ( ) , route , _ ( u'View it in your browser' ) ) from frappe . email . queue import send send ( recipients = recipients , subject = _ ( u'New comment on {0} {1}' ) . format ( doc . doctype , doc . name ) , message = message , reference_doctype = doc . doctype , reference_name = doc . name ) template = frappe . get_template ( u'templates/includes/comments/comment.html' ) return template . render ( { u'comment' : comment . as_dict ( ) } )
allow any logged user to post a comment .