changeset 6059:d4061c6cc0e2

notifications: tweak PR mail subject lines The subject line is used for mail threading in gmail and can thus not be changed without impacting users ... but now we do it. * The tag '[Review]' is more spot-on than '[Added]'. * The subject should be short so it fits on one line, so abbreviate "pull request" to PR. * Add the PR owner - convenient for filtering comments on own PRs from comments on other PRs.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Jul 2016 16:34:29 +0200
parents bd5d70b6f445
children 40edadecda69
files kallithea/model/comment.py kallithea/model/notification.py kallithea/model/pull_request.py kallithea/tests/models/test_dump_html_mails.ref.html kallithea/tests/models/test_notifications.py
diffstat 5 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/comment.py	Thu Jul 09 22:17:26 2015 +0200
+++ b/kallithea/model/comment.py	Thu Jul 28 16:34:29 2016 +0200
@@ -153,6 +153,7 @@
                                    repo_name=pull_request.org_repo.repo_name),
                 'pr_source_branch': org_ref_name,
                 'pr_owner': pull_request.owner,
+                'pr_owner_username': pull_request.owner.username,
                 'repo_name': pull_request.other_repo.repo_name,
                 'comment_username': user.username,
                 'threading': threading,
--- a/kallithea/model/notification.py	Thu Jul 09 22:17:26 2015 +0200
+++ b/kallithea/model/notification.py	Thu Jul 28 16:34:29 2016 +0200
@@ -304,8 +304,8 @@
             # 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 "%(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'),
+            self.TYPE_PULL_REQUEST: _('[Review] %(repo_name)s PR %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s by %(pr_owner_username)s'),
+            self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s PR %(pr_nice_id)s "%(pr_title_short)s" from %(pr_source_branch)s by %(pr_owner_username)s'),
         }
 
     def get_email_description(self, type_, **kwargs):
--- a/kallithea/model/pull_request.py	Thu Jul 09 22:17:26 2015 +0200
+++ b/kallithea/model/pull_request.py	Thu Jul 28 16:34:29 2016 +0200
@@ -171,6 +171,7 @@
                                repo_name=pr.org_repo.repo_name),
             'pr_source_branch': org_ref_name,
             'pr_owner': pr.owner,
+            'pr_owner_username': pr.owner.username,
             'pr_username': user.username,
             'threading': threading,
             'is_mention': False,
--- a/kallithea/tests/models/test_dump_html_mails.ref.html	Thu Jul 09 22:17:26 2015 +0200
+++ b/kallithea/tests/models/test_dump_html_mails.ref.html	Thu Jul 28 16:34:29 2016 +0200
@@ -286,7 +286,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Added] repo/name pull request #7 "The Title" from devbranch
+Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -351,7 +351,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Added] repo/name pull request #7 "The Title" from devbranch
+Subject: [Review] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -416,7 +416,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -459,7 +459,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -502,7 +502,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Under Review: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Under Review: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -547,7 +547,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Under Review: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Under Review: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -592,7 +592,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Closing: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Closing: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -635,7 +635,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Closing: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Closing: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -678,7 +678,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Under Review, Closing: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Under Review, Closing: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
@@ -723,7 +723,7 @@
 
 From: u1
 To: u2@example.com
-Subject: [Under Review, Closing: Comment] repo/name pull request #7 "The Title" from devbranch
+Subject: [Under Review, Closing: Comment] repo/name PR #7 "The Title" from devbranch by u2
 
 --------------------
 
--- a/kallithea/tests/models/test_notifications.py	Thu Jul 09 22:17:26 2015 +0200
+++ b/kallithea/tests/models/test_notifications.py	Thu Jul 28 16:34:29 2016 +0200
@@ -192,6 +192,7 @@
                 pr_source_repo='https://dev.org/repo',
                 pr_source_branch='devbranch',
                 pr_owner=User.get(self.u2),
+                pr_owner_username='u2'
                 )
 
             for type_, body, kwargs in [