[damned-lies] Add link to commit log in notification mail (#669588)



commit d51a87ecaf121b831388a52a123dae2abb05024a
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Feb 7 22:29:11 2012 +0100

    Add link to commit log in notification mail (#669588)

 stats/models.py                   |   10 +++++++++-
 stats/utils.py                    |   26 +++++++++++---------------
 templates/freeze-notification.txt |   10 ++++++++++
 3 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 8d9d513..5f8b207 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -306,6 +306,14 @@ class Branch(models.Model):
         else:
             return utils.url_join(self.module.vcs_web, "branches", self.name)
 
+    def get_vcs_web_log_url(self):
+        """ Link to browsable commit log """
+        if self.module.vcs_type == 'git':
+            return utils.url_join(self.module.vcs_web, "log", "?h=%s" % self.name)
+        else:
+            # Not implemented for other VCS
+            return ""
+
     def co_path(self):
         """ Returns the path of the local checkout for the branch """
         if self.module.vcs_type in ('hg', 'git'):
@@ -445,7 +453,7 @@ class Branch(models.Model):
                     # Compare old and new POT
                     changed_status, diff = utils.pot_diff_status(previous_pot, potfile)
                     if string_frozen and dom.dtype == 'ui' and changed_status == utils.CHANGED_WITH_ADDITIONS:
-                        utils.notify_list("%s.%s" % (self.module.name, self.name), diff)
+                        utils.notify_list(self, diff)
 
                 # 6. Generate pot stats and update DB
                 # ***********************************
diff --git a/stats/utils.py b/stats/utils.py
index 3f35f79..40b8982 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -35,6 +35,8 @@ from django.conf import settings
 from django.contrib.sites.models import Site
 from django.core.files.base import File
 from django.core.mail import send_mail
+from django.template import Context
+from django.template.loader import get_template
 from django.utils.translation import ugettext_noop
 
 import potdiff
@@ -527,23 +529,17 @@ def compute_md5(full_path):
     return m.hexdigest()
 
 
-def notify_list(out_domain, diff):
+def notify_list(branch, diff):
     """Send notification about string changes described in diff."""
     current_site = Site.objects.get_current()
-    text = u"""This is an automatic notification from status generation scripts on:
-http://%(ourweb)s.
-
-There have been following string additions to module '%(module)s':
-
-%(potdiff)s
-
-Note that this doesn't directly indicate a string freeze break, but it
-might be worth investigating.
-""" % { 'module' : out_domain,
-    'ourweb' : current_site.domain,
-    'potdiff' : "\n    ".join(diff).decode('utf-8') }
-
-    send_mail(subject="String additions to '%s'" % (out_domain),
+    template = get_template('freeze-notification.txt')
+    text = template.render(Context({
+        'module' : '%s.%s' % (branch.module.name, branch.name),
+        'ourweb' : current_site.domain,
+        'potdiff' : "\n    ".join(diff).decode('utf-8'),
+        'commit_log': branch.get_vcs_web_log_url(),
+    }))
+    send_mail(subject="String additions to '%s.%s'" % (branch.module.name, branch.name),
               message=text,
               from_email="GNOME Status Pages <%s>" % (settings.DEFAULT_FROM_EMAIL),
               recipient_list=settings.NOTIFICATIONS_TO)
diff --git a/templates/freeze-notification.txt b/templates/freeze-notification.txt
new file mode 100644
index 0000000..f97f6f7
--- /dev/null
+++ b/templates/freeze-notification.txt
@@ -0,0 +1,10 @@
+This is an automatic notification from status generation scripts on:
+http://{{ ourweb }}.
+
+There have been following string additions to module '{{ module }}':
+
+{{ potdiff }}
+
+Note that this doesn't directly indicate a string freeze break, but it
+might be worth investigating.
+{{ commit_log }}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]