# HG changeset patch # User Marcin Kuzminski # Date 2012-05-17 10:54:44 # Node ID e5c0f201ca0bd7420ea9e9fe11f7b06ac9ba5dd5 # Parent 8447d35b674e4916d6952710bb322470cda90072 Add changeset status change into emails diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -368,18 +368,22 @@ class ChangesetController(BaseRepoContro @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, diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -52,9 +52,10 @@ class ChangesetCommentsModel(BaseModel): 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: @@ -62,6 +63,7 @@ class ChangesetCommentsModel(BaseModel): :param revision: :param f_path: :param line_no: + :param status_change: """ if text: @@ -104,7 +106,8 @@ class ChangesetCommentsModel(BaseModel): 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))\ diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1256,9 +1256,13 @@ class ChangesetStatus(Base, BaseModel): 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): diff --git a/rhodecode/model/notification.py b/rhodecode/model/notification.py --- a/rhodecode/model/notification.py +++ b/rhodecode/model/notification.py @@ -108,6 +108,7 @@ class NotificationModel(BaseModel): 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()\ diff --git a/rhodecode/templates/email_templates/changeset_comment.html b/rhodecode/templates/email_templates/changeset_comment.html --- a/rhodecode/templates/email_templates/changeset_comment.html +++ b/rhodecode/templates/email_templates/changeset_comment.html @@ -4,3 +4,9 @@

${subject}

${body} + +% if status_change is not None: +
+ New status -> ${status_change} +
+% endif \ No newline at end of file