Changeset - 3274ba9f1489
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-12-19 23:12:33
marcin@python-works.com
fixes #691: Notifications for pull requests: move link to pull request to the top
- fixed html escape in the template
2 files changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/notification.py
Show inline comments
 
@@ -225,53 +225,54 @@ class NotificationModel(BaseModel):
 
            _n.TYPE_PULL_REQUEST_COMMENT: _('commented on pull request at %(when)s')
 
        }
 

	
 
        # action == _map string
 
        tmpl = "%(user)s %(action)s "
 
        if show_age:
 
            when = h.age(notification.created_on)
 
        else:
 
            when = h.fmt_date(notification.created_on)
 

	
 
        data = dict(
 
            user=notification.created_by_user.username,
 
            action=_map[notification.type_]
 
        )
 
        return (tmpl % data) % {'when': when}
 

	
 

	
 
class EmailNotificationModel(BaseModel):
 

	
 
    TYPE_CHANGESET_COMMENT = Notification.TYPE_CHANGESET_COMMENT
 
    TYPE_PASSWORD_RESET = 'passoword_link'
 
    TYPE_REGISTRATION = Notification.TYPE_REGISTRATION
 
    TYPE_PULL_REQUEST = Notification.TYPE_PULL_REQUEST
 
    TYPE_PULL_REQUEST_COMMENT = Notification.TYPE_PULL_REQUEST_COMMENT
 
    TYPE_DEFAULT = 'default'
 

	
 
    def __init__(self):
 
        self._template_root = rhodecode.CONFIG['pylons.paths']['templates'][0]
 
        self._tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
 

	
 
        self.email_types = {
 
         self.TYPE_CHANGESET_COMMENT: 'email_templates/changeset_comment.html',
 
         self.TYPE_PASSWORD_RESET: 'email_templates/password_reset.html',
 
         self.TYPE_REGISTRATION: 'email_templates/registration.html',
 
         self.TYPE_DEFAULT: 'email_templates/default.html',
 
         self.TYPE_PULL_REQUEST: 'email_templates/pull_request.html',
 
         self.TYPE_PULL_REQUEST_COMMENT: 'email_templates/pull_request_comment.html',
 
        }
 

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

	
 
        :param type_:
 
        """
 

	
 
        base = self.email_types.get(type_, self.email_types[self.TYPE_DEFAULT])
 
        email_template = self._tmpl_lookup.get_template(base)
 
        # translator inject
 
        _kwargs = {'_': _}
 
        # translator and helpers inject
 
        _kwargs = {'_': _,
 
                   'h': h}
 
        _kwargs.update(kwargs)
 
        log.debug('rendering tmpl %s with kwargs %s' % (base, _kwargs))
 
        return email_template.render(**_kwargs)
rhodecode/templates/email_templates/pull_request.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%inherit file="main.html"/>
 

	
 
${_('User %s opened pull request for repository %s and wants you to review changes.') % ('<b>%s</b>' % pr_user_created,pr_repo_url)}
 
${_('User %s opened pull request for repository %s and wants you to review changes.') % (('<b>%s</b>' % pr_user_created),pr_repo_url) |n}
 
<div>${_('title')}: ${pr_title}</div>
 
<div>${_('description')}:</div>
 
<div>${_('View this pull request here')}: ${pr_url}</div>
 
<p>
 
${body}
 
</p>
 

	
 
<div>${_('revisions for reviewing')}</div>
 
<ul>
 
%for r in pr_revisions:
 
    <li>${r}</li>
 
%endfor
 
</ul>
 

	
 
${_('View this pull request here')}: ${pr_url}
 

	
0 comments (0 inline, 0 general)