Changeset - e5c0f201ca0b
[Not reviewed]
codereview
0 5 0
Marcin Kuzminski - 14 years ago 2012-05-17 12:54:44
marcin@python-works.com
Add changeset status change into emails
5 files changed with 25 insertions and 7 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -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,
rhodecode/model/comment.py
Show inline comments
 
@@ -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))\
rhodecode/model/db.py
Show inline comments
 
@@ -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):
rhodecode/model/notification.py
Show inline comments
 
@@ -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()\
rhodecode/templates/email_templates/changeset_comment.html
Show inline comments
 
@@ -4,3 +4,9 @@
 
<h4>${subject}</h4>
 

	
 
${body}
 

	
 
% if status_change is not None:
 
<div>
 
    New status -> ${status_change}
 
</div>    
 
% endif
 
\ No newline at end of file
0 comments (0 inline, 0 general)