Changeset - 32a283e5fd0d
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2013-01-29 22:40:29
marcin@python-works.com
Don't send notification email for auto-status changes
2 files changed with 19 insertions and 15 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/changeset_status.py
Show inline comments
 
@@ -129,16 +129,17 @@ class ChangesetStatusModel(BaseModel):
 
        repo = self._get_repo(repo)
 

	
 
        q = ChangesetStatus.query()
 
        if not comment:
 
            from rhodecode.model.comment import ChangesetCommentsModel
 
            comment = ChangesetCommentsModel().create(
 
                text='Auto status change',
 
                text='Auto status change to %s' % status,
 
                repo=repo,
 
                user=user,
 
                pull_request=pull_request,
 
                send_email=False
 
            )
 
        if revision:
 
            q = q.filter(ChangesetStatus.repo == repo)
 
            q = q.filter(ChangesetStatus.revision == revision)
 
        elif pull_request:
 
            pull_request = self.__get_pull_request(pull_request)
rhodecode/model/comment.py
Show inline comments
 
@@ -55,13 +55,13 @@ class ChangesetCommentsModel(BaseModel):
 
            user_obj = User.get_by_username(username, case_insensitive=True)
 
            if user_obj:
 
                user_objects.append(user_obj)
 
        return user_objects
 

	
 
    def create(self, text, repo, user, revision=None, pull_request=None,
 
               f_path=None, line_no=None, status_change=None):
 
               f_path=None, line_no=None, status_change=None, send_email=True):
 
        """
 
        Creates new comment for changeset or pull request.
 
        IF status_change is not none this comment is associated with a
 
        status change of changeset or changesets associated with pull request
 

	
 
        :param text:
 
@@ -69,12 +69,13 @@ class ChangesetCommentsModel(BaseModel):
 
        :param user:
 
        :param revision:
 
        :param pull_request:
 
        :param f_path:
 
        :param line_no:
 
        :param status_change:
 
        :param send_email:
 
        """
 
        if not text:
 
            return
 

	
 
        repo = self._get_repo(repo)
 
        user = self._get_user(user)
 
@@ -161,31 +162,33 @@ class ChangesetCommentsModel(BaseModel):
 
                'pr_comment_url': _url,
 
                'pr_comment_user': h.person(user.email),
 
                'pr_target_repo': h.url('summary_home',
 
                                   repo_name=pull_request.other_repo.repo_name,
 
                                   qualified=True)
 
            }
 
        # create notification objects, and emails
 
        NotificationModel().create(
 
            created_by=user, subject=subj, body=body,
 
            recipients=recipients, type_=notification_type,
 
            email_kwargs=email_kwargs
 
        )
 

	
 
        mention_recipients = set(self._extract_mentions(body))\
 
                                .difference(recipients)
 
        if mention_recipients:
 
            email_kwargs.update({'pr_mention': True})
 
            subj = _('[Mention]') + ' ' + subj
 
        if send_email:
 
            # create notification objects, and emails
 
            NotificationModel().create(
 
                created_by=user, subject=subj, body=body,
 
                recipients=mention_recipients,
 
                type_=notification_type,
 
                recipients=recipients, type_=notification_type,
 
                email_kwargs=email_kwargs
 
            )
 

	
 
            mention_recipients = set(self._extract_mentions(body))\
 
                                    .difference(recipients)
 
            if mention_recipients:
 
                email_kwargs.update({'pr_mention': True})
 
                subj = _('[Mention]') + ' ' + subj
 
                NotificationModel().create(
 
                    created_by=user, subject=subj, body=body,
 
                    recipients=mention_recipients,
 
                    type_=notification_type,
 
                    email_kwargs=email_kwargs
 
                )
 

	
 
        return comment
 

	
 
    def delete(self, comment):
 
        """
 
        Deletes given comment
 

	
0 comments (0 inline, 0 general)