Commits

Marcin Kuzminski  committed e5c0f20

Add changeset status change into emails

  • Participants
  • Parent commits 8447d35
  • Branches codereview

Comments (0)

Files changed (5)

File rhodecode/controllers/changeset.py

 
     @jsonify
     def comment(self, repo_name, revision):
+        status = request.POST.get('changeset_status')
+        change_status = request.POST.get('change_changeset_status')
+
         comm = ChangesetCommentsModel().create(
             text=request.POST.get('text'),
             repo_id=c.rhodecode_db_repo.repo_id,
             user_id=c.rhodecode_user.user_id,
             revision=revision,
             f_path=request.POST.get('f_path'),
-            line_no=request.POST.get('line')
+            line_no=request.POST.get('line'),
+            status_change=(ChangesetStatus.get_status_lbl(status) 
+                           if status and change_status else None)
         )
 
         # get status if set !
-        status = request.POST.get('changeset_status')
-        if status and request.POST.get('change_changeset_status'):
+        if status and change_status:
             ChangesetStatusModel().set_status(
                 c.rhodecode_db_repo.repo_id,
                 revision,

File rhodecode/model/comment.py

         return user_objects
 
     def create(self, text, repo_id, user_id, revision, f_path=None,
-               line_no=None):
+               line_no=None, status_change=None):
         """
-        Creates new comment for changeset
+        Creates new comment for changeset. IF status_change is not none
+        this comment is associated with a status change of changeset
 
         :param text:
         :param repo_id:
         :param revision:
         :param f_path:
         :param line_no:
+        :param status_change:
         """
 
         if text:
 
             NotificationModel().create(
               created_by=user_id, subject=subj, body=body,
-              recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT
+              recipients=recipients, type_=Notification.TYPE_CHANGESET_COMMENT,
+              email_kwargs={'status_change': status_change}
             )
 
             mention_recipients = set(self._extract_mentions(body))\

File rhodecode/model/db.py

     repo = relationship('Repository')
     comment = relationship('ChangesetComment', lazy='joined')
 
+    @classmethod
+    def get_status_lbl(cls, value):
+        return dict(cls.STATUSES).get(value)
+
     @property
     def status_lbl(self):
-        return dict(self.STATUSES).get(self.status)
+        return ChangesetStatus.get_status_lbl(self.status)
 
 
 class Notification(Base, BaseModel):

File rhodecode/model/notification.py

             email_subject = NotificationModel().make_description(notif, False)
             type_ = type_
             email_body = body
+            ## this is passed into template
             kwargs = {'subject': subject, 'body': h.rst_w_mentions(body)}
             kwargs.update(email_kwargs)
             email_body_html = EmailNotificationModel()\

File rhodecode/templates/email_templates/changeset_comment.html

 <h4>${subject}</h4>
 
 ${body}
+
+% if status_change is not None:
+<div>
+    New status -> ${status_change}
+</div>    
+% endif