Show More
@@ -251,6 +251,7 b' class CommentsModel(BaseModel):' | |||||
251 | 'comment_body': text, |
|
251 | 'comment_body': text, | |
252 | 'comment_file': f_path, |
|
252 | 'comment_file': f_path, | |
253 | 'comment_line': line_no, |
|
253 | 'comment_line': line_no, | |
|
254 | 'comment_type': comment_type or 'note' | |||
254 | } |
|
255 | } | |
255 |
|
256 | |||
256 | if commit_obj: |
|
257 | if commit_obj: |
@@ -2,6 +2,7 b'' | |||||
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 | <%def name="subject()" filter="n,trim"> |
|
6 | <%def name="subject()" filter="n,trim"> | |
6 | <% |
|
7 | <% | |
7 | data = { |
|
8 | data = { | |
@@ -11,22 +12,24 b' data = {' | |||||
11 | 'status': status_change, |
|
12 | 'status': status_change, | |
12 | 'comment_file': comment_file, |
|
13 | 'comment_file': comment_file, | |
13 | 'comment_line': comment_line, |
|
14 | 'comment_line': comment_line, | |
|
15 | 'comment_type': comment_type, | |||
14 | } |
|
16 | } | |
15 | %> |
|
17 | %> | |
16 | ${_('[mention]') if mention else ''} \ |
|
18 | ${_('[mention]') if mention else ''} \ | |
17 |
|
19 | |||
18 | % if comment_file: |
|
20 | % if comment_file: | |
19 |
${_('%(user)s comment |
|
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 | % else: |
|
22 | % else: | |
21 | % if status_change: |
|
23 | % if status_change: | |
22 |
${_('%(user)s comment |
|
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 | % else: |
|
25 | % else: | |
24 |
${_('%(user)s comment |
|
26 | ${_('%(user)s left %(comment_type)s on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n} | |
25 | % endif |
|
27 | % endif | |
26 | % endif |
|
28 | % endif | |
27 |
|
29 | |||
28 | </%def> |
|
30 | </%def> | |
29 |
|
31 | |||
|
32 | ## PLAINTEXT VERSION OF BODY | |||
30 | <%def name="body_plaintext()" filter="n,trim"> |
|
33 | <%def name="body_plaintext()" filter="n,trim"> | |
31 | <% |
|
34 | <% | |
32 | data = { |
|
35 | data = { | |
@@ -36,6 +39,7 b' data = {' | |||||
36 | 'status': status_change, |
|
39 | 'status': status_change, | |
37 | 'comment_file': comment_file, |
|
40 | 'comment_file': comment_file, | |
38 | 'comment_line': comment_line, |
|
41 | 'comment_line': comment_line, | |
|
42 | 'comment_type': comment_type, | |||
39 | } |
|
43 | } | |
40 | %> |
|
44 | %> | |
41 | ${self.subject()} |
|
45 | ${self.subject()} | |
@@ -45,7 +49,7 b' data = {' | |||||
45 | * ${_('Commit')}: ${h.show_id(commit)} |
|
49 | * ${_('Commit')}: ${h.show_id(commit)} | |
46 |
|
50 | |||
47 | %if comment_file: |
|
51 | %if comment_file: | |
48 |
* ${_('File: %(comment_file)s on line %(comment_line)s') % |
|
52 | * ${_('File: %(comment_file)s on line %(comment_line)s') % data} | |
49 | %endif |
|
53 | %endif | |
50 |
|
54 | |||
51 | --- |
|
55 | --- | |
@@ -63,26 +67,39 b' data = {' | |||||
63 | <% |
|
67 | <% | |
64 | data = { |
|
68 | data = { | |
65 | 'user': h.person(user), |
|
69 | 'user': h.person(user), | |
66 | 'comment_file': comment_file, |
|
|||
67 | 'comment_line': comment_line, |
|
|||
68 | 'repo': commit_target_repo, |
|
70 | 'repo': commit_target_repo, | |
69 | 'repo_name': repo_name, |
|
71 | 'repo_name': repo_name, | |
70 | 'commit_id': h.show_id(commit), |
|
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 | <table style="text-align:left;vertical-align:middle;"> |
|
78 | <table style="text-align:left;vertical-align:middle;"> | |
74 | <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 | ||||
75 |
|
|
81 | % if comment_file: | |
76 | <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)s commented on commit `%(commit_id)s` (file:`%(comment_file)s`)') % data}</a> ${_('in the %(repo)s repository') % data |n}</h4> | |
77 | % else: |
|
83 | % else: | |
78 | <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)s commented on commit `%(commit_id)s`') % data |n}</a> ${_('in the %(repo)s repository') % data |n}</h4> | |
79 | % endif |
|
85 | % endif | |
80 | </td></tr> |
|
86 | </td></tr> | |
|
87 | ||||
81 | <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> | |
82 | <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> | |
83 |
|
90 | |||
84 | % if status_change: |
|
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 | % endif |
|
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 | </table> |
|
105 | </table> |
@@ -2,7 +2,7 b'' | |||||
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 |
|
5 | ## EMAIL SUBJECT | ||
6 | <%def name="subject()" filter="n,trim"> |
|
6 | <%def name="subject()" filter="n,trim"> | |
7 | <% |
|
7 | <% | |
8 | data = { |
|
8 | data = { | |
@@ -12,22 +12,24 b' data = {' | |||||
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 | } |
|
16 | } | |
16 | %> |
|
17 | %> | |
17 |
|
18 | |||
18 | ${_('[mention]') if mention else ''} \ |
|
19 | ${_('[mention]') if mention else ''} \ | |
19 |
|
20 | |||
20 | % if comment_file: |
|
21 | % if comment_file: | |
21 |
${_('%(user)s comment |
|
22 | ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n} | |
22 | % else: |
|
23 | % else: | |
23 | % if status_change: |
|
24 | % if status_change: | |
24 |
${_('%(user)s comment |
|
25 | ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n} | |
25 | % else: |
|
26 | % else: | |
26 |
${_('%(user)s comment |
|
27 | ${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s"') % data |n} | |
27 | % endif |
|
28 | % endif | |
28 | % endif |
|
29 | % endif | |
29 | </%def> |
|
30 | </%def> | |
30 |
|
31 | |||
|
32 | ## PLAINTEXT VERSION OF BODY | |||
31 | <%def name="body_plaintext()" filter="n,trim"> |
|
33 | <%def name="body_plaintext()" filter="n,trim"> | |
32 | <% |
|
34 | <% | |
33 | data = { |
|
35 | data = { | |
@@ -37,6 +39,7 b' data = {' | |||||
37 | 'status': status_change, |
|
39 | 'status': status_change, | |
38 | 'comment_file': comment_file, |
|
40 | 'comment_file': comment_file, | |
39 | 'comment_line': comment_line, |
|
41 | 'comment_line': comment_line, | |
|
42 | 'comment_type': comment_type, | |||
40 | } |
|
43 | } | |
41 | %> |
|
44 | %> | |
42 | ${self.subject()} |
|
45 | ${self.subject()} | |
@@ -71,28 +74,41 b' data = {' | |||||
71 | 'status': status_change, |
|
74 | 'status': status_change, | |
72 | 'comment_file': comment_file, |
|
75 | 'comment_file': comment_file, | |
73 | 'comment_line': comment_line, |
|
76 | 'comment_line': comment_line, | |
|
77 | 'comment_type': comment_type, | |||
74 | } |
|
78 | } | |
75 | %> |
|
79 | %> | |
76 | <table style="text-align:left;vertical-align:middle;"> |
|
80 | <table style="text-align:left;vertical-align:middle;"> | |
77 | <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;"> | |
78 | <h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer"> |
|
|||
79 |
|
82 | |||
80 | % if comment_file: |
|
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 | % else: |
|
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 | % endif |
|
87 | % endif | |
85 | </a> |
|
88 | ||
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> |
|
|||
92 | </td></tr> |
|
89 | </td></tr> | |
93 | <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 | ||||
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 | % endif |
|
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 | </table> |
|
114 | </table> |
@@ -52,13 +52,15 b' class TestCommitCommentsController(TestC' | |||||
52 | Session().delete(x) |
|
52 | Session().delete(x) | |
53 | Session().commit() |
|
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 | self.log_user() |
|
57 | self.log_user() | |
57 | commit = backend.repo.get_commit('300') |
|
58 | commit = backend.repo.get_commit('300') | |
58 | commit_id = commit.raw_id |
|
59 | commit_id = commit.raw_id | |
59 | text = u'CommentOnCommit' |
|
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 | self.app.post( |
|
64 | self.app.post( | |
63 | url(controller='changeset', action='comment', |
|
65 | url(controller='changeset', action='comment', | |
64 | repo_name=backend.repo_name, revision=commit_id), params=params) |
|
66 | repo_name=backend.repo_name, revision=commit_id), params=params) | |
@@ -79,15 +81,16 b' class TestCommitCommentsController(TestC' | |||||
79 | comment_id = ChangesetComment.query().first().comment_id |
|
81 | comment_id = ChangesetComment.query().first().comment_id | |
80 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT |
|
82 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT | |
81 |
|
83 | |||
82 |
sbj = ' |
|
84 | sbj = 'left {0} on commit `{1}` in the {2} repository'.format( | |
83 | h.show_id(commit), backend.repo_name) |
|
85 | comment_type, h.show_id(commit), backend.repo_name) | |
84 | assert sbj in notification.subject |
|
86 | assert sbj in notification.subject | |
85 |
|
87 | |||
86 | lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( |
|
88 | lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( | |
87 | backend.repo_name, commit_id, comment_id)) |
|
89 | backend.repo_name, commit_id, comment_id)) | |
88 | assert lnk in notification.body |
|
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 | self.log_user() |
|
94 | self.log_user() | |
92 | commit = backend.repo.get_commit('300') |
|
95 | commit = backend.repo.get_commit('300') | |
93 | commit_id = commit.raw_id |
|
96 | commit_id = commit.raw_id | |
@@ -96,6 +99,7 b' class TestCommitCommentsController(TestC' | |||||
96 | line = 'n1' |
|
99 | line = 'n1' | |
97 |
|
100 | |||
98 | params = {'text': text, 'f_path': f_path, 'line': line, |
|
101 | params = {'text': text, 'f_path': f_path, 'line': line, | |
|
102 | 'comment_type': comment_type, | |||
99 | 'csrf_token': self.csrf_token} |
|
103 | 'csrf_token': self.csrf_token} | |
100 |
|
104 | |||
101 | self.app.post( |
|
105 | self.app.post( | |
@@ -129,10 +133,11 b' class TestCommitCommentsController(TestC' | |||||
129 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT |
|
133 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT | |
130 |
|
134 | |||
131 | assert comment.revision == commit_id |
|
135 | assert comment.revision == commit_id | |
132 |
sbj = 'comment |
|
136 | sbj = 'left {comment_type} on commit `{commit}` ' \ | |
133 | '(file: `{f_path}`) in the {repo} repository'.format( |
|
137 | '(file: `{f_path}`) in the {repo} repository'.format( | |
134 | commit=h.show_id(commit), |
|
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 | assert sbj in notification.subject |
|
141 | assert sbj in notification.subject | |
137 |
|
142 | |||
138 | lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( |
|
143 | lnk = (u'/{0}/changeset/{1}#comment-{2}'.format( | |
@@ -197,7 +202,7 b' class TestCommitCommentsController(TestC' | |||||
197 | comment_id = ChangesetComment.query().first().comment_id |
|
202 | comment_id = ChangesetComment.query().first().comment_id | |
198 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT |
|
203 | assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT | |
199 |
|
204 | |||
200 |
sbj = ' |
|
205 | sbj = 'left note on commit `{0}` (status: Approved) ' \ | |
201 | 'in the {1} repository'.format( |
|
206 | 'in the {1} repository'.format( | |
202 | h.show_id(commit), backend.repo_name) |
|
207 | h.show_id(commit), backend.repo_name) | |
203 | assert sbj in notification.subject |
|
208 | assert sbj in notification.subject |
General Comments 0
You need to be logged in to leave comments.
Login now