Changeset - bd5d70b6f445
[Not reviewed]
default
0 5 0
Thomas De Schampheleire <thomas.de.schampheleire at gmail.com> - 10 years ago 2015-07-09 22:17:26

email: add relevant title to subject of emails

For comment and pullrequest mails, add changeset/pullrequest title (shortened
to first 50 characters of first line)
5 files changed with 22 insertions and 17 deletions:
0 comments (0 inline, 0 general)
kallithea/model/comment.py
Show inline comments
 
@@ -95,12 +95,13 @@ class ChangesetCommentsModel(BaseModel):
 
                'status_change': status_change,
 
                'cs_comment_user': user.full_name_and_username,
 
                'cs_target_repo': h.canonical_url('summary_home', repo_name=repo.repo_name),
 
                'cs_comment_url': comment_url,
 
                'raw_id': revision,
 
                'message': cs.message,
 
                'message_short': h.shorter(cs.message, 50, firstline=True),
 
                'cs_author': cs_author,
 
                'repo_name': repo.repo_name,
 
                'short_id': h.short_id(revision),
 
                'branch': cs.branch,
 
                'comment_username': user.username,
 
                'threading': threading,
 
@@ -136,12 +137,13 @@ class ChangesetCommentsModel(BaseModel):
 
            # add the reviewers to notification
 
            recipients += pull_request.get_reviewer_users()
 

	
 
            #set some variables for email notification
 
            email_kwargs = {
 
                'pr_title': pull_request.title,
 
                'pr_title_short': h.shorter(pull_request.title, 50),
 
                'pr_nice_id': pull_request.nice_id(),
 
                'status_change': status_change,
 
                'closing_pr': closing_pr,
 
                'pr_comment_url': comment_url,
 
                'pr_comment_user': user.full_name_and_username,
 
                'pr_target_repo': h.canonical_url('summary_home',
kallithea/model/notification.py
Show inline comments
 
@@ -296,19 +296,19 @@ class EmailNotificationModel(BaseModel):
 
            self.TYPE_REGISTRATION: 'registration',
 
            self.TYPE_DEFAULT: 'default',
 
            self.TYPE_PULL_REQUEST: 'pull_request',
 
            self.TYPE_PULL_REQUEST_COMMENT: 'pull_request_comment',
 
        }
 
        self._subj_map = {
 
            self.TYPE_CHANGESET_COMMENT: _('[Comment] %(repo_name)s changeset %(short_id)s on %(branch)s'),
 
            self.TYPE_CHANGESET_COMMENT: _('[Comment] %(repo_name)s changeset %(short_id)s "%(message_short)s" on %(branch)s'),
 
            self.TYPE_MESSAGE: 'Test Message',
 
            # self.TYPE_PASSWORD_RESET
 
            self.TYPE_REGISTRATION: _('New user %(new_username)s registered'),
 
            # self.TYPE_DEFAULT
 
            self.TYPE_PULL_REQUEST: _('[Added] %(repo_name)s pull request %(pr_nice_id)s from %(pr_source_branch)s'),
 
            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s pull request %(pr_nice_id)s from %(pr_source_branch)s'),
 
            self.TYPE_PULL_REQUEST: _('[Added] %(repo_name)s pull request %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s'),
 
            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s pull request %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s'),
 
        }
 

	
 
    def get_email_description(self, type_, **kwargs):
 
        """
 
        return subject for email based on given type
 
        """
kallithea/model/pull_request.py
Show inline comments
 
@@ -153,12 +153,13 @@ class PullRequestModel(BaseModel):
 
            )
 
        body = pr.description
 
        _org_ref_type, org_ref_name, _org_rev = pr.org_ref.split(':')
 
        _other_ref_type, other_ref_name, _other_rev = pr.other_ref.split(':')
 
        email_kwargs = {
 
            'pr_title': pr.title,
 
            'pr_title_short': h.shorter(pr.title, 50),
 
            'pr_user_created': user.full_name_and_username,
 
            'pr_repo_url': h.canonical_url('summary_home', repo_name=pr.other_repo.repo_name),
 
            'pr_url': pr_url,
 
            'pr_revisions': revision_data,
 
            'repo_name': pr.other_repo.repo_name,
 
            'org_repo_name': pr.org_repo.repo_name,
kallithea/tests/models/test_dump_html_mails.ref.html
Show inline comments
 
@@ -3,13 +3,13 @@
 

	
 
<h1>cs_comment, is_mention=False, status_change=None</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name changeset cafe1234 on brunch
 
Subject: [Comment] repo/name changeset cafe1234 "This changeset did something cl..." on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:
 
This is the new comment.
 
@@ -55,13 +55,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>cs_comment, is_mention=True, status_change=None</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name changeset cafe1234 on brunch
 
Subject: [Comment] repo/name changeset cafe1234 "This changeset did something cl..." on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:
 
This is the new comment.
 
@@ -107,13 +107,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>cs_comment, is_mention=False, status_change='Approved'</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Approved: Comment] repo/name changeset cafe1234 on brunch
 
