##// END OF EJS Templates
part2 of pull-request notification improvements
marcink -
r2802:0a623ec2 beta
parent child Browse files
Show More
@@ -0,0 +1,15 b''
1 ## -*- coding: utf-8 -*-
2 <%inherit file="main.html"/>
3
4 User <b>${pr_comment_user}</b> commented on pull request #${pr_id} for
5 repository ${pr_target_repo}
6
7 <p>
8 ${body}
9
10 %if status_change:
11 <span>New status -> ${status_change}</span>
12 %endif
13 </p>
14
15 View this comment here: ${pr_comment_url}
@@ -125,16 +125,15 b' class ChangesetCommentsModel(BaseModel):'
125 recipients += [User.get_by_email(author_email)]
125 recipients += [User.get_by_email(author_email)]
126 #pull request
126 #pull request
127 elif pull_request:
127 elif pull_request:
128 _url = h.url('pullrequest_show',
129 repo_name=pull_request.other_repo.repo_name,
130 pull_request_id=pull_request.pull_request_id,
131 anchor='comment-%s' % comment.comment_id,
132 qualified=True,
133 )
128 subj = safe_unicode(
134 subj = safe_unicode(
129 h.link_to('Re pull request: %(desc)s %(line)s' % \
135 h.link_to('Re pull request: %(desc)s %(line)s' % \
130 {'desc': desc, 'line': line},
136 {'desc': desc, 'line': line}, _url)
131 h.url('pullrequest_show',
132 repo_name=pull_request.other_repo.repo_name,
133 pull_request_id=pull_request.pull_request_id,
134 anchor='comment-%s' % comment.comment_id,
135 qualified=True,
136 )
137 )
138 )
137 )
139
138
140 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
139 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
@@ -144,22 +143,36 b' class ChangesetCommentsModel(BaseModel):'
144 # add pull request author
143 # add pull request author
145 recipients += [pull_request.author]
144 recipients += [pull_request.author]
146
145
146 # add the reviewers to notification
147 recipients += [x.user for x in pull_request.reviewers]
148
149 #set some variables for email notification
150 kwargs = {
151 'pr_id': pull_request.pull_request_id,
152 'status_change': status_change,
153 'pr_comment_url': _url,
154 'pr_comment_user': h.person(user.email),
155 'pr_target_repo': h.url('summary_home',
156 repo_name=pull_request.other_repo.repo_name,
157 qualified=True)
158 }
147 # create notification objects, and emails
159 # create notification objects, and emails
148 NotificationModel().create(
160 NotificationModel().create(
149 created_by=user, subject=subj, body=body,
161 created_by=user, subject=subj, body=body,
150 recipients=recipients, type_=notification_type,
162 recipients=recipients, type_=notification_type,
151 email_kwargs={'status_change': status_change}
163 email_kwargs=kwargs
152 )
164 )
153
165
154 mention_recipients = set(self._extract_mentions(body))\
166 mention_recipients = set(self._extract_mentions(body))\
155 .difference(recipients)
167 .difference(recipients)
156 if mention_recipients:
168 if mention_recipients:
169 kwargs.update({'pr_mention': True})
157 subj = _('[Mention]') + ' ' + subj
170 subj = _('[Mention]') + ' ' + subj
158 NotificationModel().create(
171 NotificationModel().create(
159 created_by=user, subject=subj, body=body,
172 created_by=user, subject=subj, body=body,
160 recipients=mention_recipients,
173 recipients=mention_recipients,
161 type_=notification_type,
174 type_=notification_type,
162 email_kwargs={'status_change': status_change}
175 email_kwargs=kwargs
163 )
176 )
164
177
165 return comment
178 return comment
@@ -245,6 +245,7 b' class EmailNotificationModel(BaseModel):'
245 TYPE_PASSWORD_RESET = 'passoword_link'
245 TYPE_PASSWORD_RESET = 'passoword_link'
246 TYPE_REGISTRATION = Notification.TYPE_REGISTRATION
246 TYPE_REGISTRATION = Notification.TYPE_REGISTRATION
247 TYPE_PULL_REQUEST = Notification.TYPE_PULL_REQUEST
247 TYPE_PULL_REQUEST = Notification.TYPE_PULL_REQUEST
248 TYPE_PULL_REQUEST_COMMENT = Notification.TYPE_PULL_REQUEST_COMMENT
248 TYPE_DEFAULT = 'default'
249 TYPE_DEFAULT = 'default'
249
250
250 def __init__(self):
251 def __init__(self):
@@ -257,6 +258,7 b' class EmailNotificationModel(BaseModel):'
257 self.TYPE_REGISTRATION: 'email_templates/registration.html',
258 self.TYPE_REGISTRATION: 'email_templates/registration.html',
258 self.TYPE_DEFAULT: 'email_templates/default.html',
259 self.TYPE_DEFAULT: 'email_templates/default.html',
259 self.TYPE_PULL_REQUEST: 'email_templates/pull_request.html',
260 self.TYPE_PULL_REQUEST: 'email_templates/pull_request.html',
261 self.TYPE_PULL_REQUEST_COMMENT: 'email_templates/pull_request_comment.html',
260 }
262 }
261
263
262 def get_email_tmpl(self, type_, **kwargs):
264 def get_email_tmpl(self, type_, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now