Show More
@@ -329,7 +329,7 b' class ChangesetController(BaseRepoContro' | |||||
329 | text = text or (_('Status change -> %s') |
|
329 | text = text or (_('Status change -> %s') | |
330 | % ChangesetStatus.get_status_lbl(status)) |
|
330 | % ChangesetStatus.get_status_lbl(status)) | |
331 |
|
331 | |||
332 | comm = ChangesetCommentsModel().create( |
|
332 | c.co = comm = ChangesetCommentsModel().create( | |
333 | text=text, |
|
333 | text=text, | |
334 | repo=c.rhodecode_db_repo.repo_id, |
|
334 | repo=c.rhodecode_db_repo.repo_id, | |
335 | user=c.rhodecode_user.user_id, |
|
335 | user=c.rhodecode_user.user_id, | |
@@ -371,12 +371,11 b' class ChangesetController(BaseRepoContro' | |||||
371 | if not request.environ.get('HTTP_X_PARTIAL_XHR'): |
|
371 | if not request.environ.get('HTTP_X_PARTIAL_XHR'): | |
372 | return redirect(h.url('changeset_home', repo_name=repo_name, |
|
372 | return redirect(h.url('changeset_home', repo_name=repo_name, | |
373 | revision=revision)) |
|
373 | revision=revision)) | |
374 |
|
374 | #only ajax below | ||
375 | data = { |
|
375 | data = { | |
376 | 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), |
|
376 | 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), | |
377 | } |
|
377 | } | |
378 | if comm: |
|
378 | if comm: | |
379 | c.co = comm |
|
|||
380 | data.update(comm.get_dict()) |
|
379 | data.update(comm.get_dict()) | |
381 | data.update({'rendered_text': |
|
380 | data.update({'rendered_text': | |
382 | render('changeset/changeset_comment_block.html')}) |
|
381 | render('changeset/changeset_comment_block.html')}) |
@@ -403,11 +403,15 b' class PullrequestsController(BaseRepoCon' | |||||
403 | status = request.POST.get('changeset_status') |
|
403 | status = request.POST.get('changeset_status') | |
404 | change_status = request.POST.get('change_changeset_status') |
|
404 | change_status = request.POST.get('change_changeset_status') | |
405 | text = request.POST.get('text') |
|
405 | text = request.POST.get('text') | |
|
406 | close_pr = request.POST.get('save_close') | |||
406 |
|
407 | |||
407 | allowed_to_change_status = self._get_is_allowed_change_status(pull_request) |
|
408 | allowed_to_change_status = self._get_is_allowed_change_status(pull_request) | |
408 | if status and change_status and allowed_to_change_status: |
|
409 | if status and change_status and allowed_to_change_status: | |
409 |
|
|
410 | _def = (_('status change -> %s') | |
410 | % ChangesetStatus.get_status_lbl(status)) |
|
411 | % ChangesetStatus.get_status_lbl(status)) | |
|
412 | if close_pr: | |||
|
413 | _def = _('Closing with') + ' ' + _def | |||
|
414 | text = text or _def | |||
411 | comm = ChangesetCommentsModel().create( |
|
415 | comm = ChangesetCommentsModel().create( | |
412 | text=text, |
|
416 | text=text, | |
413 | repo=c.rhodecode_db_repo.repo_id, |
|
417 | repo=c.rhodecode_db_repo.repo_id, | |
@@ -416,7 +420,9 b' class PullrequestsController(BaseRepoCon' | |||||
416 | f_path=request.POST.get('f_path'), |
|
420 | f_path=request.POST.get('f_path'), | |
417 | line_no=request.POST.get('line'), |
|
421 | line_no=request.POST.get('line'), | |
418 | status_change=(ChangesetStatus.get_status_lbl(status) |
|
422 | status_change=(ChangesetStatus.get_status_lbl(status) | |
419 | if status and change_status and allowed_to_change_status else None) |
|
423 | if status and change_status | |
|
424 | and allowed_to_change_status else None), | |||
|
425 | closing_pr=close_pr | |||
420 | ) |
|
426 | ) | |
421 |
|
427 | |||
422 | action_logger(self.rhodecode_user, |
|
428 | action_logger(self.rhodecode_user, | |
@@ -434,7 +440,7 b' class PullrequestsController(BaseRepoCon' | |||||
434 | pull_request=pull_request_id |
|
440 | pull_request=pull_request_id | |
435 | ) |
|
441 | ) | |
436 |
|
442 | |||
437 |
if |
|
443 | if close_pr: | |
438 | if status in ['rejected', 'approved']: |
|
444 | if status in ['rejected', 'approved']: | |
439 | PullRequestModel().close_pull_request(pull_request_id) |
|
445 | PullRequestModel().close_pull_request(pull_request_id) | |
440 | action_logger(self.rhodecode_user, |
|
446 | action_logger(self.rhodecode_user, |
@@ -35,6 +35,7 b' from rhodecode.model import BaseModel' | |||||
35 | from rhodecode.model.db import ChangesetComment, User, Repository, \ |
|
35 | from rhodecode.model.db import ChangesetComment, User, Repository, \ | |
36 | Notification, PullRequest |
|
36 | Notification, PullRequest | |
37 | from rhodecode.model.notification import NotificationModel |
|
37 | from rhodecode.model.notification import NotificationModel | |
|
38 | from rhodecode.model.meta import Session | |||
38 |
|
39 | |||
39 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
40 |
|
41 | |||
@@ -57,8 +58,103 b' class ChangesetCommentsModel(BaseModel):' | |||||
57 | user_objects.append(user_obj) |
|
58 | user_objects.append(user_obj) | |
58 | return user_objects |
|
59 | return user_objects | |
59 |
|
60 | |||
|
61 | def _get_notification_data(self, repo, comment, user, comment_text, | |||
|
62 | line_no=None, revision=None, pull_request=None, | |||
|
63 | status_change=None, closing_pr=False): | |||
|
64 | """ | |||
|
65 | Get notification data | |||
|
66 | ||||
|
67 | :param comment_text: | |||
|
68 | :param line: | |||
|
69 | :returns: tuple (subj,body,recipients,notification_type,email_kwargs) | |||
|
70 | """ | |||
|
71 | # make notification | |||
|
72 | body = comment_text # text of the comment | |||
|
73 | line = '' | |||
|
74 | if line_no: | |||
|
75 | line = _('on line %s') % line_no | |||
|
76 | ||||
|
77 | #changeset | |||
|
78 | if revision: | |||
|
79 | notification_type = Notification.TYPE_CHANGESET_COMMENT | |||
|
80 | cs = repo.scm_instance.get_changeset(revision) | |||
|
81 | desc = "%s" % (cs.short_id) | |||
|
82 | ||||
|
83 | _url = h.url('changeset_home', | |||
|
84 | repo_name=repo.repo_name, | |||
|
85 | revision=revision, | |||
|
86 | anchor='comment-%s' % comment.comment_id, | |||
|
87 | qualified=True, | |||
|
88 | ) | |||
|
89 | subj = safe_unicode( | |||
|
90 | h.link_to('Re changeset: %(desc)s %(line)s' % \ | |||
|
91 | {'desc': desc, 'line': line}, | |||
|
92 | _url) | |||
|
93 | ) | |||
|
94 | email_subject = 'User %s commented on changeset %s' % \ | |||
|
95 | (user.username, h.short_id(revision)) | |||
|
96 | # get the current participants of this changeset | |||
|
97 | recipients = ChangesetComment.get_users(revision=revision) | |||
|
98 | # add changeset author if it's in rhodecode system | |||
|
99 | cs_author = User.get_from_cs_author(cs.author) | |||
|
100 | if not cs_author: | |||
|
101 | #use repo owner if we cannot extract the author correctly | |||
|
102 | cs_author = repo.user | |||
|
103 | recipients += [cs_author] | |||
|
104 | email_kwargs = { | |||
|
105 | 'status_change': status_change, | |||
|
106 | 'cs_comment_user': h.person(user.email), | |||
|
107 | 'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name, | |||
|
108 | qualified=True), | |||
|
109 | 'cs_comment_url': _url, | |||
|
110 | 'raw_id': revision, | |||
|
111 | 'message': cs.message | |||
|
112 | } | |||
|
113 | #pull request | |||
|
114 | elif pull_request: | |||
|
115 | notification_type = Notification.TYPE_PULL_REQUEST_COMMENT | |||
|
116 | desc = comment.pull_request.title | |||
|
117 | _url = h.url('pullrequest_show', | |||
|
118 | repo_name=pull_request.other_repo.repo_name, | |||
|
119 | pull_request_id=pull_request.pull_request_id, | |||
|
120 | anchor='comment-%s' % comment.comment_id, | |||
|
121 | qualified=True, | |||
|
122 | ) | |||
|
123 | subj = safe_unicode( | |||
|
124 | h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \ | |||
|
125 | {'desc': desc, | |||
|
126 | 'pr_id': comment.pull_request.pull_request_id, | |||
|
127 | 'line': line}, | |||
|
128 | _url) | |||
|
129 | ) | |||
|
130 | email_subject = 'User %s commented on pull request #%s' % \ | |||
|
131 | (user.username, comment.pull_request.pull_request_id) | |||
|
132 | # get the current participants of this pull request | |||
|
133 | recipients = ChangesetComment.get_users(pull_request_id= | |||
|
134 | pull_request.pull_request_id) | |||
|
135 | # add pull request author | |||
|
136 | recipients += [pull_request.author] | |||
|
137 | ||||
|
138 | # add the reviewers to notification | |||
|
139 | recipients += [x.user for x in pull_request.reviewers] | |||
|
140 | ||||
|
141 | #set some variables for email notification | |||
|
142 | email_kwargs = { | |||
|
143 | 'pr_id': pull_request.pull_request_id, | |||
|
144 | 'status_change': status_change, | |||
|
145 | 'closing_pr': closing_pr, | |||
|
146 | 'pr_comment_url': _url, | |||
|
147 | 'pr_comment_user': h.person(user.email), | |||
|
148 | 'pr_target_repo': h.url('summary_home', | |||
|
149 | repo_name=pull_request.other_repo.repo_name, | |||
|
150 | qualified=True) | |||
|
151 | } | |||
|
152 | ||||
|
153 | return subj, body, recipients, notification_type, email_kwargs, email_subject | |||
|
154 | ||||
60 | def create(self, text, repo, user, revision=None, pull_request=None, |
|
155 | def create(self, text, repo, user, revision=None, pull_request=None, | |
61 |
f_path=None, line_no=None, status_change=None, |
|
156 | f_path=None, line_no=None, status_change=None, closing_pr=False, | |
|
157 | send_email=True): | |||
62 | """ |
|
158 | """ | |
63 | Creates new comment for changeset or pull request. |
|
159 | Creates new comment for changeset or pull request. | |
64 | IF status_change is not none this comment is associated with a |
|
160 | IF status_change is not none this comment is associated with a | |
@@ -72,9 +168,11 b' class ChangesetCommentsModel(BaseModel):' | |||||
72 | :param f_path: |
|
168 | :param f_path: | |
73 | :param line_no: |
|
169 | :param line_no: | |
74 | :param status_change: |
|
170 | :param status_change: | |
|
171 | :param closing_pr: | |||
75 | :param send_email: |
|
172 | :param send_email: | |
76 | """ |
|
173 | """ | |
77 | if not text: |
|
174 | if not text: | |
|
175 | log.warning('Missing text for comment, skipping...') | |||
78 | return |
|
176 | return | |
79 |
|
177 | |||
80 | repo = self._get_repo(repo) |
|
178 | repo = self._get_repo(repo) | |
@@ -87,8 +185,6 b' class ChangesetCommentsModel(BaseModel):' | |||||
87 | comment.line_no = line_no |
|
185 | comment.line_no = line_no | |
88 |
|
186 | |||
89 | if revision: |
|
187 | if revision: | |
90 | cs = repo.scm_instance.get_changeset(revision) |
|
|||
91 | desc = "%s - %s" % (cs.short_id, h.shorter(cs.message, 256)) |
|
|||
92 | comment.revision = revision |
|
188 | comment.revision = revision | |
93 | elif pull_request: |
|
189 | elif pull_request: | |
94 | pull_request = self.__get_pull_request(pull_request) |
|
190 | pull_request = self.__get_pull_request(pull_request) | |
@@ -96,82 +192,24 b' class ChangesetCommentsModel(BaseModel):' | |||||
96 | else: |
|
192 | else: | |
97 | raise Exception('Please specify revision or pull_request_id') |
|
193 | raise Exception('Please specify revision or pull_request_id') | |
98 |
|
194 | |||
99 |
|
|
195 | Session().add(comment) | |
100 |
|
|
196 | Session().flush() | |
101 |
|
||||
102 | # make notification |
|
|||
103 | line = '' |
|
|||
104 | body = text |
|
|||
105 |
|
||||
106 | #changeset |
|
|||
107 | if revision: |
|
|||
108 | if line_no: |
|
|||
109 | line = _('on line %s') % line_no |
|
|||
110 | subj = safe_unicode( |
|
|||
111 | h.link_to('Re commit: %(desc)s %(line)s' % \ |
|
|||
112 | {'desc': desc, 'line': line}, |
|
|||
113 | h.url('changeset_home', repo_name=repo.repo_name, |
|
|||
114 | revision=revision, |
|
|||
115 | anchor='comment-%s' % comment.comment_id, |
|
|||
116 | qualified=True, |
|
|||
117 | ) |
|
|||
118 | ) |
|
|||
119 | ) |
|
|||
120 | notification_type = Notification.TYPE_CHANGESET_COMMENT |
|
|||
121 | # get the current participants of this changeset |
|
|||
122 | recipients = ChangesetComment.get_users(revision=revision) |
|
|||
123 | # add changeset author if it's in rhodecode system |
|
|||
124 | cs_author = User.get_from_cs_author(cs.author) |
|
|||
125 | if not cs_author: |
|
|||
126 | #use repo owner if we cannot extract the author correctly |
|
|||
127 | cs_author = repo.user |
|
|||
128 | recipients += [cs_author] |
|
|||
129 | email_kwargs = { |
|
|||
130 | 'status_change': status_change, |
|
|||
131 | } |
|
|||
132 | #pull request |
|
|||
133 | elif pull_request: |
|
|||
134 | _url = h.url('pullrequest_show', |
|
|||
135 | repo_name=pull_request.other_repo.repo_name, |
|
|||
136 | pull_request_id=pull_request.pull_request_id, |
|
|||
137 | anchor='comment-%s' % comment.comment_id, |
|
|||
138 | qualified=True, |
|
|||
139 | ) |
|
|||
140 | subj = safe_unicode( |
|
|||
141 | h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \ |
|
|||
142 | {'desc': comment.pull_request.title, |
|
|||
143 | 'pr_id': comment.pull_request.pull_request_id, |
|
|||
144 | 'line': line}, |
|
|||
145 | _url) |
|
|||
146 | ) |
|
|||
147 |
|
||||
148 | notification_type = Notification.TYPE_PULL_REQUEST_COMMENT |
|
|||
149 | # get the current participants of this pull request |
|
|||
150 | recipients = ChangesetComment.get_users(pull_request_id= |
|
|||
151 | pull_request.pull_request_id) |
|
|||
152 | # add pull request author |
|
|||
153 | recipients += [pull_request.author] |
|
|||
154 |
|
||||
155 | # add the reviewers to notification |
|
|||
156 | recipients += [x.user for x in pull_request.reviewers] |
|
|||
157 |
|
||||
158 | #set some variables for email notification |
|
|||
159 | email_kwargs = { |
|
|||
160 | 'pr_id': pull_request.pull_request_id, |
|
|||
161 | 'status_change': status_change, |
|
|||
162 | 'pr_comment_url': _url, |
|
|||
163 | 'pr_comment_user': h.person(user.email), |
|
|||
164 | 'pr_target_repo': h.url('summary_home', |
|
|||
165 | repo_name=pull_request.other_repo.repo_name, |
|
|||
166 | qualified=True) |
|
|||
167 | } |
|
|||
168 |
|
197 | |||
169 | if send_email: |
|
198 | if send_email: | |
|
199 | (subj, body, recipients, notification_type, | |||
|
200 | email_kwargs, email_subject) = self._get_notification_data( | |||
|
201 | repo, comment, user, | |||
|
202 | comment_text=text, | |||
|
203 | line_no=line_no, | |||
|
204 | revision=revision, | |||
|
205 | pull_request=pull_request, | |||
|
206 | status_change=status_change, | |||
|
207 | closing_pr=closing_pr) | |||
170 | # create notification objects, and emails |
|
208 | # create notification objects, and emails | |
171 | NotificationModel().create( |
|
209 | NotificationModel().create( | |
172 | created_by=user, subject=subj, body=body, |
|
210 | created_by=user, subject=subj, body=body, | |
173 | recipients=recipients, type_=notification_type, |
|
211 | recipients=recipients, type_=notification_type, | |
174 | email_kwargs=email_kwargs |
|
212 | email_kwargs=email_kwargs, email_subject=email_subject | |
175 | ) |
|
213 | ) | |
176 |
|
214 | |||
177 | mention_recipients = set(self._extract_mentions(body))\ |
|
215 | mention_recipients = set(self._extract_mentions(body))\ | |
@@ -195,7 +233,7 b' class ChangesetCommentsModel(BaseModel):' | |||||
195 | :param comment_id: |
|
233 | :param comment_id: | |
196 | """ |
|
234 | """ | |
197 | comment = self.__get_changeset_comment(comment) |
|
235 | comment = self.__get_changeset_comment(comment) | |
198 |
|
|
236 | Session().delete(comment) | |
199 |
|
237 | |||
200 | return comment |
|
238 | return comment | |
201 |
|
239 | |||
@@ -204,11 +242,8 b' class ChangesetCommentsModel(BaseModel):' | |||||
204 | Get's main comments based on revision or pull_request_id |
|
242 | Get's main comments based on revision or pull_request_id | |
205 |
|
243 | |||
206 | :param repo_id: |
|
244 | :param repo_id: | |
207 | :type repo_id: |
|
|||
208 | :param revision: |
|
245 | :param revision: | |
209 | :type revision: |
|
|||
210 | :param pull_request: |
|
246 | :param pull_request: | |
211 | :type pull_request: |
|
|||
212 | """ |
|
247 | """ | |
213 |
|
248 | |||
214 | q = ChangesetComment.query()\ |
|
249 | q = ChangesetComment.query()\ | |
@@ -226,7 +261,7 b' class ChangesetCommentsModel(BaseModel):' | |||||
226 | return q.all() |
|
261 | return q.all() | |
227 |
|
262 | |||
228 | def get_inline_comments(self, repo_id, revision=None, pull_request=None): |
|
263 | def get_inline_comments(self, repo_id, revision=None, pull_request=None): | |
229 |
q = |
|
264 | q = Session().query(ChangesetComment)\ | |
230 | .filter(ChangesetComment.repo_id == repo_id)\ |
|
265 | .filter(ChangesetComment.repo_id == repo_id)\ | |
231 | .filter(ChangesetComment.line_no != None)\ |
|
266 | .filter(ChangesetComment.line_no != None)\ | |
232 | .filter(ChangesetComment.f_path != None)\ |
|
267 | .filter(ChangesetComment.f_path != None)\ |
@@ -35,6 +35,7 b' import rhodecode' | |||||
35 | from rhodecode.lib import helpers as h |
|
35 | from rhodecode.lib import helpers as h | |
36 | from rhodecode.model import BaseModel |
|
36 | from rhodecode.model import BaseModel | |
37 | from rhodecode.model.db import Notification, User, UserNotification |
|
37 | from rhodecode.model.db import Notification, User, UserNotification | |
|
38 | from rhodecode.model.meta import Session | |||
38 |
|
39 | |||
39 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
40 |
|
41 | |||
@@ -55,7 +56,7 b' class NotificationModel(BaseModel):' | |||||
55 |
|
56 | |||
56 | def create(self, created_by, subject, body, recipients=None, |
|
57 | def create(self, created_by, subject, body, recipients=None, | |
57 | type_=Notification.TYPE_MESSAGE, with_email=True, |
|
58 | type_=Notification.TYPE_MESSAGE, with_email=True, | |
58 | email_kwargs={}): |
|
59 | email_kwargs={}, email_subject=None): | |
59 | """ |
|
60 | """ | |
60 |
|
61 | |||
61 | Creates notification of given type |
|
62 | Creates notification of given type | |
@@ -69,6 +70,7 b' class NotificationModel(BaseModel):' | |||||
69 | :param type_: type of notification |
|
70 | :param type_: type of notification | |
70 | :param with_email: send email with this notification |
|
71 | :param with_email: send email with this notification | |
71 | :param email_kwargs: additional dict to pass as args to email template |
|
72 | :param email_kwargs: additional dict to pass as args to email template | |
|
73 | :param email_subject: use given subject as email subject | |||
72 | """ |
|
74 | """ | |
73 | from rhodecode.lib.celerylib import tasks, run_task |
|
75 | from rhodecode.lib.celerylib import tasks, run_task | |
74 |
|
76 | |||
@@ -106,7 +108,8 b' class NotificationModel(BaseModel):' | |||||
106 |
|
108 | |||
107 | # send email with notification to all other participants |
|
109 | # send email with notification to all other participants | |
108 | for rec in rec_objs: |
|
110 | for rec in rec_objs: | |
109 | email_subject = NotificationModel().make_description(notif, False) |
|
111 | if not email_subject: | |
|
112 | email_subject = NotificationModel().make_description(notif, show_age=False) | |||
110 | type_ = type_ |
|
113 | type_ = type_ | |
111 | email_body = body |
|
114 | email_body = body | |
112 | ## this is passed into template |
|
115 | ## this is passed into template | |
@@ -131,7 +134,7 b' class NotificationModel(BaseModel):' | |||||
131 | .filter(UserNotification.notification |
|
134 | .filter(UserNotification.notification | |
132 | == notification)\ |
|
135 | == notification)\ | |
133 | .one() |
|
136 | .one() | |
134 |
|
|
137 | Session().delete(obj) | |
135 | return True |
|
138 | return True | |
136 | except Exception: |
|
139 | except Exception: | |
137 | log.error(traceback.format_exc()) |
|
140 | log.error(traceback.format_exc()) | |
@@ -142,7 +145,6 b' class NotificationModel(BaseModel):' | |||||
142 | Get mentions for given user, filter them if filter dict is given |
|
145 | Get mentions for given user, filter them if filter dict is given | |
143 |
|
146 | |||
144 | :param user: |
|
147 | :param user: | |
145 | :type user: |
|
|||
146 | :param filter: |
|
148 | :param filter: | |
147 | """ |
|
149 | """ | |
148 | user = self._get_user(user) |
|
150 | user = self._get_user(user) | |
@@ -168,7 +170,7 b' class NotificationModel(BaseModel):' | |||||
168 | == notification)\ |
|
170 | == notification)\ | |
169 | .one() |
|
171 | .one() | |
170 | obj.read = True |
|
172 | obj.read = True | |
171 |
|
|
173 | Session().add(obj) | |
172 | return True |
|
174 | return True | |
173 | except Exception: |
|
175 | except Exception: | |
174 | log.error(traceback.format_exc()) |
|
176 | log.error(traceback.format_exc()) | |
@@ -188,7 +190,7 b' class NotificationModel(BaseModel):' | |||||
188 | # update on joined tables :( |
|
190 | # update on joined tables :( | |
189 | for obj in q.all(): |
|
191 | for obj in q.all(): | |
190 | obj.read = True |
|
192 | obj.read = True | |
191 |
|
|
193 | Session().add(obj) | |
192 |
|
194 | |||
193 | def get_unread_cnt_for_user(self, user): |
|
195 | def get_unread_cnt_for_user(self, user): | |
194 | user = self._get_user(user) |
|
196 | user = self._get_user(user) | |
@@ -218,7 +220,7 b' class NotificationModel(BaseModel):' | |||||
218 | #alias |
|
220 | #alias | |
219 | _n = notification |
|
221 | _n = notification | |
220 | _map = { |
|
222 | _map = { | |
221 |
_n.TYPE_CHANGESET_COMMENT: _('commented on c |
|
223 | _n.TYPE_CHANGESET_COMMENT: _('commented on changeset at %(when)s'), | |
222 | _n.TYPE_MESSAGE: _('sent message at %(when)s'), |
|
224 | _n.TYPE_MESSAGE: _('sent message at %(when)s'), | |
223 | _n.TYPE_MENTION: _('mentioned you at %(when)s'), |
|
225 | _n.TYPE_MENTION: _('mentioned you at %(when)s'), | |
224 | _n.TYPE_REGISTRATION: _('registered in RhodeCode at %(when)s'), |
|
226 | _n.TYPE_REGISTRATION: _('registered in RhodeCode at %(when)s'), |
@@ -75,13 +75,13 b' class PullRequestModel(BaseModel):' | |||||
75 | new.title = title |
|
75 | new.title = title | |
76 | new.description = description |
|
76 | new.description = description | |
77 | new.author = created_by_user |
|
77 | new.author = created_by_user | |
78 |
|
|
78 | Session().add(new) | |
79 | Session().flush() |
|
79 | Session().flush() | |
80 | #members |
|
80 | #members | |
81 | for member in set(reviewers): |
|
81 | for member in set(reviewers): | |
82 | _usr = self._get_user(member) |
|
82 | _usr = self._get_user(member) | |
83 | reviewer = PullRequestReviewers(_usr, new) |
|
83 | reviewer = PullRequestReviewers(_usr, new) | |
84 |
|
|
84 | Session().add(reviewer) | |
85 |
|
85 | |||
86 | #reset state to under-review |
|
86 | #reset state to under-review | |
87 | ChangesetStatusModel().set_status( |
|
87 | ChangesetStatusModel().set_status( | |
@@ -90,7 +90,8 b' class PullRequestModel(BaseModel):' | |||||
90 | user=created_by_user, |
|
90 | user=created_by_user, | |
91 | pull_request=new |
|
91 | pull_request=new | |
92 | ) |
|
92 | ) | |
93 |
|
93 | revision_data = [(x.raw_id, x.message) | ||
|
94 | for x in map(org_repo.get_changeset, revisions)] | |||
94 | #notification to reviewers |
|
95 | #notification to reviewers | |
95 | notif = NotificationModel() |
|
96 | notif = NotificationModel() | |
96 |
|
97 | |||
@@ -114,7 +115,7 b' class PullRequestModel(BaseModel):' | |||||
114 | 'pr_repo_url': h.url('summary_home', repo_name=other_repo.repo_name, |
|
115 | 'pr_repo_url': h.url('summary_home', repo_name=other_repo.repo_name, | |
115 | qualified=True,), |
|
116 | qualified=True,), | |
116 | 'pr_url': pr_url, |
|
117 | 'pr_url': pr_url, | |
117 |
'pr_revisions': revision |
|
118 | 'pr_revisions': revision_data | |
118 | } |
|
119 | } | |
119 |
|
120 | |||
120 | notif.create(created_by=created_by_user, subject=subject, body=body, |
|
121 | notif.create(created_by=created_by_user, subject=subject, body=body, | |
@@ -140,7 +141,7 b' class PullRequestModel(BaseModel):' | |||||
140 | for uid in to_add: |
|
141 | for uid in to_add: | |
141 | _usr = self._get_user(uid) |
|
142 | _usr = self._get_user(uid) | |
142 | reviewer = PullRequestReviewers(_usr, pull_request) |
|
143 | reviewer = PullRequestReviewers(_usr, pull_request) | |
143 |
|
|
144 | Session().add(reviewer) | |
144 |
|
145 | |||
145 | for uid in to_remove: |
|
146 | for uid in to_remove: | |
146 | reviewer = PullRequestReviewers.query()\ |
|
147 | reviewer = PullRequestReviewers.query()\ | |
@@ -148,7 +149,7 b' class PullRequestModel(BaseModel):' | |||||
148 | PullRequestReviewers.pull_request==pull_request)\ |
|
149 | PullRequestReviewers.pull_request==pull_request)\ | |
149 | .scalar() |
|
150 | .scalar() | |
150 | if reviewer: |
|
151 | if reviewer: | |
151 |
|
|
152 | Session().delete(reviewer) | |
152 |
|
153 | |||
153 | def delete(self, pull_request): |
|
154 | def delete(self, pull_request): | |
154 | pull_request = self.__get_pull_request(pull_request) |
|
155 | pull_request = self.__get_pull_request(pull_request) | |
@@ -158,7 +159,7 b' class PullRequestModel(BaseModel):' | |||||
158 | pull_request = self.__get_pull_request(pull_request) |
|
159 | pull_request = self.__get_pull_request(pull_request) | |
159 | pull_request.status = PullRequest.STATUS_CLOSED |
|
160 | pull_request.status = PullRequest.STATUS_CLOSED | |
160 | pull_request.updated_on = datetime.datetime.now() |
|
161 | pull_request.updated_on = datetime.datetime.now() | |
161 |
|
|
162 | Session().add(pull_request) | |
162 |
|
163 | |||
163 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref): |
|
164 | def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref): | |
164 | """ |
|
165 | """ |
@@ -1,12 +1,17 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="main.html"/> |
|
2 | <%inherit file="main.html"/> | |
3 |
|
3 | ##message from user goes here | ||
4 | <h4>${subject}</h4> |
|
4 | <p> | |
5 |
|
5 | ${cs_comment_user}: <br/> | ||
6 | ${body} |
|
6 | ${body} | |
|
7 | </p> | |||
|
8 | %if status_change: | |||
|
9 | <span>${_('New status')} -> ${status_change}</span> | |||
|
10 | %endif | |||
|
11 | <div>${_('View this comment here')}: ${cs_comment_url}</div> | |||
7 |
|
12 | |||
8 | % if status_change is not None: |
|
13 | <pre> | |
9 | <div> |
|
14 | ${_('Repo')}: ${cs_target_repo} | |
10 | ${_('New status')} -> ${status_change} |
|
15 | ${_('Changeset')}: ${h.short_id(raw_id)} | |
11 | </div> |
|
16 | ${_('desc')}: ${h.shorter(message, 256)} | |
12 | % endif |
|
17 | </pre> |
@@ -10,8 +10,10 b'' | |||||
10 | </p> |
|
10 | </p> | |
11 |
|
11 | |||
12 | <div>${_('revisions for reviewing')}</div> |
|
12 | <div>${_('revisions for reviewing')}</div> | |
13 | <ul> |
|
13 | <pre> | |
14 | %for r in pr_revisions: |
|
14 | %for r,r_msg in pr_revisions: | |
15 | <li>${r}</li> |
|
15 | ${h.short_id(r)}: | |
|
16 | ${h.shorter(r_msg, 256)} | |||
|
17 | ||||
16 | %endfor |
|
18 | %endfor | |
17 | </ul> |
|
19 | </pre> |
@@ -1,13 +1,18 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="main.html"/> |
|
2 | <%inherit file="main.html"/> | |
3 |
|
3 | ${_('Pull request #%s for repository %s') % (pr_id, pr_target_repo) |n} | ||
4 | ${_('User %s commented on pull request #%s for repository %s') % ('<b>%s</b>' % pr_comment_user, pr_id, pr_target_repo) |n} |
|
4 | ##message from user goes here | |
|
5 | <p> | |||
|
6 | ${pr_comment_user}: <br/> | |||
|
7 | ${body} | |||
|
8 | </p> | |||
5 | <div>${_('View this comment here')}: ${pr_comment_url}</div> |
|
9 | <div>${_('View this comment here')}: ${pr_comment_url}</div> | |
6 |
|
10 | |||
7 | <p> |
|
|||
8 | ${body} |
|
|||
9 |
|
||||
10 | %if status_change: |
|
11 | %if status_change: | |
|
12 | %if closing_pr: | |||
|
13 | <span>${_('Closing pull request with status')} -> ${status_change}</span> | |||
|
14 | %else: | |||
11 |
|
|
15 | <span>${_('New status')} -> ${status_change}</span> | |
12 | %endif |
|
16 | %endif | |
|
17 | %endif | |||
13 | </p> |
|
18 | </p> |
@@ -30,7 +30,7 b'' | |||||
30 | <span style="font-size: 20px"> |
|
30 | <span style="font-size: 20px"> | |
31 | ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref',c.default_org_ref,c.org_refs,class_='refs')} |
|
31 | ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref',c.default_org_ref,c.org_refs,class_='refs')} | |
32 | </span> |
|
32 | </span> | |
33 |
<div style="padding:5px 3px 3px |
|
33 | <div style="padding:5px 3px 3px 20px;">${c.rhodecode_db_repo.description}</div> | |
34 | </div> |
|
34 | </div> | |
35 | <div style="clear:both;padding-top: 10px"></div> |
|
35 | <div style="clear:both;padding-top: 10px"></div> | |
36 | </div> |
|
36 | </div> | |
@@ -44,7 +44,7 b'' | |||||
44 | <span style="font-size: 20px"> |
|
44 | <span style="font-size: 20px"> | |
45 | ${h.select('other_repo',c.default_other_repo,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_other_ref,c.default_other_refs,class_='refs')} |
|
45 | ${h.select('other_repo',c.default_other_repo,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_other_ref,c.default_other_refs,class_='refs')} | |
46 | </span> |
|
46 | </span> | |
47 |
<div id="other_repo_desc" style="padding:5px 3px 3px |
|
47 | <div id="other_repo_desc" style="padding:5px 3px 3px 20px;"></div> | |
48 | </div> |
|
48 | </div> | |
49 | <div style="clear:both;padding-top: 10px"></div> |
|
49 | <div style="clear:both;padding-top: 10px"></div> | |
50 | </div> |
|
50 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now