##// 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 125 recipients += [User.get_by_email(author_email)]
126 126 #pull request
127 127 elif pull_request:
128 subj = safe_unicode(
129 h.link_to('Re pull request: %(desc)s %(line)s' % \
130 {'desc': desc, 'line': line},
131 h.url('pullrequest_show',
128 _url = h.url('pullrequest_show',
132 129 repo_name=pull_request.other_repo.repo_name,
133 130 pull_request_id=pull_request.pull_request_id,
134 131 anchor='comment-%s' % comment.comment_id,
135 132 qualified=True,
136 133 )
137 )
134 subj = safe_unicode(
135 h.link_to('Re pull request: %(desc)s %(line)s' % \
136 {'desc': desc, 'line': line}, _url)
138 137 )
139 138
140 139 notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
@@ -144,22 +143,36 b' class ChangesetCommentsModel(BaseModel):'
144 143 # add pull request author
145 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 159 # create notification objects, and emails
148 160 NotificationModel().create(
149 161 created_by=user, subject=subj, body=body,
150 162 recipients=recipients, type_=notification_type,
151 email_kwargs={'status_change': status_change}
163 email_kwargs=kwargs
152 164 )
153 165
154 166 mention_recipients = set(self._extract_mentions(body))\
155 167 .difference(recipients)
156 168 if mention_recipients:
169 kwargs.update({'pr_mention': True})
157 170 subj = _('[Mention]') + ' ' + subj
158 171 NotificationModel().create(
159 172 created_by=user, subject=subj, body=body,
160 173 recipients=mention_recipients,
161 174 type_=notification_type,
162 email_kwargs={'status_change': status_change}
175 email_kwargs=kwargs
163 176 )
164 177
165 178 return comment
@@ -245,6 +245,7 b' class EmailNotificationModel(BaseModel):'
245 245 TYPE_PASSWORD_RESET = 'passoword_link'
246 246 TYPE_REGISTRATION = Notification.TYPE_REGISTRATION
247 247 TYPE_PULL_REQUEST = Notification.TYPE_PULL_REQUEST
248 TYPE_PULL_REQUEST_COMMENT = Notification.TYPE_PULL_REQUEST_COMMENT
248 249 TYPE_DEFAULT = 'default'
249 250
250 251 def __init__(self):
@@ -257,6 +258,7 b' class EmailNotificationModel(BaseModel):'
257 258 self.TYPE_REGISTRATION: 'email_templates/registration.html',
258 259 self.TYPE_DEFAULT: 'email_templates/default.html',
259 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 264 def get_email_tmpl(self, type_, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now