emails: added note types into emails. Fixes #5221
This commit is contained in:
parent
5b6f560bdb
commit
8c73a665d3
4 changed files with 71 additions and 32 deletions
|
|
@ -251,6 +251,7 @@ class CommentsModel(BaseModel):
|
|||
'comment_body': text,
|
||||
'comment_file': f_path,
|
||||
'comment_line': line_no,
|
||||
'comment_type': comment_type or 'note'
|
||||
}
|
||||
|
||||
if commit_obj:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
<%inherit file="base.mako"/>
|
||||
<%namespace name="base" file="base.mako"/>
|
||||
|
||||
## EMAIL SUBJECT
|
||||
<%def name="subject()" filter="n,trim">
|
||||
<%
|
||||
data = {
|
||||
|
|
@ -11,22 +12,24 @@ data = {
|
|||
'status': status_change,
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
${_('[mention]') if mention else ''} \
|
||||
|
||||
% if comment_file:
|
||||
${_('%(user)s commented on commit `%(commit_id)s` (file: `%(comment_file)s`)') % data} ${_('in the %(repo_name)s repository') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on commit `%(commit_id)s` (file: `%(comment_file)s`)') % data} ${_('in the %(repo_name)s repository') % data |n}
|
||||
% else:
|
||||
% if status_change:
|
||||
${_('%(user)s commented on commit `%(commit_id)s` (status: %(status)s)') % data |n} ${_('in the %(repo_name)s repository') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on commit `%(commit_id)s` (status: %(status)s)') % data |n} ${_('in the %(repo_name)s repository') % data |n}
|
||||
% else:
|
||||
${_('%(user)s commented on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on commit `%(commit_id)s`') % data |n} ${_('in the %(repo_name)s repository') % data |n}
|
||||
% endif
|
||||
% endif
|
||||
|
||||
</%def>
|
||||
|
||||
## PLAINTEXT VERSION OF BODY
|
||||
<%def name="body_plaintext()" filter="n,trim">
|
||||
<%
|
||||
data = {
|
||||
|
|
@ -36,6 +39,7 @@ data = {
|
|||
'status': status_change,
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
${self.subject()}
|
||||
|
|
@ -45,7 +49,7 @@ ${self.subject()}
|
|||
* ${_('Commit')}: ${h.show_id(commit)}
|
||||
|
||||
%if comment_file:
|
||||
* ${_('File: %(comment_file)s on line %(comment_line)s') % {'comment_file': comment_file, 'comment_line': comment_line}}
|
||||
* ${_('File: %(comment_file)s on line %(comment_line)s') % data}
|
||||
%endif
|
||||
|
||||
---
|
||||
|
|
@ -63,26 +67,39 @@ ${self.plaintext_footer()}
|
|||
<%
|
||||
data = {
|
||||
'user': h.person(user),
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'repo': commit_target_repo,
|
||||
'repo_name': repo_name,
|
||||
'commit_id': h.show_id(commit),
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
<table style="text-align:left;vertical-align:middle;">
|
||||
<tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
|
||||
|
||||
% if comment_file:
|
||||
<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>
|
||||
% else:
|
||||
<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>
|
||||
% endif
|
||||
</td></tr>
|
||||
|
||||
<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>
|
||||
<tr><td style="padding-right:20px;">${_('Description')}</td><td style="white-space:pre-wrap">${h.urlify_commit_message(commit.message, repo_name)}</td></tr>
|
||||
|
||||
% if status_change:
|
||||
<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>
|
||||
<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>
|
||||
% endif
|
||||
<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>
|
||||
<tr>
|
||||
<td style="padding-right:20px;">
|
||||
% if comment_type == 'todo':
|
||||
${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
|
||||
% else:
|
||||
${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
|
||||
% endif
|
||||
</td>
|
||||
<td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td></tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<%inherit file="base.mako"/>
|
||||
<%namespace name="base" file="base.mako"/>
|
||||
|
||||
|
||||
## EMAIL SUBJECT
|
||||
<%def name="subject()" filter="n,trim">
|
||||
<%
|
||||
data = {
|
||||
|
|
@ -12,22 +12,24 @@ data = {
|
|||
'status': status_change,
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
|
||||
${_('[mention]') if mention else ''} \
|
||||
|
||||
% if comment_file:
|
||||
${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (file: `%(comment_file)s`)') % data |n}
|
||||
% else:
|
||||
% if status_change:
|
||||
${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s" (status: %(status)s)') % data |n}
|
||||
% else:
|
||||
${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
|
||||
${_('%(user)s left %(comment_type)s on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
|
||||
% endif
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
## PLAINTEXT VERSION OF BODY
|
||||
<%def name="body_plaintext()" filter="n,trim">
|
||||
<%
|
||||
data = {
|
||||
|
|
@ -37,6 +39,7 @@ data = {
|
|||
'status': status_change,
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
${self.subject()}
|
||||
|
|
@ -71,28 +74,41 @@ data = {
|
|||
'status': status_change,
|
||||
'comment_file': comment_file,
|
||||
'comment_line': comment_line,
|
||||
'comment_type': comment_type,
|
||||
}
|
||||
%>
|
||||
<table style="text-align:left;vertical-align:middle;">
|
||||
<tr><td colspan="2" style="width:100%;padding-bottom:15px;border-bottom:1px solid #dbd9da;">
|
||||
<h4><a href="${pr_comment_url}" style="color:#427cc9;text-decoration:none;cursor:pointer">
|
||||
|
||||
% if comment_file:
|
||||
${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file:`%(comment_file)s`)') % data |n}
|
||||
<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>
|
||||
% else:
|
||||
${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}
|
||||
<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>
|
||||
% endif
|
||||
</a>
|
||||
%if status_change and not closing_pr:
|
||||
, ${_('submitted pull request status: %(status)s') % data}
|
||||
%elif status_change and closing_pr:
|
||||
, ${_('submitted pull request status: %(status)s and closed') % data}
|
||||
%endif
|
||||
</h4>
|
||||
|
||||
</td></tr>
|
||||
<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>
|
||||
|
||||
% if status_change:
|
||||
<tr><td style="padding-right:20px;">${_('Submitted status')}</td><td>${base.status_text(status_change, tag_type=status_change_type)}</td></tr>
|
||||
<tr>
|
||||
<td style="padding-right:20px;">${_('Status')}</td>
|
||||
<td>
|
||||
% if closing_pr:
|
||||
${_('Closed pull request with status')}: ${base.status_text(status_change, tag_type=status_change_type)}
|
||||
% else:
|
||||
${_('Submitted review status')}: ${base.status_text(status_change, tag_type=status_change_type)}
|
||||
% endif
|
||||
</td>
|
||||
</tr>
|
||||
% endif
|
||||
<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>
|
||||
<tr>
|
||||
<td style="padding-right:20px;">
|
||||
% if comment_type == 'todo':
|
||||
${(_('TODO comment on line: %(comment_line)s') if comment_file else _('TODO comment')) % data}
|
||||
% else:
|
||||
${(_('Note comment on line: %(comment_line)s') if comment_file else _('Note comment')) % data}
|
||||
% endif
|
||||
</td>
|
||||
<td style="line-height:1.2em;white-space:pre-wrap">${h.render(comment_body, renderer=renderer_type, mentions=True)}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -52,13 +52,15 @@ class TestCommitCommentsController(TestController):
|
|||
Session().delete(x)
|
||||
Session().commit()
|
||||
|
||||
def test_create(self, backend):
|
||||
@pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
|
||||
def test_create(self, comment_type, backend):
|
||||
self.log_user()
|
||||
commit = backend.repo.get_commit('300')
|
||||
commit_id = commit.raw_id
|
||||
text = u'CommentOnCommit'
|
||||
|
||||
params = {'text': text, 'csrf_token': self.csrf_token}
|
||||
params = {'text': text, 'csrf_token': self.csrf_token,
|
||||
'comment_type': comment_type}
|
||||
self.app.post(
|
||||
url(controller='changeset', action='comment',
|
||||
repo_name=backend.repo_name, revision=commit_id), params=params)
|
||||
|
|
@ -79,15 +81,16 @@ class TestCommitCommentsController(TestController):
|
|||
comment_id = ChangesetComment.query().first().comment_id
|
||||
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
|
||||
|
||||
sbj = 'commented on commit `{0}` in the {1} repository'.format(
|
||||
h.show_id(commit), backend.repo_name)
|
||||
sbj = 'left {0} on commit `{1}` in the {2} repository'.format(
|
||||
comment_type, h.show_id(commit), backend.repo_name)
|
||||
assert sbj in notification.subject
|
||||
|
||||
lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
|
||||
backend.repo_name, commit_id, comment_id))
|
||||
assert lnk in notification.body
|
||||
|
||||
def test_create_inline(self, backend):
|
||||
@pytest.mark.parametrize('comment_type', ChangesetComment.COMMENT_TYPES)
|
||||
def test_create_inline(self, comment_type, backend):
|
||||
self.log_user()
|
||||
commit = backend.repo.get_commit('300')
|
||||
commit_id = commit.raw_id
|
||||
|
|
@ -96,6 +99,7 @@ class TestCommitCommentsController(TestController):
|
|||
line = 'n1'
|
||||
|
||||
params = {'text': text, 'f_path': f_path, 'line': line,
|
||||
'comment_type': comment_type,
|
||||
'csrf_token': self.csrf_token}
|
||||
|
||||
self.app.post(
|
||||
|
|
@ -129,10 +133,11 @@ class TestCommitCommentsController(TestController):
|
|||
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
|
||||
|
||||
assert comment.revision == commit_id
|
||||
sbj = 'commented on commit `{commit}` ' \
|
||||
sbj = 'left {comment_type} on commit `{commit}` ' \
|
||||
'(file: `{f_path}`) in the {repo} repository'.format(
|
||||
commit=h.show_id(commit),
|
||||
f_path=f_path, line=line, repo=backend.repo_name)
|
||||
f_path=f_path, line=line, repo=backend.repo_name,
|
||||
comment_type=comment_type)
|
||||
assert sbj in notification.subject
|
||||
|
||||
lnk = (u'/{0}/changeset/{1}#comment-{2}'.format(
|
||||
|
|
@ -197,7 +202,7 @@ class TestCommitCommentsController(TestController):
|
|||
comment_id = ChangesetComment.query().first().comment_id
|
||||
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
|
||||
|
||||
sbj = 'commented on commit `{0}` (status: Approved) ' \
|
||||
sbj = 'left note on commit `{0}` (status: Approved) ' \
|
||||
'in the {1} repository'.format(
|
||||
h.show_id(commit), backend.repo_name)
|
||||
assert sbj in notification.subject
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue