##// END OF EJS Templates
Add changeset status change into emails
marcink -
r2296:e5c0f201 codereview
parent child Browse files
Show More
@@ -368,18 +368,22 b' class ChangesetController(BaseRepoContro'
368 368
369 369 @jsonify
370 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 374 comm = ChangesetCommentsModel().create(
372 375 text=request.POST.get('text'),
373 376 repo_id=c.rhodecode_db_repo.repo_id,
374 377 user_id=c.rhodecode_user.user_id,
375 378 revision=revision,
376 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 385 # get status if set !
381 status = request.POST.get('changeset_status')
382 if status and request.POST.get('change_changeset_status'):
386 if status and change_status:
383 387 ChangesetStatusModel().set_status(
384 388 c.rhodecode_db_repo.repo_id,
385 389 revision,
@@ -52,9 +52,10 b' class ChangesetCommentsModel(BaseModel):'
52 52 return user_objects
53 53
54 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 60 :param text:
60 61 :param repo_id:
@@ -62,6 +63,7 b' class ChangesetCommentsModel(BaseModel):'
62 63 :param revision:
63 64 :param f_path:
64 65 :param line_no:
66 :param status_change:
65 67 """
66 68
67 69 if text:
@@ -104,7 +106,8 b' class ChangesetCommentsModel(BaseModel):'
104 106
105 107 NotificationModel().create(
106 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 113 mention_recipients = set(self._extract_mentions(body))\
@@ -1256,9 +1256,13 b' class ChangesetStatus(Base, BaseModel):'
1256 1256 repo = relationship('Repository')
1257 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 1263 @property
1260 1264 def status_lbl(self):
1261 return dict(self.STATUSES).get(self.status)
1265 return ChangesetStatus.get_status_lbl(self.status)
1262 1266
1263 1267
1264 1268 class Notification(Base, BaseModel):
@@ -108,6 +108,7 b' class NotificationModel(BaseModel):'
108 108 email_subject = NotificationModel().make_description(notif, False)
109 109 type_ = type_
110 110 email_body = body
111 ## this is passed into template
111 112 kwargs = {'subject': subject, 'body': h.rst_w_mentions(body)}
112 113 kwargs.update(email_kwargs)
113 114 email_body_html = EmailNotificationModel()\
@@ -4,3 +4,9 b''
4 4 <h4>${subject}</h4>
5 5
6 6 ${body}
7
8 % if status_change is not None:
9 <div>
10 New status -> ${status_change}
11 </div>
12 % endif No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now