diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -125,16 +125,15 @@ class ChangesetCommentsModel(BaseModel): recipients += [User.get_by_email(author_email)] #pull request elif pull_request: + _url = h.url('pullrequest_show', + repo_name=pull_request.other_repo.repo_name, + pull_request_id=pull_request.pull_request_id, + anchor='comment-%s' % comment.comment_id, + qualified=True, + ) subj = safe_unicode( h.link_to('Re pull request: %(desc)s %(line)s' % \ - {'desc': desc, 'line': line}, - h.url('pullrequest_show', - repo_name=pull_request.other_repo.repo_name, - pull_request_id=pull_request.pull_request_id, - anchor='comment-%s' % comment.comment_id, - qualified=True, - ) - ) + {'desc': desc, 'line': line}, _url) ) notification_type = Notification.TYPE_PULL_REQUEST_COMMENT @@ -144,22 +143,36 @@ class ChangesetCommentsModel(BaseModel): # add pull request author recipients += [pull_request.author] + # add the reviewers to notification + recipients += [x.user for x in pull_request.reviewers] + + #set some variables for email notification + kwargs = { + 'pr_id': pull_request.pull_request_id, + 'status_change': status_change, + 'pr_comment_url': _url, + 'pr_comment_user': h.person(user.email), + 'pr_target_repo': h.url('summary_home', + repo_name=pull_request.other_repo.repo_name, + qualified=True) + } # create notification objects, and emails NotificationModel().create( - created_by=user, subject=subj, body=body, - recipients=recipients, type_=notification_type, - email_kwargs={'status_change': status_change} + created_by=user, subject=subj, body=body, + recipients=recipients, type_=notification_type, + email_kwargs=kwargs ) mention_recipients = set(self._extract_mentions(body))\ .difference(recipients) if mention_recipients: + kwargs.update({'pr_mention': True}) subj = _('[Mention]') + ' ' + subj NotificationModel().create( created_by=user, subject=subj, body=body, recipients=mention_recipients, type_=notification_type, - email_kwargs={'status_change': status_change} + email_kwargs=kwargs ) return comment diff --git a/rhodecode/model/notification.py b/rhodecode/model/notification.py --- a/rhodecode/model/notification.py +++ b/rhodecode/model/notification.py @@ -245,6 +245,7 @@ class EmailNotificationModel(BaseModel): TYPE_PASSWORD_RESET = 'passoword_link' TYPE_REGISTRATION = Notification.TYPE_REGISTRATION TYPE_PULL_REQUEST = Notification.TYPE_PULL_REQUEST + TYPE_PULL_REQUEST_COMMENT = Notification.TYPE_PULL_REQUEST_COMMENT TYPE_DEFAULT = 'default' def __init__(self): @@ -257,6 +258,7 @@ class EmailNotificationModel(BaseModel): self.TYPE_REGISTRATION: 'email_templates/registration.html', self.TYPE_DEFAULT: 'email_templates/default.html', self.TYPE_PULL_REQUEST: 'email_templates/pull_request.html', + self.TYPE_PULL_REQUEST_COMMENT: 'email_templates/pull_request_comment.html', } def get_email_tmpl(self, type_, **kwargs): diff --git a/rhodecode/templates/email_templates/pull_request_comment.html b/rhodecode/templates/email_templates/pull_request_comment.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/email_templates/pull_request_comment.html @@ -0,0 +1,15 @@ +## -*- coding: utf-8 -*- +<%inherit file="main.html"/> + +User ${pr_comment_user} commented on pull request #${pr_id} for +repository ${pr_target_repo} + +
+${body} + +%if status_change: + New status -> ${status_change} +%endif +
+ +View this comment here: ${pr_comment_url}