Changeset - 78059b94991e
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 5 years ago 2020-11-05 22:17:13
thomas.de_schampheleire@nokia.com
model/comment: inline _get_notification_data

This method was only used in one place, from code which was very related.
Inline it to group things together and reduce complexity.
1 file changed with 4 insertions and 24 deletions:
0 comments (0 inline, 0 general)
kallithea/model/comment.py
Show inline comments
 
@@ -51,19 +51,16 @@ def _list_pull_request_commenters(pull_r
 
        .filter(db.ChangesetComment.pull_request_id == pull_request.pull_request_id)
 
        .all())
 

	
 

	
 
class ChangesetCommentsModel(object):
 

	
 
    def _get_notification_data(self, repo, comment, author, comment_text,
 
                               line_no=None, revision=None, pull_request=None,
 
                               status_change=None, closing_pr=False):
 
        """
 
        :returns: tuple (subj,body,recipients,notification_type,email_kwargs)
 
        """
 
        # make notification
 
    def create_notification(self, repo, comment, author, comment_text,
 
                                line_no=None, revision=None, pull_request=None,
 
                                status_change=None, closing_pr=False):
 

	
 
        body = comment_text  # text of the comment
 
        line = ''
 
        if line_no:
 
            line = _('on line %s') % line_no
 

	
 
        # changeset
 
@@ -157,29 +154,12 @@ class ChangesetCommentsModel(object):
 
                'pr_owner_username': pull_request.owner.username,
 
                'repo_name': pull_request.other_repo.repo_name,
 
                'comment_username': author.username,
 
                'threading': threading,
 
            }
 

	
 
        return subj, body, recipients, notification_type, email_kwargs
 

	
 
    def create_notification(self, repo, comment, author, comment_text,
 
                                line_no=None, revision=None, pull_request=None,
 
                                status_change=None, closing_pr=False):
 

	
 

	
 
        (subj, body, recipients, notification_type, email_kwargs) = self._get_notification_data(
 
            repo, comment, author,
 
            comment_text=comment_text,
 
            line_no=line_no,
 
            revision=revision,
 
            pull_request=pull_request,
 
            status_change=status_change,
 
            closing_pr=closing_pr,
 
        )
 

	
 
        email_kwargs['is_mention'] = False
 
        # create notification objects, and emails
 
        notification.NotificationModel().create(
 
            created_by=author, subject=subj, body=body,
 
            recipients=recipients, type_=notification_type,
 
            email_kwargs=email_kwargs,
0 comments (0 inline, 0 general)