[PATCH 5 of 6] email: remove user and add relevant title to subject of emails
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Sep 1 16:28:37 UTC 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1436473046 -7200
# Thu Jul 09 22:17:26 2015 +0200
# Node ID 63dd90a5345e35b914a4f3842d4838e98fc7fdbc
# Parent 3ca9738eb4f87f38b99404a1eda22fb889e2d0d9
email: remove user and add relevant title to subject of emails
For comment and pullrequest mails:
- remove user that triggered the email, as this is now in the From header.
- add changeset/pullrequest title (shortened to first 50 characters of first
line)
Based on code by Cedric De Herdt.
diff --git a/kallithea/model/comment.py b/kallithea/model/comment.py
--- a/kallithea/model/comment.py
+++ b/kallithea/model/comment.py
@@ -105,6 +105,7 @@ class ChangesetCommentsModel(BaseModel):
'cs_comment_url': comment_url,
'raw_id': revision,
'message': cs.message,
+ 'message_short': h.shorter(cs.message.splitlines()[0], 50),
'repo_name': repo.repo_name,
'short_id': h.short_id(revision),
'branch': cs.branch,
@@ -144,6 +145,7 @@ class ChangesetCommentsModel(BaseModel):
#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 --git a/kallithea/model/notification.py b/kallithea/model/notification.py
--- a/kallithea/model/notification.py
+++ b/kallithea/model/notification.py
@@ -299,13 +299,13 @@ class EmailNotificationModel(BaseModel):
self.TYPE_PULL_REQUEST_COMMENT: 'pull_request_comment',
}
self._subj_map = {
- self.TYPE_CHANGESET_COMMENT: _('[Comment from %(comment_username)s] %(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 by %(pr_username)s] %(repo_name)s pull request %(pr_nice_id)s from %(ref)s'),
- self.TYPE_PULL_REQUEST_COMMENT: _('[Comment from %(comment_username)s] %(repo_name)s pull request %(pr_nice_id)s from %(ref)s'),
+ self.TYPE_PULL_REQUEST: _('[Added] %(repo_name)s pull request %(pr_nice_id)s: "%(pr_title_short)s" from %(ref)s'),
+ self.TYPE_PULL_REQUEST_COMMENT: _('[Comment] %(repo_name)s pull request %(pr_nice_id)s: "%(pr_title_short)s" from %(ref)s'),
}
def get_email_description(self, type_, **kwargs):
More information about the kallithea-general
mailing list