Repository: fedora-infra/bodhi

Issue:
Put versions back into e-mail subjects
In https://github.com/fedora-infra/bodhi/pull/1561 we made it so update e-mail subjects use the new beautify title code (which is very nice), but inadvertently we also stopped including version info on the packages and now only list the package names. It has been requested that we bring back the versions into e-mail subjects, so we should modify the new beautify title to have an ```nvr``` flag (defaulting to ```False```) that includes the ```nvr``` of the Build if ```True```, and uses the current behavior if ```False```.


Discussion:

Resolving patch:
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -1640,7 +1640,7 @@ def get_testcase_karma(self, testcase):
                         bad += 1
         return bad * -1, good
 
-    def beautify_title(self, amp=False):
+    def beautify_title(self, amp=False, nvr=False):
         """Will shorten the title according to its length.
 
         This is used mostly in subject of a update notification email and
@@ -1651,9 +1651,16 @@ def beautify_title(self, amp=False):
 
         If the "amp" parameter is specified it will replace the and with and
         &amp; html entity
+
+        If the "nvr" parameter is specified it will include name, version and
+        release information in package labels.
         """
+        def build_label():
+            return build.nvr if nvr else packagename_from_nvr(self, build.nvr)
+
         if len(self.builds) > 2:
-            title = ", ".join([packagename_from_nvr(self, build.nvr) for build in self.builds[:2]])
+            title = ", ".join([build_label() for build in self.builds[:2]])
+
             if amp:
                 title += ", &amp; "
             else:
@@ -1662,7 +1669,7 @@ def beautify_title(self, amp=False):
             title += " more"
             return title
         else:
-            return " and ".join([packagename_from_nvr(self, build.nvr) for build in self.builds])
+            return " and ".join([build_label() for build in self.builds])
 
     def assign_alias(self):
         """Return a randomly-suffixed update ID.


Test patch:
diff --git a/bodhi/tests/server/test_models.py b/bodhi/tests/server/test_models.py
--- a/bodhi/tests/server/test_models.py
+++ b/bodhi/tests/server/test_models.py
@@ -1078,15 +1078,21 @@ def test_beautify_title(self):
         update = self.get_update()
         rpm_build = update.builds[0]
         eq_(update.beautify_title(), u'TurboGears')
+        eq_(update.beautify_title(nvr=True), u'TurboGears-1.0.8-3.fc11')
 
         update.builds.append(rpm_build)
         eq_(update.beautify_title(), u'TurboGears and TurboGears')
+        eq_(update.beautify_title(nvr=True), u'TurboGears-1.0.8-3.fc11 and TurboGears-1.0.8-3.fc11')
 
         update.builds.append(rpm_build)
         eq_(update.beautify_title(), u'TurboGears, TurboGears, and 1 more')
+        eq_(update.beautify_title(nvr=True),
+            u'TurboGears-1.0.8-3.fc11, TurboGears-1.0.8-3.fc11, and 1 more')
 
         p = HTMLParser()
         eq_(p.unescape(update.beautify_title(amp=True)), u'TurboGears, TurboGears, & 1 more')
+        eq_(p.unescape(update.beautify_title(amp=True, nvr=True)),
+            u'TurboGears-1.0.8-3.fc11, TurboGears-1.0.8-3.fc11, & 1 more')
 
     def test_pkg_str(self):
         """ Ensure str(pkg) is correct """