Show More
@@ -368,18 +368,22 b' class ChangesetController(BaseRepoContro' | |||||
368 |
|
368 | |||
369 | @jsonify |
|
369 | @jsonify | |
370 | def comment(self, repo_name, revision): |
|
370 | def comment(self, repo_name, revision): | |
|
371 | status = request.POST.get('changeset_status') | |||
|
372 | change_status = request.POST.get('change_changeset_status') | |||
|
373 | ||||
371 | comm = ChangesetCommentsModel().create( |
|
374 | comm = ChangesetCommentsModel().create( | |
372 | text=request.POST.get('text'), |
|
375 | text=request.POST.get('text'), | |
373 | repo_id=c.rhodecode_db_repo.repo_id, |
|
376 | repo_id=c.rhodecode_db_repo.repo_id, | |
374 | user_id=c.rhodecode_user.user_id, |
|
377 | user_id=c.rhodecode_user.user_id, | |
375 | revision=revision, |
|
378 | revision=revision, | |
376 | f_path=request.POST.get('f_path'), |
|
379 | f_path=request.POST.get('f_path'), | |
377 | line_no=request.POST.get('line') |
|
380 | line_no=request.POST.get('line'), | |
|
381 | status_change=(ChangesetStatus.get_status_lbl(status) | |||
|
382 | if status and change_status else None) | |||
378 | ) |
|
383 | ) | |
379 |
|
384 | |||
380 | # get status if set ! |
|
385 | # get status if set ! | |
381 |
status |
|
386 | if status and change_status: | |
382 | if status and request.POST.get('change_changeset_status'): |
|
|||
383 | ChangesetStatusModel().set_status( |
|
387 | ChangesetStatusModel().set_status( | |
384 | c.rhodecode_db_repo.repo_id, |
|
388 | c.rhodecode_db_repo.repo_id, | |
385 | revision, |
|
389 | revision, |
@@ -52,9 +52,10 b' class ChangesetCommentsModel(BaseModel):' | |||||
52 | return user_objects |
|
52 | return user_objects | |
53 |
|
53 | |||
54 | def create(self, text, repo_id, user_id, revision, f_path=None, |
|
54 | def create(self, text, repo_id, user_id, revision, f_path=None, | |
55 | line_no=None): |
|
55 | line_no=None, status_change=None): | |
56 | """ |
|
56 | """ | |
57 | Creates new comment for changeset |
|
57 | Creates new comment for changeset. IF status_change is not none | |
|
58 | this comment is associated with a status change of changeset | |||
58 |
|
59 | |||
59 | :param text: |
|
60 | :param text: | |
60 | :param repo_id: |
|
61 | :param repo_id: | |
@@ -62,6 +63,7 b' class ChangesetCommentsModel(BaseModel):' | |||||
62 | :param revision: |
|
63 | :param revision: | |
63 | :param f_path: |
|
64 | :param f_path: | |
64 | :param line_no: |
|
65 | :param line_no: | |
|
66 | :param status_change: | |||
65 | """ |
|
67 | """ | |
66 |
|
68 | |||
67 | if text: |
|
69 | if text: | |
@@ -104,7 +106,8 b' class ChangesetCommentsModel(BaseModel):' | |||||
104 |
|
106 | |||
105 | NotificationModel().create( |
|
107 | NotificationModel().create( | |
106 | created_by=user_id, subject=subj, body=body, |
|
108 | created_by=user_id, subject=subj, body=body, | |
107 | recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT |
|
109 | recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT, | |
|
110 | email_kwargs={'status_change': status_change} | |||
108 | ) |
|
111 | ) | |
109 |
|
112 | |||
110 | mention_recipients = set(self._extract_mentions(body))\ |
|
113 | mention_recipients = set(self._extract_mentions(body))\ |
@@ -1256,9 +1256,13 b' class ChangesetStatus(Base, BaseModel):' | |||||
1256 | repo = relationship('Repository') |
|
1256 | repo = relationship('Repository') | |
1257 | comment = relationship('ChangesetComment', lazy='joined') |
|
1257 | comment = relationship('ChangesetComment', lazy='joined') | |
1258 |
|
1258 | |||
|
1259 | @classmethod | |||
|
1260 | def get_status_lbl(cls, value): | |||
|
1261 | return dict(cls.STATUSES).get(value) | |||
|
1262 | ||||
1259 | @property |
|
1263 | @property | |
1260 | def status_lbl(self): |
|
1264 | def status_lbl(self): | |
1261 |
return |
|
1265 | return ChangesetStatus.get_status_lbl(self.status) | |
1262 |
|
1266 | |||
1263 |
|
1267 | |||
1264 | class Notification(Base, BaseModel): |
|
1268 | class Notification(Base, BaseModel): |
@@ -108,6 +108,7 b' class NotificationModel(BaseModel):' | |||||
108 | email_subject = NotificationModel().make_description(notif, False) |
|
108 | email_subject = NotificationModel().make_description(notif, False) | |
109 | type_ = type_ |
|
109 | type_ = type_ | |
110 | email_body = body |
|
110 | email_body = body | |
|
111 | ## this is passed into template | |||
111 | kwargs = {'subject': subject, 'body': h.rst_w_mentions(body)} |
|
112 | kwargs = {'subject': subject, 'body': h.rst_w_mentions(body)} | |
112 | kwargs.update(email_kwargs) |
|
113 | kwargs.update(email_kwargs) | |
113 | email_body_html = EmailNotificationModel()\ |
|
114 | email_body_html = EmailNotificationModel()\ |
General Comments 0
You need to be logged in to leave comments.
Login now