aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/comment.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-09-05 00:08:38 +0200
committerMarcin Kuzminski <marcin@python-works.com>2012-09-05 00:08:38 +0200
commit3b03dcbd1a98486e617bfc8f68c7519fc902e0fc (patch)
treef149b939a33c49c997ed0e1b7cca48a7f6f118ee /rhodecode/model/comment.py
parentd2418205c3c746a806bc0fadfb7365a0db5f40ae (diff)
part2 of pull-request notification improvements
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model/comment.py')
-rw-r--r--rhodecode/model/comment.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py
index a7520b3a..d81aad6b 100644
--- 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