Mercurial > kallithea
changeset 8070:6e5787e496a0
model: clean up get_email_description to make it more clear how the [tags] are added ... and why
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 25 Dec 2019 19:32:48 +0100 |
parents | 4f03bd5ac2f2 |
children | 2b7aeb9d1546 |
files | kallithea/model/notification.py |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/notification.py Tue Dec 24 04:13:48 2019 +0100 +++ b/kallithea/model/notification.py Wed Dec 25 19:32:48 2019 +0100 @@ -35,7 +35,6 @@ import kallithea from kallithea.lib import helpers as h -from kallithea.lib.utils2 import safe_unicode from kallithea.model.db import User @@ -180,12 +179,19 @@ except KeyError as e: log.error('error generating email subject for %r from %s: %s', type_, ','.join(self._subj_map.keys()), e) raise - l = [safe_unicode(x) for x in [kwargs.get('status_change'), kwargs.get('closing_pr') and _('Closing')] if x] - if l: + # gmail doesn't do proper threading but will ignore leading square + # bracket content ... so that is where we put status info + bracket_tags = [] + status_change = kwargs.get('status_change') + if status_change: + bracket_tags.append(unicode(status_change)) # apply unicode to evaluate LazyString before .join + if kwargs.get('closing_pr'): + bracket_tags.append(_('Closing')) + if bracket_tags: if subj.startswith('['): - subj = '[' + ', '.join(l) + ': ' + subj[1:] + subj = '[' + ', '.join(bracket_tags) + ': ' + subj[1:] else: - subj = '[' + ', '.join(l) + '] ' + subj + subj = '[' + ', '.join(bracket_tags) + '] ' + subj return subj def get_email_tmpl(self, type_, content_type, **kwargs):