# HG changeset patch # User Marcin Kuzminski # Date 2016-08-03 13:21:38 # Node ID 1e26c2895504204f40af6af34e392ecb73f186d3 # Parent be8e7f94c4adc58728ffbe018978dac2db76f0d2 emails: added new tags to status sent - make this distinct colored tags for quick status catch - pass in the status type together with label to the notifiactions and templates - fixed some UI issues on emails diff --git a/rhodecode/api/views/pull_request_api.py b/rhodecode/api/views/pull_request_api.py --- a/rhodecode/api/views/pull_request_api.py +++ b/rhodecode/api/views/pull_request_api.py @@ -408,6 +408,8 @@ def comment_pull_request(request, apiuse line_no=None, status_change=(ChangesetStatus.get_status_lbl(status) if status and allowed_to_change_status else None), + status_change_type=(status + if status and allowed_to_change_status else None), closing_pr=False, renderer=renderer ) diff --git a/rhodecode/api/views/repo_api.py b/rhodecode/api/views/repo_api.py --- a/rhodecode/api/views/repo_api.py +++ b/rhodecode/api/views/repo_api.py @@ -1363,9 +1363,11 @@ def comment_commit( try: rc_config = SettingsModel().get_all_settings() renderer = rc_config.get('rhodecode_markup_renderer', 'rst') - + status_change_label = ChangesetStatus.get_status_lbl(status) comm = ChangesetCommentsModel().create( - message, repo, user, revision=commit_id, status_change=status, + message, repo, user, revision=commit_id, + status_change=status_change_label, + status_change_type=status, renderer=renderer) if status: # also do a status change diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -351,7 +351,8 @@ class ChangesetController(BaseRepoContro f_path=request.POST.get('f_path'), line_no=request.POST.get('line'), status_change=(ChangesetStatus.get_status_lbl(status) - if status else None) + if status else None), + status_change_type=status ) # get status if set ! if status: diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -762,6 +762,8 @@ class PullrequestsController(BaseRepoCon line_no=request.POST.get('line'), status_change=(ChangesetStatus.get_status_lbl(status) if status and allowed_to_change_status else None), + status_change_type=(status + if status and allowed_to_change_status else None), closing_pr=close_pr ) diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -82,7 +82,8 @@ class ChangesetCommentsModel(BaseModel): return global_renderer def create(self, text, repo, user, revision=None, pull_request=None, - f_path=None, line_no=None, status_change=None, closing_pr=False, + f_path=None, line_no=None, status_change=None, + status_change_type=None, closing_pr=False, send_email=True, renderer=None): """ Creates new comment for commit or pull request. @@ -96,7 +97,8 @@ class ChangesetCommentsModel(BaseModel): :param pull_request: :param f_path: :param line_no: - :param status_change: + :param status_change: Label for status change + :param status_change_type: type of status change :param closing_pr: :param send_email: """ @@ -144,6 +146,7 @@ class ChangesetCommentsModel(BaseModel): 'renderer_type': renderer, 'repo_name': repo.repo_name, 'status_change': status_change, + 'status_change_type': status_change_type, 'comment_body': text, 'comment_file': f_path, 'comment_line': line_no, diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -854,6 +854,7 @@ class PullRequestModel(BaseModel): f_path=None, line_no=None, status_change=ChangesetStatus.get_status_lbl(status), + status_change_type=status, closing_pr=True ) diff --git a/rhodecode/templates/email_templates/base.mako b/rhodecode/templates/email_templates/base.mako --- a/rhodecode/templates/email_templates/base.mako +++ b/rhodecode/templates/email_templates/base.mako @@ -1,5 +1,30 @@ ## -*- coding: utf-8 -*- +## helpers +<%def name="tag_button(text, tag_type=None)"> + <% + color_scheme = { + 'default': 'border:1px solid #979797;color:#666666;background-color:#f9f9f9', + 'approved': 'border:1px solid #0ac878;color:#0ac878;background-color:#f9f9f9', + 'rejected': 'border:1px solid #e85e4d;color:#e85e4d;background-color:#f9f9f9', + 'under_review': 'border:1px solid #ffc854;color:#ffc854;background-color:#f9f9f9', + } + %> +
${text}
+ + +<%def name="status_text(text, tag_type=None)"> + <% + color_scheme = { + 'default': 'color:#666666', + 'approved': 'color:#0ac878', + 'rejected': 'color:#e85e4d', + 'under_review': 'color:#ffc854', + } + %> + ${text} + + ## headers we additionally can set for email <%def name="headers()" filter="n,trim"> 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 @@ -1,6 +1,6 @@ ## -*- coding: utf-8 -*- <%inherit file="base.mako"/> - +<%namespace name="base" file="base.mako"/> <%def name="subject()" filter="n,trim"> <% @@ -82,7 +82,7 @@ data = { ${_('Description')}${h.urlify_commit_message(commit.message, repo_name)} % if status_change: - ${_('Status')}${_('The commit status was changed to')}: ${status_change}. + ${_('Status')}${_('The commit status was changed to')}: ${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)} 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 @@ -1,5 +1,6 @@ ## -*- coding: utf-8 -*- <%inherit file="base.mako"/> +<%namespace name="base" file="base.mako"/> <%def name="subject()" filter="n,trim"> @@ -90,5 +91,8 @@ data = { ${_('Source')}${pr_source_repo.repo_name} + % if status_change: + ${_('Submitted 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)} diff --git a/rhodecode/templates/email_templates/pull_request_review.mako b/rhodecode/templates/email_templates/pull_request_review.mako --- a/rhodecode/templates/email_templates/pull_request_review.mako +++ b/rhodecode/templates/email_templates/pull_request_review.mako @@ -1,26 +1,37 @@ ## -*- coding: utf-8 -*- <%inherit file="base.mako"/> +<%namespace name="base" file="base.mako"/> <%def name="subject()" filter="n,trim"> - ${_('%(user)s wants you to review pull request #%(pr_url)s: "%(pr_title)s"') % { - 'user': h.person(user), - 'pr_title': pull_request.title, - 'pr_url': pull_request.pull_request_id - } |n} +<% +data = { + 'user': h.person(user), + 'pr_id': pull_request.pull_request_id, + 'pr_title': pull_request.title, +} +%> + +${_('%(user)s wants you to review pull request #%(pr_id)s: "%(pr_title)s"') % data |n} <%def name="body_plaintext()" filter="n,trim"> +<% +data = { + 'user': h.person(user), + 'pr_id': pull_request.pull_request_id, + 'pr_title': pull_request.title, + 'source_ref_type': pull_request.source_ref_parts.type, + 'source_ref_name': pull_request.source_ref_parts.name, + 'target_ref_type': pull_request.target_ref_parts.type, + 'target_ref_name': pull_request.target_ref_parts.name, + 'repo_url': pull_request_source_repo_url +} +%> ${self.subject()} -${h.literal(_('Pull request from %(source_ref_type)s:%(source_ref_name)s of %(repo_url)s into %(target_ref_type)s:%(target_ref_name)s') % { - 'source_ref_type': pull_request.source_ref_parts.type, - 'source_ref_name': pull_request.source_ref_parts.name, - 'target_ref_type': pull_request.target_ref_parts.type, - 'target_ref_name': pull_request.target_ref_parts.name, - 'repo_url': pull_request_source_repo_url -})} +${h.literal(_('Pull request from %(source_ref_type)s:%(source_ref_name)s of %(repo_url)s into %(target_ref_type)s:%(target_ref_name)s') % data)} * ${_('Link')}: ${pull_request_url} @@ -42,20 +53,33 @@ ${self.plaintext_footer()} - +<% +data = { + 'user': h.person(user), + 'pr_id': pull_request.pull_request_id, + 'pr_title': pull_request.title, + 'source_ref_type': pull_request.source_ref_parts.type, + 'source_ref_name': pull_request.source_ref_parts.name, + 'target_ref_type': pull_request.target_ref_parts.type, + 'target_ref_name': pull_request.target_ref_parts.name, + 'repo_url': pull_request_source_repo_url, + 'source_repo_url': h.link_to(pull_request_source_repo.repo_name, pull_request_source_repo_url), + 'target_repo_url': h.link_to(pull_request_target_repo.repo_name, pull_request_target_repo_url) +} +%> - + - - + +

