← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/new-releases-636060 into lp:launchpad/devel

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/new-releases-636060 into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #636060 show new releases on package pages
  https://bugs.launchpad.net/bugs/636060


Summary
=======

There's a section showing upstream info on sourcepackages, but it doesn't show the upstream version/release; you have to click links to see that which is both cumbersome and silly.

This branch adds the latest release version info to the upstream portlet to remedy that.


Proposed fix
============

Get the latest release from ProductSeries.releases and show the version on the upstream portlet.

Preimplementation talk
======================

Spoke with Curtis Hovey.

Implementation details
======================

Largely as in proposed. A new method, getLatestRelease, provides the relevant release information.

Tests
=====

bin/test -t TestProductSeriesReleases
bin/test -t sourcepackage-views.txt

Q&A
===

Open https://launchpad.dev/ubuntu/hoary/+source/evolution/

You should see "Latest version" as part of the upstream data.

Lint
====

make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/interfaces/productseries.py
  lib/lp/registry/model/productseries.py
  lib/lp/registry/templates/sourcepackage-upstream-connections.pt
  lib/lp/registry/tests/test_productseries.py

-- 
https://code.launchpad.net/~jcsackett/launchpad/new-releases-636060/+merge/38773
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/new-releases-636060 into lp:launchpad/devel.
=== modified file 'lib/lp/registry/interfaces/productseries.py'
--- lib/lp/registry/interfaces/productseries.py	2010-09-23 02:15:42 +0000
+++ lib/lp/registry/interfaces/productseries.py	2010-10-18 21:15:58 +0000
@@ -252,6 +252,11 @@
             "A Bazaar branch to commit translation snapshots to.  "
             "Leave blank to disable."))
 
+    def getLatestRelease():
+        """Gets the most recent release in the series.
+
+        Returns None if there is no release."""
+
     def getRelease(version):
         """Get the release in this series that has the specified version.
         Return None is there is no such release.

=== modified file 'lib/lp/registry/model/productseries.py'
--- lib/lp/registry/model/productseries.py	2010-09-23 01:46:29 +0000
+++ lib/lp/registry/model/productseries.py	2010-10-18 21:15:58 +0000
@@ -200,7 +200,6 @@
             service_uses_launchpad(self.codehosting_usage) or
             service_uses_launchpad(self.bug_tracking_usage))
 
-
     def _getMilestoneCondition(self):
         """See `HasMilestonesMixin`."""
         return (Milestone.productseries == self)
@@ -451,6 +450,13 @@
         """See ISpecificationTarget."""
         return self.product.getSpecification(name)
 
+    def getLatestRelease(self):
+        """See `IProductRelease.`"""
+        try:
+            return self.releases[0]
+        except IndexError:
+            return None
+
     def getRelease(self, version):
         for release in self.releases:
             if release.version == version:

=== modified file 'lib/lp/registry/templates/sourcepackage-upstream-connections.pt'
--- lib/lp/registry/templates/sourcepackage-upstream-connections.pt	2010-07-16 08:57:54 +0000
+++ lib/lp/registry/templates/sourcepackage-upstream-connections.pt	2010-10-18 21:15:58 +0000
@@ -24,6 +24,13 @@
           structure context/menu:overview/remove_packaging/fmt:icon " />
       </span>
     </dd>
+    <tal:upstream-version
+      define="release series/getLatestRelease">
+      <dd tal:condition="release">
+        Lastest version:
+        <tal:version replace="release/version"/>
+      </dd>
+    </tal:upstream-version>
   </dl>
 
   <style>

=== modified file 'lib/lp/registry/tests/test_productseries.py'
--- lib/lp/registry/tests/test_productseries.py	2010-10-04 19:50:45 +0000
+++ lib/lp/registry/tests/test_productseries.py	2010-10-18 21:15:58 +0000
@@ -11,6 +11,7 @@
 
 from canonical.launchpad.ftests import login
 from canonical.testing.layers import (
+    DatabaseFunctionalLayer,
     LaunchpadFunctionalLayer,
     ZopelessDatabaseLayer,
     )
@@ -105,7 +106,6 @@
         object_with_driver.driver = self.factory.makePerson()
         return object_with_driver.driver
 
-
     def test_drivers_group(self):
         # A driver on the group is reported as one of the drivers of the
         # series.
@@ -273,5 +273,33 @@
                 self.ps_set.findByTranslationsImportBranch(branch, True))
 
 
+class TestProductSeriesReleases(TestCaseWithFactory):
+    '''Tests the releases functions for productseries.'''
+
+    layer = DatabaseFunctionalLayer
+
+    def setUp(self):
+        super(TestProductSeriesReleases, self).setUp()
+        self.product = self.factory.makeProduct()
+        self.productseries = self.factory.makeProductSeries(
+                                            product=self.product)
+
+    def test_getLatestRelease(self):
+        # getLatestRelease returns the most recent release.
+        self.assertIs(None, self.productseries.getLatestRelease())
+
+        release = self.factory.makeProductRelease(
+                        product=self.product,
+                        productseries=self.productseries)
+        self.assertEqual(release, self.productseries.getLatestRelease())
+
+        second_release = self.factory.makeProductRelease(
+                                product=self.product,
+                                productseries=self.productseries)
+        self.assertEqual(
+            second_release,
+            self.productseries.getLatestRelease())
+
+
 def test_suite():
     return TestLoader().loadTestsFromName(__name__)