changeset 2799:493646d3146f beta

Nicer email notifications about pull-request
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 04 Sep 2012 02:18:59 +0200
parents 091e99b29fd4
children 6540ee9179da
files docs/changelog.rst rhodecode/model/notification.py rhodecode/model/pull_request.py rhodecode/templates/email_templates/pull_request.html
diffstat 4 files changed, 42 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/docs/changelog.rst	Tue Sep 04 01:45:57 2012 +0200
+++ b/docs/changelog.rst	Tue Sep 04 02:18:59 2012 +0200
@@ -18,15 +18,17 @@
   empty data 
 - modified_on column saves repository update and it's going to be used
   later for light version of main page ref #500
+- pull request notifications send much nicer emails with details about pull
+  request
 
 fixes
 +++++
 
 - fixed migrations of permissions that can lead to inconsistency.
-  Some users sent feedback that after upgrading from older versions issues with updating
-  default permissions occured. RhodeCode detects that now and resets default user
-  permission to initial state if there is a need for that. Also forces users to set
-  the default value for new forking permission. 
+  Some users sent feedback that after upgrading from older versions issues 
+  with updating default permissions occurred. RhodeCode detects that now and
+  resets default user permission to initial state if there is a need for that.
+  Also forces users to set the default value for new forking permission. 
 
 
 1.4.0 (**2012-09-03**)
--- a/rhodecode/model/notification.py	Tue Sep 04 01:45:57 2012 +0200
+++ b/rhodecode/model/notification.py	Tue Sep 04 02:18:59 2012 +0200
@@ -255,7 +255,8 @@
          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_DEFAULT: 'email_templates/default.html',
+         self.TYPE_PULL_REQUEST: 'email_templates/pull_request.html',
         }
 
     def get_email_tmpl(self, type_, **kwargs):
--- a/rhodecode/model/pull_request.py	Tue Sep 04 01:45:57 2012 +0200
+++ b/rhodecode/model/pull_request.py	Tue Sep 04 02:18:59 2012 +0200
@@ -79,22 +79,30 @@
         #notification to reviewers
         notif = NotificationModel()
 
+        pr_url = h.url('pullrequest_show', repo_name=other_repo.repo_name,
+                       pull_request_id=new.pull_request_id,
+                       qualified=True,
+        )
         subject = safe_unicode(
             h.link_to(
               _('%(user)s wants you to review pull request #%(pr_id)s') % \
                 {'user': created_by_user.username,
                  'pr_id': new.pull_request_id},
-              h.url('pullrequest_show', repo_name=other_repo.repo_name,
-                    pull_request_id=new.pull_request_id,
-                    qualified=True,
-              )
+                pr_url
             )
         )
         body = description
+        kwargs = {
+            'pr_title': title,
+            'pr_user_created': h.person(created_by_user.email),
+            'pr_repo_url': h.url('summary_home', repo_name=other_repo.repo_name,
+                                 qualified=True,),
+            'pr_url': pr_url,
+            'pr_revisions': revisions
+        }
         notif.create(created_by=created_by_user, subject=subject, body=body,
                      recipients=reviewers,
-                     type_=Notification.TYPE_PULL_REQUEST,)
-
+                     type_=Notification.TYPE_PULL_REQUEST, email_kwargs=kwargs)
         return new
 
     def update_reviewers(self, pull_request, reviewers_ids):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rhodecode/templates/email_templates/pull_request.html	Tue Sep 04 02:18:59 2012 +0200
@@ -0,0 +1,20 @@
+## -*- coding: utf-8 -*-
+<%inherit file="main.html"/>
+            
+User <b>${pr_user_created}</b> opened pull request for repository 
+${pr_repo_url} and wants you to review changes.
+
+<div>title: ${pr_title}</div>
+<div>description:</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}