${_('%(user)s wants you to review pull request #%(pr_id)s: "%(pr_title)s".') % { 'user': h.person(user), 'pr_title': pull_request.title, 'pr_id': pull_request.pull_request_id } }

${_('%(user)s wants you to review pull request #%(pr_id)s: "%(pr_title)s".') % data }

${_('Title')}${pull_request.title}
${_('Source')}
${pull_request.source_ref_parts.name}
${h.literal(_('%(source_ref_type)s of %(source_repo_url)s') % {'source_ref_type': pull_request.source_ref_parts.type, 'source_repo_url': h.link_to(pull_request_source_repo.repo_name, pull_request_source_repo_url)})}
${_('Target')}
${pull_request.target_ref_parts.name}
${h.literal(_('%(target_ref_type)s of %(target_repo_url)s') % {'target_ref_type': pull_request.target_ref_parts.type, 'target_repo_url': h.link_to(pull_request_target_repo.repo_name, pull_request_target_repo_url)})}
${_('Source')}${base.tag_button(pull_request.source_ref_parts.name)} ${h.literal(_('%(source_ref_type)s of %(source_repo_url)s') % data)}
${_('Target')}${base.tag_button(pull_request.target_ref_parts.name)} ${h.literal(_('%(target_ref_type)s of %(target_repo_url)s') % data)}
${_('Description')}${pull_request.description}
${ungettext('%(num)s Commit', '%(num)s Commits', len(pull_request_commits)) % {'num': len(pull_request_commits)}}
    -% for commit_id, message in pull_request_commits: -
  1. ${h.short_id(commit_id)}
    - ${h.chop_at_smart(message, '\n', suffix_if_chopped='...')} -
  2. -% endfor + % for commit_id, message in pull_request_commits: +
  3. ${h.short_id(commit_id)}
    + ${h.chop_at_smart(message, '\n', suffix_if_chopped='...')} +
  4. + % endfor