##// END OF EJS Templates
emails: added note types into emails. Fixes #5221
marcink -
r1453:4b56dcb1 default
parent child Browse files
Show More
@@ -251,6 +251,7 b' class CommentsModel(BaseModel):'
251 251 'comment_body': text,
252 252 'comment_file': f_path,
253 253 'comment_line': line_no,
254 'comment_type': comment_type or 'note'
254 255 }
255 256
256 257 if commit_obj:
@@ -2,6 +2,7 b''
2 2 <%inherit file="base.mako"/>
3 3 <%namespace name="base" file="base.mako"/>
4 4
5 ## EMAIL SUBJECT
5 6 <%def name="subject()" filter="n,trim">
6 7 <%
7 8 data = {
@@ -11,22 +12,24 b' data = {'
11 12 'status': status_change,
12 13 'comment_file': comment_file,
13 14 'comment_line': comment_line,
15 'comment_type': comment_type,
14 16 }
15 17 %>
16 18 ${_('[mention]') if mention else ''} \
17 19
18 20 % if comment_file:
19 ${_('%(user)s commented on commit `%(commit_id)s` (file: `%(comment_file)s`)') % data} ${_('in the %(repo_name)s repository') % data |n}
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}
20 22 % else:
21 23 % if status_change:
22 ${_('%(user)s commented on commit `%(commit_id)s` (status: %(status)s)') % data |n} ${_('in the %(repo_name)s repository') % data |n}
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}
23 25 % else:
24 ${_('%(user)s commented on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n}
26 ${_('%(user)s left %(comment_type)s on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n}
25 27 % endif
26 28 % endif
27 29
28 30 </%def>
29 31
32 ## PLAINTEXT VERSION OF BODY
30 33 <%def name="body_plaintext()" filter="n,trim">
31 34 <%
32 35 data = {
@@ -36,6 +39,7 b' data = {'
36 39 'status': status_change,
37 40 'comment_file': comment_file,
38 41 'comment_line': comment_line,
42 'comment_type': comment_type,
39 43 }
40 44 %>
41 45 ${self.subject()}
@@ -45,7 +49,7 b' data = {'
45 49 * ${_('Commit')}: ${h.show_id(commit)}
46 50
47 51 %if comment_file:
48 * ${_('File: %(comment_file)s on line %(comment_line)s') % {'comment_file': comment_file, 'comment_line': comment_line}}
52 * ${_('File: %(comment_file)s on line %(comment_line)s') % data}
49 53 %endif
50 54
51 55 ---
@@ -63,26 +67,39 b' data = {'
63 67 <%
64 68 data = {
65 69 'user': h.person(user),
66 'comment_file': comment_file,
67 'comment_line': comment_line,
68 70 'repo': commit_target_repo,
69 71 'repo_name': repo_name,
70 72 'commit_id': h.show_id(commit),
73 'comment_file': comment_file,
74 'comment_line': comment_line,
75 'comment_type': comment_type,
71 76 }
72 77 %>
73 78 <table style="text-align:left;vertical-align:middle;">
74 79 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
80
75 81 % if comment_file:
76 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>
77 83 % else:
78 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>
79 85 % endif
80 86 </td></tr>
87
81 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>
82 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>
83 90
84 91 % if status_change:
85 <tr><td style="padding-right:20px;">${_('Status')}</td><td>${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}</td></tr>
92 <tr><td style="padding-right:20px;">${_('Status')}</td>
93 <td>${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}</td>
94 </tr>
86 95 % endif
87 <tr><td style="padding-right:20px;">${(_('Comment on line: %(comment_line)s') if comment_file else _('Comment')) % data}</td><td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
96 <tr>
97 <td style="padding-right:20px;">
98 % if comment_type == 'todo':
99 ${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
100 % else:
101 ${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
102 % endif
103 </td>
104 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
88 105 </table>
@@ -2,7 +2,7 b''
2 2 <%inherit file="base.mako"/>
3 3 <%namespace name="base" file="base.mako"/>
4 4
5
5 ## EMAIL SUBJECT
6 6 <%def name="subject()" filter="n,trim">
7 7 <%
8 8 data = {
@@ -12,22 +12,24 b' data = {'
12 12 'status': status_change,
13 13 'comment_file': comment_file,
14 14 'comment_line': comment_line,
15 'comment_type': comment_type,
15 16 }
16 17 %>
17 18
18 19 ${_('[mention]') if mention else ''} \
19 20
20 21 % if comment_file:
21 ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n}
22 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n}
22 23 % else:
23 24 % if status_change:
24 ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n}
25 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n}
25 26 % else:
26 ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
27 ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
27 28 % endif
28 29 % endif
29 30 </%def>
30 31
32 ## PLAINTEXT VERSION OF BODY
31 33 <%def name="body_plaintext()" filter="n,trim">
32 34 <%
33 35 data = {
@@ -37,6 +39,7 b' data = {'
37 39 'status': status_change,
38 40 'comment_file': comment_file,
39 41 'comment_line': comment_line,
42 'comment_type': comment_type,
40 43 }
41 44 %>
42 45 ${self.subject()}
@@ -71,28 +74,41 b' data = {'
71 74 'status': status_change,
72 75 'comment_file': comment_file,
73 76 'comment_line': comment_line,
77 'comment_type': comment_type,
74 78 }
75 79 %>
76 80 <table style="text-align:left;vertical-align:middle;">
77 81 <tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
78 <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">
79 82
80 83 % if comment_file:
81 ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file:`%(comment_file)s`)') % data |n}
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>
82 85 % else:
83 ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
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>
84 87 % endif
85 </a>
86 %if status_change and not closing_pr:
87 , ${_('submitted pull request status: %(status)s') % data}
88 %elif status_change and closing_pr:
89 , ${_('submitted pull request status: %(status)s and closed') % data}
90 %endif
91 </h4>
88
92 89 </td></tr>
93 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
94 92 % if status_change:
95 <tr><td style="padding-right:20px;">${_('Submitted status')}</td><td>${base.status_text(status_change, tag_type=status_change_type)}</td></tr>
93 <tr>
94 <td style="padding-right:20px;">${_('Status')}</td>
95 <td>
96 % if closing_pr:
97 ${_('Closed pull request with status')}: ${base.status_text(status_change, tag_type=status_change_type)}
98 % else:
99 ${_('Submitted review status')}: ${base.status_text(status_change, tag_type=status_change_type)}
100 % endif
101 </td>
102 </tr>
96 103 % endif
97 <tr><td style="padding-right:20px;">${(_('Comment on line: %(comment_line)s') if comment_file else _('Comment')) % data}</td><td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
104 <tr>
105 <td style="padding-right:20px;">
106 % if comment_type == 'todo':
107 ${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
108 % else:
109 ${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
110 % endif
111 </td>
112 <td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td>
113 </tr>
98 114 </table>
@@ -52,13 +52,15 b' class TestCommitCommentsController(TestC'
52 52 Session().delete(x)
53 53 Session().commit()
54 54
55 def test_create(self, backend):
55 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
56 def test_create(self, comment_type, backend):
56 57 self.log_user()
57 58 commit = backend.repo.get_commit('300')
58 59 commit_id = commit.raw_id
59 60 text = u'CommentOnCommit'
60 61
61 params = {'text': text, 'csrf_token': self.csrf_token}
62 params = {'text': text, 'csrf_token': self.csrf_token,
63 'comment_type': comment_type}
62 64 self.app.post(
63 65 url(controller='changeset', action='comment',
64 66 repo_name=backend.repo_name, revision=commit_id), params=params)
@@ -79,15 +81,16 b' class TestCommitCommentsController(TestC'
79 81 comment_id = ChangesetComment.query().first().comment_id
80 82 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
81 83
82 sbj = 'commented on commit `{0}` in the {1} repository'.format(
83 h.show_id(commit), backend.repo_name)
84 sbj = 'left {0} on commit `{1}` in the {2} repository'.format(
85 comment_type, h.show_id(commit), backend.repo_name)
84 86 assert sbj in notification.subject
85 87
86 88 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
87 89 backend.repo_name, commit_id, comment_id))
88 90 assert lnk in notification.body
89 91
90 def test_create_inline(self, backend):
92 @pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
93 def test_create_inline(self, comment_type, backend):
91 94 self.log_user()
92 95 commit = backend.repo.get_commit('300')
93 96 commit_id = commit.raw_id
@@ -96,6 +99,7 b' class TestCommitCommentsController(TestC'
96 99 line = 'n1'
97 100
98 101 params = {'text': text, 'f_path': f_path, 'line': line,
102 'comment_type': comment_type,
99 103 'csrf_token': self.csrf_token}
100 104
101 105 self.app.post(
@@ -129,10 +133,11 b' class TestCommitCommentsController(TestC'
129 133 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
130 134
131 135 assert comment.revision == commit_id
132 sbj = 'commented on commit `{commit}` ' \
136 sbj = 'left {comment_type} on commit `{commit}` ' \
133 137 '(file: `{f_path}`) in the {repo} repository'.format(
134 138 commit=h.show_id(commit),
135 f_path=f_path, line=line, repo=backend.repo_name)
139 f_path=f_path, line=line, repo=backend.repo_name,
140 comment_type=comment_type)
136 141 assert sbj in notification.subject
137 142
138 143 lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
@@ -197,7 +202,7 b' class TestCommitCommentsController(TestC'
197 202 comment_id = ChangesetComment.query().first().comment_id
198 203 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
199 204
200 sbj = 'commented on commit `{0}` (status: Approved) ' \
205 sbj = 'left note on commit `{0}` (status: Approved) ' \
201 206 'in the {1} repository'.format(
202 207 h.show_id(commit), backend.repo_name)
203 208 assert sbj in notification.subject
General Comments 0
You need to be logged in to leave comments. Login now