Fixed some comment notification code for compliance with SQL
* Pulled instance name in notification email from config
This commit is contained in:
parent
879ff4bde6
commit
00722c9908
@ -19,6 +19,7 @@ from mediagoblin.tools.template import render_template
|
|||||||
from mediagoblin.tools.translate import pass_to_ugettext as _
|
from mediagoblin.tools.translate import pass_to_ugettext as _
|
||||||
from mediagoblin import mg_globals
|
from mediagoblin import mg_globals
|
||||||
|
|
||||||
|
|
||||||
def send_comment_email(user, comment, media, request):
|
def send_comment_email(user, comment, media, request):
|
||||||
"""
|
"""
|
||||||
Sends comment email to user when a comment is made on their media.
|
Sends comment email to user when a comment is made on their media.
|
||||||
@ -32,23 +33,25 @@ def send_comment_email(user, comment, media, request):
|
|||||||
|
|
||||||
comment_url = request.urlgen(
|
comment_url = request.urlgen(
|
||||||
'mediagoblin.user_pages.media_home.view_comment',
|
'mediagoblin.user_pages.media_home.view_comment',
|
||||||
comment = comment._id,
|
comment=comment._id,
|
||||||
user = media.get_uploader.username,
|
user=media.get_uploader.username,
|
||||||
media = media.slug_or_id,
|
media=media.slug_or_id,
|
||||||
qualified = True) + '#comment'
|
qualified=True) + '#comment'
|
||||||
|
|
||||||
comment_author = comment.get_author['username']
|
comment_author = comment.get_author.username
|
||||||
|
|
||||||
rendered_email = render_template(
|
rendered_email = render_template(
|
||||||
request, 'mediagoblin/user_pages/comment_email.txt',
|
request, 'mediagoblin/user_pages/comment_email.txt',
|
||||||
{'username':user.username,
|
{'username': user.username,
|
||||||
'comment_author':comment_author,
|
'comment_author': comment_author,
|
||||||
'comment_content':comment.content,
|
'comment_content': comment.content,
|
||||||
'comment_url':comment_url})
|
'comment_url': comment_url})
|
||||||
|
|
||||||
send_email(
|
send_email(
|
||||||
mg_globals.app_config['email_sender_address'],
|
mg_globals.app_config['email_sender_address'],
|
||||||
[user.email],
|
[user.email],
|
||||||
'GNU MediaGoblin - {comment_author} '.format(
|
'{instance_title} - {comment_author} '.format(
|
||||||
comment_author=comment_author) + _('commented on your post'),
|
comment_author=comment_author,
|
||||||
|
instance_title=mg_globals.app_config['html_title']) \
|
||||||
|
+ _('commented on your post'),
|
||||||
rendered_email)
|
rendered_email)
|
||||||
|
@ -162,7 +162,7 @@ def media_post_comment(request, media):
|
|||||||
media_uploader = media.get_uploader
|
media_uploader = media.get_uploader
|
||||||
#don't send email if you comment on your own post
|
#don't send email if you comment on your own post
|
||||||
if (comment.author != media_uploader and
|
if (comment.author != media_uploader and
|
||||||
media_uploader['wants_comment_notification']):
|
media_uploader.wants_comment_notification):
|
||||||
send_comment_email(media_uploader, comment, media, request)
|
send_comment_email(media_uploader, comment, media, request)
|
||||||
|
|
||||||
return exc.HTTPFound(
|
return exc.HTTPFound(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user