1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from mediagoblin
.tools
.mail
import send_email
18 from mediagoblin
.tools
.template
import render_template
19 from mediagoblin
.tools
.translate
import pass_to_ugettext
as _
20 from mediagoblin
import mg_globals
23 def send_comment_email(user
, comment
, media
, request
):
25 Sends comment email to user when a comment is made on their media.
28 - user: the user object to whom the email is sent
29 - comment: the comment object referencing user's media
30 - media: the media object the comment is about
31 - request: the request
34 comment_url
= request
.urlgen(
35 'mediagoblin.user_pages.media_home.view_comment',
37 user
=media
.get_uploader
.username
,
38 media
=media
.slug_or_id
,
39 qualified
=True) + '#comment'
41 comment_author
= comment
.get_author
.username
43 rendered_email
= render_template(
44 request
, 'mediagoblin/user_pages/comment_email.txt',
45 {'username': user
.username
,
46 'comment_author': comment_author
,
47 'comment_content': comment
.content
,
48 'comment_url': comment_url
})
51 mg_globals
.app_config
['email_sender_address'],
53 '{instance_title} - {comment_author} '.format(
54 comment_author
=comment_author
,
55 instance_title
=mg_globals
.app_config
['html_title']) \
56 + _('commented on your post'),