##// END OF EJS Templates
comments: update comments email templates....
marcink -
r3120:646ada6a default
parent child Browse files
Show More
@@ -1,313 +1,314 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2018 RhodeCode GmbH
3 # Copyright (C) 2010-2018 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
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/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import pytest
21 import pytest
22
22
23 from rhodecode.tests import TestController
23 from rhodecode.tests import TestController
24
24
25 from rhodecode.model.db import (
25 from rhodecode.model.db import (
26 ChangesetComment, Notification, UserNotification)
26 ChangesetComment, Notification, UserNotification)
27 from rhodecode.model.meta import Session
27 from rhodecode.model.meta import Session
28 from rhodecode.lib import helpers as h
28 from rhodecode.lib import helpers as h
29
29
30
30
31 def route_path(name, params=None, **kwargs):
31 def route_path(name, params=None, **kwargs):
32 import urllib
32 import urllib
33
33
34 base_url = {
34 base_url = {
35 'repo_commit': '/{repo_name}/changeset/{commit_id}',
35 'repo_commit': '/{repo_name}/changeset/{commit_id}',
36 'repo_commit_comment_create': '/{repo_name}/changeset/{commit_id}/comment/create',
36 'repo_commit_comment_create': '/{repo_name}/changeset/{commit_id}/comment/create',
37 'repo_commit_comment_preview': '/{repo_name}/changeset/{commit_id}/comment/preview',
37 'repo_commit_comment_preview': '/{repo_name}/changeset/{commit_id}/comment/preview',
38 'repo_commit_comment_delete': '/{repo_name}/changeset/{commit_id}/comment/{comment_id}/delete',
38 'repo_commit_comment_delete': '/{repo_name}/changeset/{commit_id}/comment/{comment_id}/delete',
39 }[name].format(**kwargs)
39 }[name].format(**kwargs)
40
40
41 if params:
41 if params:
42 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
42 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
43 return base_url
43 return base_url
44
44
45
45
46 @pytest.mark.backends("git", "hg", "svn")
46 @pytest.mark.backends("git", "hg", "svn")
47 class TestRepoCommitCommentsView(TestController):
47 class TestRepoCommitCommentsView(TestController):
48
48
49 @pytest.fixture(autouse=True)
49 @pytest.fixture(autouse=True)
50 def prepare(self, request, baseapp):
50 def prepare(self, request, baseapp):
51 for x in ChangesetComment.query().all():
51 for x in ChangesetComment.query().all():
52 Session().delete(x)
52 Session().delete(x)
53 Session().commit()
53 Session().commit()
54
54
55 for x in Notification.query().all():
55 for x in Notification.query().all():
56 Session().delete(x)
56 Session().delete(x)
57 Session().commit()
57 Session().commit()
58
58
59 request.addfinalizer(self.cleanup)
59 request.addfinalizer(self.cleanup)
60
60
61 def cleanup(self):
61 def cleanup(self):
62 for x in ChangesetComment.query().all():
62 for x in ChangesetComment.query().all():
63 Session().delete(x)
63 Session().delete(x)
64 Session().commit()
64 Session().commit()
65
65
66 for x in Notification.query().all():
66 for x in Notification.query().all():
67 Session().delete(x)
67 Session().delete(x)
68 Session().commit()
68 Session().commit()
69
69
70 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
70 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
71 def test_create(self, comment_type, backend):
71 def test_create(self, comment_type, backend):
72 self.log_user()
72 self.log_user()
73 commit = backend.repo.get_commit('300')
73 commit = backend.repo.get_commit('300')
74 commit_id = commit.raw_id
74 commit_id = commit.raw_id
75 text = u'CommentOnCommit'
75 text = u'CommentOnCommit'
76
76
77 params = {'text': text, 'csrf_token': self.csrf_token,
77 params = {'text': text, 'csrf_token': self.csrf_token,
78 'comment_type': comment_type}
78 'comment_type': comment_type}
79 self.app.post(
79 self.app.post(
80 route_path('repo_commit_comment_create',
80 route_path('repo_commit_comment_create',
81 repo_name=backend.repo_name, commit_id=commit_id),
81 repo_name=backend.repo_name, commit_id=commit_id),
82 params=params)
82 params=params)
83
83
84 response = self.app.get(
84 response = self.app.get(
85 route_path('repo_commit',
85 route_path('repo_commit',
86 repo_name=backend.repo_name, commit_id=commit_id))
86 repo_name=backend.repo_name, commit_id=commit_id))
87
87
88 # test DB
88 # test DB
89 assert ChangesetComment.query().count() == 1
89 assert ChangesetComment.query().count() == 1
90 assert_comment_links(response, ChangesetComment.query().count(), 0)
90 assert_comment_links(response, ChangesetComment.query().count(), 0)
91
91
92 assert Notification.query().count() == 1
92 assert Notification.query().count() == 1
93 assert ChangesetComment.query().count() == 1
93 assert ChangesetComment.query().count() == 1
94
94
95 notification = Notification.query().all()[0]
95 notification = Notification.query().all()[0]
96
96
97 comment_id = ChangesetComment.query().first().comment_id
97 comment_id = ChangesetComment.query().first().comment_id
98 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
98 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
99
99
100 sbj = 'left {0} on commit `{1}` in the {2} repository'.format(
100 author = notification.created_by_user.username_and_name
101 comment_type, h.show_id(commit), backend.repo_name)
101 sbj = '{0} left a {1} on commit `{2}` in the {3} repository'.format(
102 assert sbj in notification.subject
102 author, comment_type, h.show_id(commit), backend.repo_name)
103 assert sbj == notification.subject
103
104
104 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
105 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
105 backend.repo_name, commit_id, comment_id))
106 backend.repo_name, commit_id, comment_id))
106 assert lnk in notification.body
107 assert lnk in notification.body
107
108
108 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
109 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
109 def test_create_inline(self, comment_type, backend):
110 def test_create_inline(self, comment_type, backend):
110 self.log_user()
111 self.log_user()
111 commit = backend.repo.get_commit('300')
112 commit = backend.repo.get_commit('300')
112 commit_id = commit.raw_id
113 commit_id = commit.raw_id
113 text = u'CommentOnCommit'
114 text = u'CommentOnCommit'
114 f_path = 'vcs/web/simplevcs/views/repository.py'
115 f_path = 'vcs/web/simplevcs/views/repository.py'
115 line = 'n1'
116 line = 'n1'
116
117
117 params = {'text': text, 'f_path': f_path, 'line': line,
118 params = {'text': text, 'f_path': f_path, 'line': line,
118 'comment_type': comment_type,
119 'comment_type': comment_type,
119 'csrf_token': self.csrf_token}
120 'csrf_token': self.csrf_token}
120
121
121 self.app.post(
122 self.app.post(
122 route_path('repo_commit_comment_create',
123 route_path('repo_commit_comment_create',
123 repo_name=backend.repo_name, commit_id=commit_id),
124 repo_name=backend.repo_name, commit_id=commit_id),
124 params=params)
125 params=params)
125
126
126 response = self.app.get(
127 response = self.app.get(
127 route_path('repo_commit',
128 route_path('repo_commit',
128 repo_name=backend.repo_name, commit_id=commit_id))
129 repo_name=backend.repo_name, commit_id=commit_id))
129
130
130 # test DB
131 # test DB
131 assert ChangesetComment.query().count() == 1
132 assert ChangesetComment.query().count() == 1
132 assert_comment_links(response, 0, ChangesetComment.query().count())
133 assert_comment_links(response, 0, ChangesetComment.query().count())
133
134
134 if backend.alias == 'svn':
135 if backend.alias == 'svn':
135 response.mustcontain(
136 response.mustcontain(
136 '''data-f-path="vcs/commands/summary.py" '''
137 '''data-f-path="vcs/commands/summary.py" '''
137 '''id="a_c--ad05457a43f8"'''
138 '''id="a_c--ad05457a43f8"'''
138 )
139 )
139 else:
140 else:
140 response.mustcontain(
141 response.mustcontain(
141 '''data-f-path="vcs/backends/hg.py" '''
142 '''data-f-path="vcs/backends/hg.py" '''
142 '''id="a_c--9c390eb52cd6"'''
143 '''id="a_c--9c390eb52cd6"'''
143 )
144 )
144
145
145 assert Notification.query().count() == 1
146 assert Notification.query().count() == 1
146 assert ChangesetComment.query().count() == 1
147 assert ChangesetComment.query().count() == 1
147
148
148 notification = Notification.query().all()[0]
149 notification = Notification.query().all()[0]
149 comment = ChangesetComment.query().first()
150 comment = ChangesetComment.query().first()
150 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
151 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
151
152
152 assert comment.revision == commit_id
153 assert comment.revision == commit_id
153 sbj = 'left {comment_type} on commit `{commit}` ' \
154
154 '(file: `{f_path}`) in the {repo} repository'.format(
155 author = notification.created_by_user.username_and_name
155 commit=h.show_id(commit),
156 sbj = '{0} left a {1} on file `{2}` in commit `{3}` in the {4} repository'.format(
156 f_path=f_path, line=line, repo=backend.repo_name,
157 author, comment_type, f_path, h.show_id(commit), backend.repo_name)
157 comment_type=comment_type)
158
158 assert sbj in notification.subject
159 assert sbj == notification.subject
159
160
160 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
161 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
161 backend.repo_name, commit_id, comment.comment_id))
162 backend.repo_name, commit_id, comment.comment_id))
162 assert lnk in notification.body
163 assert lnk in notification.body
163 assert 'on line n1' in notification.body
164 assert 'on line n1' in notification.body
164
165
165 def test_create_with_mention(self, backend):
166 def test_create_with_mention(self, backend):
166 self.log_user()
167 self.log_user()
167
168
168 commit_id = backend.repo.get_commit('300').raw_id
169 commit_id = backend.repo.get_commit('300').raw_id
169 text = u'@test_regular check CommentOnCommit'
170 text = u'@test_regular check CommentOnCommit'
170
171
171 params = {'text': text, 'csrf_token': self.csrf_token}
172 params = {'text': text, 'csrf_token': self.csrf_token}
172 self.app.post(
173 self.app.post(
173 route_path('repo_commit_comment_create',
174 route_path('repo_commit_comment_create',
174 repo_name=backend.repo_name, commit_id=commit_id),
175 repo_name=backend.repo_name, commit_id=commit_id),
175 params=params)
176 params=params)
176
177
177 response = self.app.get(
178 response = self.app.get(
178 route_path('repo_commit',
179 route_path('repo_commit',
179 repo_name=backend.repo_name, commit_id=commit_id))
180 repo_name=backend.repo_name, commit_id=commit_id))
180 # test DB
181 # test DB
181 assert ChangesetComment.query().count() == 1
182 assert ChangesetComment.query().count() == 1
182 assert_comment_links(response, ChangesetComment.query().count(), 0)
183 assert_comment_links(response, ChangesetComment.query().count(), 0)
183
184
184 notification = Notification.query().one()
185 notification = Notification.query().one()
185
186
186 assert len(notification.recipients) == 2
187 assert len(notification.recipients) == 2
187 users = [x.username for x in notification.recipients]
188 users = [x.username for x in notification.recipients]
188
189
189 # test_regular gets notification by @mention
190 # test_regular gets notification by @mention
190 assert sorted(users) == [u'test_admin', u'test_regular']
191 assert sorted(users) == [u'test_admin', u'test_regular']
191
192
192 def test_create_with_status_change(self, backend):
193 def test_create_with_status_change(self, backend):
193 self.log_user()
194 self.log_user()
194 commit = backend.repo.get_commit('300')
195 commit = backend.repo.get_commit('300')
195 commit_id = commit.raw_id
196 commit_id = commit.raw_id
196 text = u'CommentOnCommit'
197 text = u'CommentOnCommit'
197 f_path = 'vcs/web/simplevcs/views/repository.py'
198 f_path = 'vcs/web/simplevcs/views/repository.py'
198 line = 'n1'
199 line = 'n1'
199
200
200 params = {'text': text, 'changeset_status': 'approved',
201 params = {'text': text, 'changeset_status': 'approved',
201 'csrf_token': self.csrf_token}
202 'csrf_token': self.csrf_token}
202
203
203 self.app.post(
204 self.app.post(
204 route_path(
205 route_path(
205 'repo_commit_comment_create',
206 'repo_commit_comment_create',
206 repo_name=backend.repo_name, commit_id=commit_id),
207 repo_name=backend.repo_name, commit_id=commit_id),
207 params=params)
208 params=params)
208
209
209 response = self.app.get(
210 response = self.app.get(
210 route_path('repo_commit',
211 route_path('repo_commit',
211 repo_name=backend.repo_name, commit_id=commit_id))
212 repo_name=backend.repo_name, commit_id=commit_id))
212
213
213 # test DB
214 # test DB
214 assert ChangesetComment.query().count() == 1
215 assert ChangesetComment.query().count() == 1
215 assert_comment_links(response, ChangesetComment.query().count(), 0)
216 assert_comment_links(response, ChangesetComment.query().count(), 0)
216
217
217 assert Notification.query().count() == 1
218 assert Notification.query().count() == 1
218 assert ChangesetComment.query().count() == 1
219 assert ChangesetComment.query().count() == 1
219
220
220 notification = Notification.query().all()[0]
221 notification = Notification.query().all()[0]
221
222
222 comment_id = ChangesetComment.query().first().comment_id
223 comment_id = ChangesetComment.query().first().comment_id
223 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
224 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
224
225
225 sbj = 'left note on commit `{0}` (status: Approved) ' \
226 author = notification.created_by_user.username_and_name
226 'in the {1} repository'.format(
227 sbj = '[status: Approved] {0} left a note on commit `{1}` in the {2} repository'.format(
227 h.show_id(commit), backend.repo_name)
228 author, h.show_id(commit), backend.repo_name)
228 assert sbj in notification.subject
229 assert sbj == notification.subject
229
230
230 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
231 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
231 backend.repo_name, commit_id, comment_id))
232 backend.repo_name, commit_id, comment_id))
232 assert lnk in notification.body
233 assert lnk in notification.body
233
234
234 def test_delete(self, backend):
235 def test_delete(self, backend):
235 self.log_user()
236 self.log_user()
236 commit_id = backend.repo.get_commit('300').raw_id
237 commit_id = backend.repo.get_commit('300').raw_id
237 text = u'CommentOnCommit'
238 text = u'CommentOnCommit'
238
239
239 params = {'text': text, 'csrf_token': self.csrf_token}
240 params = {'text': text, 'csrf_token': self.csrf_token}
240 self.app.post(
241 self.app.post(
241 route_path(
242 route_path(
242 'repo_commit_comment_create',
243 'repo_commit_comment_create',
243 repo_name=backend.repo_name, commit_id=commit_id),
244 repo_name=backend.repo_name, commit_id=commit_id),
244 params=params)
245 params=params)
245
246
246 comments = ChangesetComment.query().all()
247 comments = ChangesetComment.query().all()
247 assert len(comments) == 1
248 assert len(comments) == 1
248 comment_id = comments[0].comment_id
249 comment_id = comments[0].comment_id
249
250
250 self.app.post(
251 self.app.post(
251 route_path('repo_commit_comment_delete',
252 route_path('repo_commit_comment_delete',
252 repo_name=backend.repo_name,
253 repo_name=backend.repo_name,
253 commit_id=commit_id,
254 commit_id=commit_id,
254 comment_id=comment_id),
255 comment_id=comment_id),
255 params={'csrf_token': self.csrf_token})
256 params={'csrf_token': self.csrf_token})
256
257
257 comments = ChangesetComment.query().all()
258 comments = ChangesetComment.query().all()
258 assert len(comments) == 0
259 assert len(comments) == 0
259
260
260 response = self.app.get(
261 response = self.app.get(
261 route_path('repo_commit',
262 route_path('repo_commit',
262 repo_name=backend.repo_name, commit_id=commit_id))
263 repo_name=backend.repo_name, commit_id=commit_id))
263 assert_comment_links(response, 0, 0)
264 assert_comment_links(response, 0, 0)
264
265
265 @pytest.mark.parametrize('renderer, input, output', [
266 @pytest.mark.parametrize('renderer, input, output', [
266 ('rst', 'plain text', '<p>plain text</p>'),
267 ('rst', 'plain text', '<p>plain text</p>'),
267 ('rst', 'header\n======', '<h1 class="title">header</h1>'),
268 ('rst', 'header\n======', '<h1 class="title">header</h1>'),
268 ('rst', '*italics*', '<em>italics</em>'),
269 ('rst', '*italics*', '<em>italics</em>'),
269 ('rst', '**bold**', '<strong>bold</strong>'),
270 ('rst', '**bold**', '<strong>bold</strong>'),
270 ('markdown', 'plain text', '<p>plain text</p>'),
271 ('markdown', 'plain text', '<p>plain text</p>'),
271 ('markdown', '# header', '<h1>header</h1>'),
272 ('markdown', '# header', '<h1>header</h1>'),
272 ('markdown', '*italics*', '<em>italics</em>'),
273 ('markdown', '*italics*', '<em>italics</em>'),
273 ('markdown', '**bold**', '<strong>bold</strong>'),
274 ('markdown', '**bold**', '<strong>bold</strong>'),
274 ], ids=['rst-plain', 'rst-header', 'rst-italics', 'rst-bold', 'md-plain',
275 ], ids=['rst-plain', 'rst-header', 'rst-italics', 'rst-bold', 'md-plain',
275 'md-header', 'md-italics', 'md-bold', ])
276 'md-header', 'md-italics', 'md-bold', ])
276 def test_preview(self, renderer, input, output, backend, xhr_header):
277 def test_preview(self, renderer, input, output, backend, xhr_header):
277 self.log_user()
278 self.log_user()
278 params = {
279 params = {
279 'renderer': renderer,
280 'renderer': renderer,
280 'text': input,
281 'text': input,
281 'csrf_token': self.csrf_token
282 'csrf_token': self.csrf_token
282 }
283 }
283 commit_id = '0' * 16 # fake this for tests
284 commit_id = '0' * 16 # fake this for tests
284 response = self.app.post(
285 response = self.app.post(
285 route_path('repo_commit_comment_preview',
286 route_path('repo_commit_comment_preview',
286 repo_name=backend.repo_name, commit_id=commit_id,),
287 repo_name=backend.repo_name, commit_id=commit_id,),
287 params=params,
288 params=params,
288 extra_environ=xhr_header)
289 extra_environ=xhr_header)
289
290
290 response.mustcontain(output)
291 response.mustcontain(output)
291
292
292
293
293 def assert_comment_links(response, comments, inline_comments):
294 def assert_comment_links(response, comments, inline_comments):
294 if comments == 1:
295 if comments == 1:
295 comments_text = "%d Commit comment" % comments
296 comments_text = "%d Commit comment" % comments
296 else:
297 else:
297 comments_text = "%d Commit comments" % comments
298 comments_text = "%d Commit comments" % comments
298
299
299 if inline_comments == 1:
300 if inline_comments == 1:
300 inline_comments_text = "%d Inline Comment" % inline_comments
301 inline_comments_text = "%d Inline Comment" % inline_comments
301 else:
302 else:
302 inline_comments_text = "%d Inline Comments" % inline_comments
303 inline_comments_text = "%d Inline Comments" % inline_comments
303
304
304 if comments:
305 if comments:
305 response.mustcontain('<a href="#comments">%s</a>,' % comments_text)
306 response.mustcontain('<a href="#comments">%s</a>,' % comments_text)
306 else:
307 else:
307 response.mustcontain(comments_text)
308 response.mustcontain(comments_text)
308
309
309 if inline_comments:
310 if inline_comments:
310 response.mustcontain(
311 response.mustcontain(
311 'id="inline-comments-counter">%s</' % inline_comments_text)
312 'id="inline-comments-counter">%s</' % inline_comments_text)
312 else:
313 else:
313 response.mustcontain(inline_comments_text)
314 response.mustcontain(inline_comments_text)
@@ -1,105 +1,108 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="base.mako"/>
2 <%inherit file="base.mako"/>
3 <%namespace name="base" file="base.mako"/>
3 <%namespace name="base" file="base.mako"/>
4
4
5 ## EMAIL SUBJECT
5 ## EMAIL SUBJECT
6 <%def name="subject()" filter="n,trim,whitespace_filter">
6 <%def name="subject()" filter="n,trim,whitespace_filter">
7 <%
7 <%
8 data = {
8 data = {
9 'user': h.person(user),
9 'user': h.person(user),
10 'repo_name': repo_name,
10 'repo_name': repo_name,
11 'commit_id': h.show_id(commit),
11 'commit_id': h.show_id(commit),
12 'status': status_change,
12 'status': status_change,
13 'comment_file': comment_file,
13 'comment_file': comment_file,
14 'comment_line': comment_line,
14 'comment_line': comment_line,
15 'comment_type': comment_type,
15 'comment_type': comment_type,
16 }
16 }
17 %>
17 %>
18 ${_('[mention]') if mention else ''} \
18 ${_('[mention]') if mention else ''} \
19
19
20 % if comment_file:
20 % if comment_file:
21 ${_('%(user)s left %(comment_type)s on commit `%(commit_id)s` (file: `%(comment_file)s`)') % data} ${_('in the %(repo_name)s repository') % data |n}
21 ${_('{user} left a {comment_type} on file `{comment_file}` in commit `{commit_id}`').format(**data)} ${_('in the {repo_name} repository').format(**data) |n}
22 % else:
22 % else:
23 % if status_change:
23 % if status_change:
24 ${_('%(user)s left %(comment_type)s on commit `%(commit_id)s` (status: %(status)s)') % data |n} ${_('in the %(repo_name)s repository') % data |n}
24 ${_('[status: {status}] {user} left a {comment_type} on commit `{commit_id}`').format(**data) |n} ${_('in the {repo_name} repository').format(**data) |n}
25 % else:
25 % else:
26 ${_('%(user)s left %(comment_type)s on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n}
26 ${_('{user} left a {comment_type} on commit `{commit_id}`').format(**data) |n} ${_('in the {repo_name} repository').format(**data) |n}
27 % endif
27 % endif
28 % endif
28 % endif
29
29
30 </%def>
30 </%def>
31
31
32 ## PLAINTEXT VERSION OF BODY
32 ## PLAINTEXT VERSION OF BODY
33 <%def name="body_plaintext()" filter="n,trim">
33 <%def name="body_plaintext()" filter="n,trim">
34 <%
34 <%
35 data = {
35 data = {
36 'user': h.person(user),
36 'user': h.person(user),
37 'repo_name': repo_name,
37 'repo_name': repo_name,
38 'commit_id': h.show_id(commit),
38 'commit_id': h.show_id(commit),
39 'status': status_change,
39 'status': status_change,
40 'comment_file': comment_file,
40 'comment_file': comment_file,
41 'comment_line': comment_line,
41 'comment_line': comment_line,
42 'comment_type': comment_type,
42 'comment_type': comment_type,
43 }
43 }
44 %>
44 %>
45 ${self.subject()}
45 ${self.subject()}
46
46
47 * ${_('Comment link')}: ${commit_comment_url}
47 * ${_('Comment link')}: ${commit_comment_url}
48
48
49 * ${_('Commit')}: ${h.show_id(commit)}
49 * ${_('Commit')}: ${h.show_id(commit)}
50
50
51 %if comment_file:
51 %if comment_file:
52 * ${_('File: %(comment_file)s on line %(comment_line)s') % data}
52 * ${_('File: {comment_file} on line {comment_line}').format(**data)}
53 %endif
53 %endif
54
54
55 ---
55 ---
56
56
57 %if status_change:
57 %if status_change:
58 ${_('Commit status was changed to')}: *${status_change}*
58 ${_('Commit status was changed to')}: *${status_change}*
59 %endif
59 %endif
60
60
61 ${comment_body|n}
61 ${comment_body|n}
62
62
63 ${self.plaintext_footer()}
63 ${self.plaintext_footer()}
64 </%def>
64 </%def>
65
65
66
66
67 <%
67 <%
68 data = {
68 data = {
69 'user': h.person(user),
69 'user': h.person(user),
70 'repo': commit_target_repo,
70 'repo': commit_target_repo,
71 'repo_name': repo_name,
71 'repo_name': repo_name,
72 'commit_id': h.show_id(commit),
72 'commit_id': h.show_id(commit),
73 'comment_file': comment_file,
73 'comment_file': comment_file,
74 'comment_line': comment_line,
74 'comment_line': comment_line,
75 'comment_type': comment_type,
75 'comment_type': comment_type,
76 }
76 }
77 %>
77 %>
78 <table style="text-align:left;vertical-align:middle;">
78 <table style="text-align:left;vertical-align:middle;">
79 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
79 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
80
80
81 % if comment_file:
81 % if comment_file:
82 <h4><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('%(user)s commented on commit `%(commit_id)s` (file:`%(comment_file)s`)') % data}</a> ${_('in the %(repo)s repository') % data |n}</h4>
82 <h4><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('{user} left a {comment_type} on file `{comment_file}` in commit `{commit_id}`').format(**data)}</a> ${_('in the {repo} repository').format(**data) |n}</h4>
83 % else:
83 % else:
84 <h4><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('%(user)s commented on commit `%(commit_id)s`') % data |n}</a> ${_('in the %(repo)s repository') % data |n}</h4>
84 <h4><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('{user} left a {comment_type} on commit `{commit_id}`').format(**data) |n}</a> ${_('in the {repo} repository').format(**data) |n}</h4>
85 % endif
85 % endif
86 </td></tr>
86 </td></tr>
87
87
88 <tr><td style="padding-right:20px;padding-top:15px;">${_('Commit')}</td><td style="padding-top:15px;"><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${h.show_id(commit)}</a></td></tr>
88 <tr><td style="padding-right:20px;padding-top:15px;">${_('Commit')}</td><td style="padding-top:15px;"><a href="${commit_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${h.show_id(commit)}</a></td></tr>
89 <tr><td style="padding-right:20px;">${_('Description')}</td><td style="white-space:pre-wrap">${h.urlify_commit_message(commit.message, repo_name)}</td></tr>
89 <tr><td style="padding-right:20px;">${_('Description')}</td><td style="white-space:pre-wrap">${h.urlify_commit_message(commit.message, repo_name)}</td></tr>
90
90
91 % if status_change:
91 % if status_change:
92 <tr><td style="padding-right:20px;">${_('Status')}</td>
92 <tr>
93 <td>${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}</td>
93 <td style="padding-right:20px;">${_('Status')}</td>
94 <td>
95 ${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}
96 </td>
94 </tr>
97 </tr>
95 % endif
98 % endif
96 <tr>
99 <tr>
97 <td style="padding-right:20px;">
100 <td style="padding-right:20px;">
98 % if comment_type == 'todo':
101 % if comment_type == 'todo':
99 ${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
102 ${(_('TODO comment on line: {comment_line}') if comment_file else _('TODO comment')).format(**data)}
100 % else:
103 % else:
101 ${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
104 ${(_('Note comment on line: {comment_line}') if comment_file else _('Note comment')).format(**data)}
102 % endif
105 % endif
103 </td>
106 </td>
104 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
107 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
105 </table>
108 </table>
@@ -1,114 +1,114 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="base.mako"/>
2 <%inherit file="base.mako"/>
3 <%namespace name="base" file="base.mako"/>
3 <%namespace name="base" file="base.mako"/>
4
4
5 ## EMAIL SUBJECT
5 ## EMAIL SUBJECT
6 <%def name="subject()" filter="n,trim,whitespace_filter">
6 <%def name="subject()" filter="n,trim,whitespace_filter">
7 <%
7 <%
8 data = {
8 data = {
9 'user': h.person(user),
9 'user': h.person(user),
10 'pr_title': pull_request.title,
10 'pr_title': pull_request.title,
11 'pr_id': pull_request.pull_request_id,
11 'pr_id': pull_request.pull_request_id,
12 'status': status_change,
12 'status': status_change,
13 'comment_file': comment_file,
13 'comment_file': comment_file,
14 'comment_line': comment_line,
14 'comment_line': comment_line,
15 'comment_type': comment_type,
15 'comment_type': comment_type,
16 }
16 }
17 %>
17 %>
18
18
19 ${_('[mention]') if mention else ''} \
19 ${(_('[mention]') if mention else '')} \
20
20
21 % if comment_file:
21 % if comment_file:
22 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n}
22 ${_('{user} left a {comment_type} on file `{comment_file}` in pull request #{pr_id} "{pr_title}"').format(**data) |n}
23 % else:
23 % else:
24 % if status_change:
24 % if status_change:
25 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n}
25 ${_('[status: {status}] {user} left a {comment_type} on pull request #{pr_id} "{pr_title}"').format(**data) |n}
26 % else:
26 % else:
27 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
27 ${_('{user} left a {comment_type} on pull request #{pr_id} "{pr_title}"').format(**data) |n}
28 % endif
28 % endif
29 % endif
29 % endif
30 </%def>
30 </%def>
31
31
32 ## PLAINTEXT VERSION OF BODY
32 ## PLAINTEXT VERSION OF BODY
33 <%def name="body_plaintext()" filter="n,trim">
33 <%def name="body_plaintext()" filter="n,trim">
34 <%
34 <%
35 data = {
35 data = {
36 'user': h.person(user),
36 'user': h.person(user),
37 'pr_title': pull_request.title,
37 'pr_title': pull_request.title,
38 'pr_id': pull_request.pull_request_id,
38 'pr_id': pull_request.pull_request_id,
39 'status': status_change,
39 'status': status_change,
40 'comment_file': comment_file,
40 'comment_file': comment_file,
41 'comment_line': comment_line,
41 'comment_line': comment_line,
42 'comment_type': comment_type,
42 'comment_type': comment_type,
43 }
43 }
44 %>
44 %>
45 ${self.subject()}
45 ${self.subject()}
46
46
47 * ${_('Comment link')}: ${pr_comment_url}
47 * ${_('Comment link')}: ${pr_comment_url}
48
48
49 * ${_('Source repository')}: ${pr_source_repo_url}
49 * ${_('Source repository')}: ${pr_source_repo_url}
50
50
51 %if comment_file:
51 %if comment_file:
52 * ${_('File: %(comment_file)s on line %(comment_line)s') % {'comment_file': comment_file, 'comment_line': comment_line}}
52 * ${_('File: {comment_file} on line {comment_line}').format(comment_file=comment_file, comment_line=comment_line)}
53 %endif
53 %endif
54
54
55 ---
55 ---
56
56
57 %if status_change and not closing_pr:
57 %if status_change and not closing_pr:
58 ${_('%(user)s submitted pull request #%(pr_id)s status: *%(status)s*') % data}
58 ${_('{user} submitted pull request #{pr_id} status: *{status}*').format(**data)}
59 %elif status_change and closing_pr:
59 %elif status_change and closing_pr:
60 ${_('%(user)s submitted pull request #%(pr_id)s status: *%(status)s and closed*') % data}
60 ${_('{user} submitted pull request #{pr_id} status: *{status} and closed*').format(**data)}
61 %endif
61 %endif
62
62
63 ${comment_body|n}
63 ${comment_body |n}
64
64
65 ${self.plaintext_footer()}
65 ${self.plaintext_footer()}
66 </%def>
66 </%def>
67
67
68
68
69 <%
69 <%
70 data = {
70 data = {
71 'user': h.person(user),
71 'user': h.person(user),
72 'pr_title': pull_request.title,
72 'pr_title': pull_request.title,
73 'pr_id': pull_request.pull_request_id,
73 'pr_id': pull_request.pull_request_id,
74 'status': status_change,
74 'status': status_change,
75 'comment_file': comment_file,
75 'comment_file': comment_file,
76 'comment_line': comment_line,
76 'comment_line': comment_line,
77 'comment_type': comment_type,
77 'comment_type': comment_type,
78 }
78 }
79 %>
79 %>
80 <table style="text-align:left;vertical-align:middle;">
80 <table style="text-align:left;vertical-align:middle;">
81 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
81 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
82
82
83 % if comment_file:
83 % if comment_file:
84 <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file:`%(comment_file)s`)') % data |n}</a></h4>
84 <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('{user} left a {comment_type} on file `{comment_file}` in pull request #{pr_id} "{pr_title}"').format(**data) |n}</a></h4>
85 % else:
85 % else:
86 <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}</a></h4>
86 <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">${_('{user} left a {comment_type} on pull request #{pr_id} "{pr_title}"').format(**data) |n}</a></h4>
87 % endif
87 % endif
88
88
89 </td></tr>
89 </td></tr>
90 <tr><td style="padding-right:20px;padding-top:15px;">${_('Source')}</td><td style="padding-top:15px;"><a style="color:#427cc9;text-decoration:none;cursor:pointer" href="${pr_source_repo_url}">${pr_source_repo.repo_name}</a></td></tr>
90 <tr><td style="padding-right:20px;padding-top:15px;">${_('Source')}</td><td style="padding-top:15px;"><a style="color:#427cc9;text-decoration:none;cursor:pointer" href="${pr_source_repo_url}">${pr_source_repo.repo_name}</a></td></tr>
91
91
92 % if status_change:
92 % if status_change:
93 <tr>
93 <tr>
94 <td style="padding-right:20px;">${_('Status')}</td>
94 <td style="padding-right:20px;">${_('Status')}</td>
95 <td>
95 <td>
96 % if closing_pr:
96 % if closing_pr:
97 ${_('Closed pull request with status')}: ${base.status_text(status_change, tag_type=status_change_type)}
97 ${_('Closed pull request with status')}: ${base.status_text(status_change, tag_type=status_change_type)}
98 % else:
98 % else:
99 ${_('Submitted review status')}: ${base.status_text(status_change, tag_type=status_change_type)}
99 ${_('Submitted review status')}: ${base.status_text(status_change, tag_type=status_change_type)}
100 % endif
100 % endif
101 </td>
101 </td>
102 </tr>
102 </tr>
103 % endif
103 % endif
104 <tr>
104 <tr>
105 <td style="padding-right:20px;">
105 <td style="padding-right:20px;">
106 % if comment_type == 'todo':
106 % if comment_type == 'todo':
107 ${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
107 ${(_('TODO comment on line: {comment_line}') if comment_file else _('TODO comment')).format(**data)}
108 % else:
108 % else:
109 ${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
109 ${(_('Note comment on line: {comment_line}') if comment_file else _('Note comment')).format(**data)}
110 % endif
110 % endif
111 </td>
111 </td>
112 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td>
112 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td>
113 </tr>
113 </tr>
114 </table>
114 </table>
General Comments 0
You need to be logged in to leave comments. Login now