diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -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: diff --git a/rhodecode/templates/email_templates/commit_comment.mako b/rhodecode/templates/email_templates/commit_comment.mako --- a/rhodecode/templates/email_templates/commit_comment.mako +++ b/rhodecode/templates/email_templates/commit_comment.mako @@ -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 +## 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 @@ data = { * ${_('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 @@ data = { <% 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, } %> + % if status_change: - + + + % endif - + + +
+ % if comment_file:

${_('%(user)s commented on commit `%(commit_id)s` (file:`%(comment_file)s`)') % data} ${_('in the %(repo)s repository') % data |n}

% else:

${_('%(user)s commented on commit `%(commit_id)s`') % data |n} ${_('in the %(repo)s repository') % data |n}

% endif
${_('Commit')}${h.show_id(commit)}
${_('Description')}${h.urlify_commit_message(commit.message, repo_name)}
${_('Status')}${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}
${_('Status')}${_('The commit status was changed to')}: ${base.status_text(status_change, tag_type=status_change_type)}
${(_('Comment on line: %(comment_line)s') if comment_file else _('Comment')) % data}${h.render(comment_body, renderer=renderer_type, mentions=True)}
+ % 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 + ${h.render(comment_body, renderer=renderer_type, mentions=True)}
diff --git a/rhodecode/templates/email_templates/pull_request_comment.mako b/rhodecode/templates/email_templates/pull_request_comment.mako --- a/rhodecode/templates/email_templates/pull_request_comment.mako +++ b/rhodecode/templates/email_templates/pull_request_comment.mako @@ -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 +## 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, } %> + % if status_change: - + + + + % endif - + + + +
-

% if comment_file: - ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file:`%(comment_file)s`)') % data |n} +

${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s" (file:`%(comment_file)s`)') % data |n}

% else: - ${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n} +

${_('%(user)s commented on pull request #%(pr_id)s "%(pr_title)s"') % data |n}

% endif - - %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 - +
${_('Source')}${pr_source_repo.repo_name}
${_('Submitted status')}${base.status_text(status_change, tag_type=status_change_type)}
${_('Status')} + % 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 +
${(_('Comment on line: %(comment_line)s') if comment_file else _('Comment')) % data}${h.render(comment_body, renderer=renderer_type, mentions=True)}
+ % 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 + ${h.render(comment_body, renderer=renderer_type, mentions=True)}
diff --git a/rhodecode/tests/functional/test_commit_comments.py b/rhodecode/tests/functional/test_commit_comments.py --- a/rhodecode/tests/functional/test_commit_comments.py +++ b/rhodecode/tests/functional/test_commit_comments.py @@ -52,13 +52,15 @@ class TestCommitCommentsController(TestC 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(TestC 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(TestC 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(TestC 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(TestC 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