Changeset - d379e2c39bba
[Not reviewed]
kallithea/model/notification.py
Show inline comments
 
@@ -159,77 +159,77 @@ class EmailNotificationModel(object):
 
        self.email_types = {
 
            self.TYPE_CHANGESET_COMMENT: 'changeset_comment',
 
            self.TYPE_PASSWORD_RESET: 'password_reset',
 
            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 "%(message_short)s" on %(branch)s by %(cs_author_username)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: _('[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):
 
        """
 
        return subject for email based on given type
 
        """
 
        tmpl = self._subj_map[type_]
 
        try:
 
            subj = tmpl % kwargs
 
        except KeyError as e:
 
            log.error('error generating email subject for %r from %s: %s', type_, ', '.join(self._subj_map), e)
 
            raise
 
        # 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(str(status_change))  # apply str to evaluate LazyString before .join
 
        if kwargs.get('closing_pr'):
 
            bracket_tags.append(_('Closing'))
 
        if bracket_tags:
 
            if subj.startswith('['):
 
                subj = '[' + ', '.join(bracket_tags) + ': ' + subj[1:]
 
            else:
 
                subj = '[' + ', '.join(bracket_tags) + '] ' + subj
 
        return subj
 

	
 
    def get_email_tmpl(self, type_, content_type, **kwargs):
 
        """
 
        return generated template for email based on given type
 
        """
 

	
 
        base = 'email_templates/' + self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT]) + '.' + content_type
 
        base = 'email/' + self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT]) + '.' + content_type
 
        email_template = self._tmpl_lookup.get_template(base)
 
        # translator and helpers inject
 
        _kwargs = {'_': _,
 
                   'h': h,
 
                   'c': c}
 
        _kwargs.update(kwargs)
 
        if content_type == 'html':
 
            _kwargs.update({
 
                "color_text": "#202020",
 
                "color_emph": "#395fa0",
 
                "color_link": "#395fa0",
 
                "color_border": "#ddd",
 
                "color_background_grey": "#f9f9f9",
 
                "color_button": "#395fa0",
 
                "monospace_style": "font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace",
 
                "sans_style": "font-family:Helvetica,Arial,sans-serif",
 
                })
 
            _kwargs.update({
 
                "default_style": "%(sans_style)s;font-weight:200;font-size:14px;line-height:17px;color:%(color_text)s" % _kwargs,
 
                "comment_style": "%(monospace_style)s;white-space:pre-wrap" % _kwargs,
 
                "data_style": "border:%(color_border)s 1px solid;background:%(color_background_grey)s" % _kwargs,
 
                "emph_style": "font-weight:600;color:%(color_emph)s" % _kwargs,
 
                "link_style": "color:%(color_link)s;text-decoration:none" % _kwargs,
 
                "link_text_style": "color:%(color_text)s;text-decoration:none;border:%(color_border)s 1px solid;background:%(color_background_grey)s" % _kwargs,
 
                })
 

	
 
        log.debug('rendering tmpl %s with kwargs %s', base, _kwargs)
 
        return email_template.render_unicode(**_kwargs)
kallithea/templates/email/button.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/button.html to kallithea/templates/email/button.html
kallithea/templates/email/button.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/button.txt to kallithea/templates/email/button.txt
kallithea/templates/email/changeset_comment.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/changeset_comment.html to kallithea/templates/email/changeset_comment.html
kallithea/templates/email/changeset_comment.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/changeset_comment.txt to kallithea/templates/email/changeset_comment.txt
kallithea/templates/email/comment.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/comment.html to kallithea/templates/email/comment.html
kallithea/templates/email/comment.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/comment.txt to kallithea/templates/email/comment.txt
kallithea/templates/email/default.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/default.html to kallithea/templates/email/default.html
kallithea/templates/email/default.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/default.txt to kallithea/templates/email/default.txt
kallithea/templates/email/header.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/header.html to kallithea/templates/email/header.html
kallithea/templates/email/header.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/header.txt to kallithea/templates/email/header.txt
kallithea/templates/email/main.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/main.html to kallithea/templates/email/main.html
kallithea/templates/email/password_reset.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/password_reset.html to kallithea/templates/email/password_reset.html
kallithea/templates/email/password_reset.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/password_reset.txt to kallithea/templates/email/password_reset.txt
kallithea/templates/email/pull_request.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/pull_request.html to kallithea/templates/email/pull_request.html
kallithea/templates/email/pull_request.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/pull_request.txt to kallithea/templates/email/pull_request.txt
kallithea/templates/email/pull_request_comment.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/pull_request_comment.html to kallithea/templates/email/pull_request_comment.html
kallithea/templates/email/pull_request_comment.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/pull_request_comment.txt to kallithea/templates/email/pull_request_comment.txt
kallithea/templates/email/registration.html
Show inline comments
 
file renamed from kallithea/templates/email_templates/registration.html to kallithea/templates/email/registration.html
kallithea/templates/email/registration.txt
Show inline comments
 
file renamed from kallithea/templates/email_templates/registration.txt to kallithea/templates/email/registration.txt
scripts/whitespacecleanup.sh
Show inline comments
 
#!/bin/bash -xe
 

	
 
# Enforce some consistency in whitespace - just to avoid spurious whitespaces changes
 

	
 
files=`hg mani | egrep -v '/fontello/|/email_templates/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`
 
files=`hg mani | egrep -v '/fontello/|/templates/email/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`
 

	
 
sed -i "s/`printf '\r'`//g" $files
 
sed -i -e "s,`printf '\t'`,    ,g" $files
 
sed -i -e "s,  *$,,g" $files
 
sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
 
# ensure one trailing newline - remove empty last line and make last line include trailing newline:
 
sed -i -e '$,${/^$/d}' -e '$a\' $files
 

	
 
sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
 
sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`
 

	
 
hg mani | xargs chmod -x
 
hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x
 

	
 
# isort is installed from dev_requirements.txt
 
hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs isort --line-width 160 --lines-after-imports 2
 

	
 
echo "diff after $0:"
 
hg diff
0 comments (0 inline, 0 general)