# HG changeset patch # User Thomas De Schampheleire # Date 1436473046 -7200 # Node ID bd5d70b6f445d4c32286de501018dbc6f1e8a957 # Parent 552800808386e9225bcaf50e895bb405d72426b3 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) diff -r 552800808386 -r bd5d70b6f445 kallithea/model/comment.py --- a/kallithea/model/comment.py Thu Jul 28 16:31:40 2016 +0200 +++ b/kallithea/model/comment.py Thu Jul 09 22:17:26 2015 +0200 @@ -98,6 +98,7 @@ '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), @@ -139,6 +140,7 @@ #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, diff -r 552800808386 -r bd5d70b6f445 kallithea/model/notification.py --- a/kallithea/model/notification.py Thu Jul 28 16:31:40 2016 +0200 +++ b/kallithea/model/notification.py Thu Jul 09 22:17:26 2015 +0200 @@ -299,13 +299,13 @@ 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): diff -r 552800808386 -r bd5d70b6f445 kallithea/model/pull_request.py --- a/kallithea/model/pull_request.py Thu Jul 28 16:31:40 2016 +0200 +++ b/kallithea/model/pull_request.py Thu Jul 09 22:17:26 2015 +0200 @@ -156,6 +156,7 @@ _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, diff -r 552800808386 -r bd5d70b6f445 kallithea/tests/models/test_dump_html_mails.ref.html --- a/kallithea/tests/models/test_dump_html_mails.ref.html Thu Jul 28 16:31:40 2016 +0200 +++ b/kallithea/tests/models/test_dump_html_mails.ref.html Thu Jul 09 22:17:26 2015 +0200 @@ -6,7 +6,7 @@ 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 -------------------- @@ -58,7 +58,7 @@ 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 -------------------- @@ -110,7 +110,7 @@ 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 -------------------- @@ -164,7 +164,7 @@ 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 -------------------- @@ -286,7 +286,7 @@ 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 -------------------- @@ -351,7 +351,7 @@ 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 -------------------- @@ -416,7 +416,7 @@ 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 -------------------- @@ -459,7 +459,7 @@ 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 -------------------- @@ -502,7 +502,7 @@ 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 -------------------- @@ -547,7 +547,7 @@ 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 -------------------- @@ -592,7 +592,7 @@ 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 -------------------- @@ -635,7 +635,7 @@ 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 -------------------- @@ -678,7 +678,7 @@ 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 -------------------- @@ -723,7 +723,7 @@ 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 -------------------- diff -r 552800808386 -r bd5d70b6f445 kallithea/tests/models/test_notifications.py --- a/kallithea/tests/models/test_notifications.py Thu Jul 28 16:31:40 2016 +0200 +++ b/kallithea/tests/models/test_notifications.py Thu Jul 09 22:17:26 2015 +0200 @@ -185,6 +185,7 @@ 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', @@ -204,6 +205,7 @@ 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',