Subject: [Approved: Comment] repo/name changeset cafe1234 "This changeset did something cl..." on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:
 
This is the new comment.
 
@@ -161,13 +161,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>cs_comment, is_mention=True, status_change='Approved'</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Approved: Comment] repo/name changeset cafe1234 on brunch
 
Subject: [Approved: Comment] repo/name changeset cafe1234 "This changeset did something cl..." on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:
 
This is the new comment.
 
@@ -283,13 +283,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request, is_mention=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Added] repo/name pull request #7 from devbranch
 
Subject: [Added] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Requesting User (root) requested your review of repo/name pull request "The Title"
 

	
 
@@ -348,13 +348,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request, is_mention=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Added] repo/name pull request #7 from devbranch
 
Subject: [Added] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Requesting User (root) mentioned you on repo/name pull request "The Title"
 

	
 
@@ -413,13 +413,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=False, status_change=None, closing_pr=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name pull request #7 from devbranch
 
Subject: [Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -456,13 +456,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=True, status_change=None, closing_pr=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name pull request #7 from devbranch
 
Subject: [Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -499,13 +499,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=False, status_change='Under Review', closing_pr=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Under Review: Comment] repo/name pull request #7 from devbranch
 
Subject: [Under Review: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -544,13 +544,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=True, status_change='Under Review', closing_pr=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Under Review: Comment] repo/name pull request #7 from devbranch
 
Subject: [Under Review: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -589,13 +589,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=False, status_change=None, closing_pr=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Closing: Comment] repo/name pull request #7 from devbranch
 
Subject: [Closing: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -632,13 +632,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=True, status_change=None, closing_pr=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Closing: Comment] repo/name pull request #7 from devbranch
 
Subject: [Closing: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -675,13 +675,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=False, status_change='Under Review', closing_pr=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Under Review, Closing: Comment] repo/name pull request #7 from devbranch
 
Subject: [Under Review, Closing: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
 
@@ -720,13 +720,13 @@ This is an automatic notification. Don&#
 

	
 
<h1>pull_request_comment, is_mention=True, status_change='Under Review', closing_pr=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Under Review, Closing: Comment] repo/name pull request #7 from devbranch
 
Subject: [Under Review, Closing: Comment] repo/name pull request #7 "The Title" from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
 
Me too!
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -182,12 +182,13 @@ class TestNotifications(TestController):
 

	
 
        l.append('<html><body>\n')
 
        with mock.patch.object(kallithea.lib.celerylib.tasks, 'send_email', send_email):
 
            pr_kwargs = dict(
 
                pr_nice_id='#7',
 
                pr_title='The Title',
 
                pr_title_short='The Title',
 
                pr_url='http://pr.org/7',
 
                pr_target_repo='http://mainline.com/repo',
 
                pr_target_branch='trunk',
 
                pr_source_repo='https://dev.org/repo',
 
                pr_source_branch='devbranch',
 
                pr_owner=User.get(self.u2),
 
@@ -201,12 +202,13 @@ class TestNotifications(TestController):
 
                    raw_id='cafe1234c0ffeecafe',
 
                    branch='brunch',
 
                    cs_comment_user='Opinionated User (jsmith)',
 
                    cs_comment_url='http://comment.org',
 
                    is_mention=[False, True],
 
                    message='This changeset did something clever which is hard to explain',
 
                    message_short='This changeset did something cl...',
 
                    status_change=[None, 'Approved'],
 
                    cs_target_repo='repo_target',
 
                    cs_url='http://changeset.com',
 
                    cs_author=User.get(self.u2))),
 
                (Notification.TYPE_MESSAGE,
 
                 u'This is the body of the test message\n - nothing interesting here except indentation.',
0 comments (0 inline, 0 general)