mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
blog comments fix, markdown and not sent multiple times
This commit is contained in:
@@ -87,18 +87,19 @@ def add_comment(args=None):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import webnotes
|
import webnotes
|
||||||
|
import webnotes.utils, markdown2
|
||||||
|
import webnotes.widgets.form.comments
|
||||||
|
import website.web_cache
|
||||||
|
|
||||||
if not args: args = webnotes.form_dict
|
if not args: args = webnotes.form_dict
|
||||||
|
args['comment'] = markdown2.markdown(args.get('comment') or '')
|
||||||
|
|
||||||
import webnotes.widgets.form.comments
|
|
||||||
comment = webnotes.widgets.form.comments.add_comment(args)
|
comment = webnotes.widgets.form.comments.add_comment(args)
|
||||||
|
|
||||||
# since comments are embedded in the page, clear the web cache
|
# since comments are embedded in the page, clear the web cache
|
||||||
import website.web_cache
|
|
||||||
website.web_cache.clear_cache(args.get('page_name'),
|
website.web_cache.clear_cache(args.get('page_name'),
|
||||||
args.get('comment_doctype'), args.get('comment_docname'))
|
args.get('comment_doctype'), args.get('comment_docname'))
|
||||||
|
|
||||||
import webnotes.utils
|
|
||||||
|
|
||||||
comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
|
comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
|
||||||
template_args = { 'comment_list': [comment], 'template': 'html/comment.html' }
|
template_args = { 'comment_list': [comment], 'template': 'html/comment.html' }
|
||||||
@@ -115,13 +116,13 @@ def add_comment(args=None):
|
|||||||
args.get('comment_docname'), as_dict=1)[0]
|
args.get('comment_docname'), as_dict=1)[0]
|
||||||
|
|
||||||
from webnotes.utils.email_lib.bulk import send
|
from webnotes.utils.email_lib.bulk import send
|
||||||
send(recipients=commentors + [blog['owner']],
|
send(recipients=list(set(commentors + [blog['owner']]),
|
||||||
doctype='Comment',
|
doctype='Comment',
|
||||||
email_field='comment_by',
|
email_field='comment_by',
|
||||||
first_name_field="comment_by_fullname",
|
first_name_field="comment_by_fullname",
|
||||||
last_name_field="NA",
|
last_name_field="NA",
|
||||||
subject='New Comment on Blog: ' + blog['title'],
|
subject='New Comment on Blog: ' + blog['title'],
|
||||||
message='<p>%(comment)s</p><p>By %(comment_by_fullname)s</p>' % args)
|
message='%(comment)s<p>By %(comment_by_fullname)s</p>' % args)
|
||||||
|
|
||||||
return comment_html
|
return comment_html
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user