Removed option for adding subtitles for image etc
[mediagoblin.git] / mediagoblin / notifications / tools.py
CommitLineData
2d7b6bde
JW
1# GNU MediaGoblin -- federated, autonomous media hosting
2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3#
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.
8#
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.
13#
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/>.
16
17from mediagoblin.tools.template import render_template
18from mediagoblin.tools.translate import pass_to_ugettext as _
19from mediagoblin import mg_globals
20
6efcab2d 21def generate_comment_message(user, comment, commentee, request):
2d7b6bde
JW
22 """
23 Sends comment email to user when a comment is made on their media.
24
25 Args:
26 - user: the user object to whom the email is sent
6efcab2d
JT
27 - comment: the comment wrapper object
28 - commentee: the object the comment is on
2d7b6bde
JW
29 - request: the request
30 """
31
6efcab2d
JT
32 # Get the comment object associated to the wrapper
33 comment_object = comment.comment()
34
35 # Get the URL to the comment
2d7b6bde 36 comment_url = request.urlgen(
6efcab2d
JT
37 "mediagoblin.user_pages.media_home.view_comment",
38 comment=comment.id,
39 user=commentee.get_actor.username,
40 media=commentee.slug_or_id,
41 qualified=True) + "#comment"
2d7b6bde 42
6efcab2d 43 comment_author = comment.comment().get_actor.username
2d7b6bde
JW
44
45 rendered_email = render_template(
46 request, 'mediagoblin/user_pages/comment_email.txt',
47 {'username': user.username,
48 'comment_author': comment_author,
6efcab2d
JT
49 'comment_content': comment_object.content,
50 'comment_url': comment_url
51 }
52 )
2d7b6bde
JW
53
54 return {
55 'from': mg_globals.app_config['email_sender_address'],
56 'to': user.email,
57 'subject': '{instance_title} - {comment_author} '.format(
58 comment_author=comment_author,
59 instance_title=mg_globals.app_config['html_title']) \
60 + _('commented on your post'),
6efcab2d
JT
61 'body': rendered_email
62 }