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

Proposed by j.c.sackett
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 11752
Proposed branch: lp:~jcsackett/launchpad/new-releases-636060
Merge into: lp:launchpad
Diff against target: 113 lines (+48/-2)
4 files modified
lib/lp/registry/interfaces/productseries.py (+5/-0)
lib/lp/registry/model/productseries.py (+7/-1)
lib/lp/registry/templates/sourcepackage-upstream-connections.pt (+7/-0)
lib/lp/registry/tests/test_productseries.py (+29/-1)
To merge this branch: bzr merge lp:~jcsackett/launchpad/new-releases-636060
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+38773@code.launchpad.net

Commit message

Adds latest upstream release version to the sourcepackage upstream portlet.

Description of the change

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

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

A few comments:

> 8 + def getLatestRelease():
> 9 + """Gets the most recent release in the series.
> 10 +
> 11 + Returns None if there is no release."""
> 12 +

The closing """ of a multi-line docstring should be on its own line.

> 89 + def setUp(self):
> 90 + super(TestProductSeriesReleases, self).setUp()
> 91 + self.product = self.factory.makeProduct()
> 92 + self.productseries = self.factory.makeProductSeries(
> 93 + product=self.product)
> 94 +
> 95 + def test_getLatestRelease(self):
> 96 + # getLatestRelease returns the most recent release.
> 97 + self.assertIs(None, self.productseries.getLatestRelease())
> 98 +
> 99 + release = self.factory.makeProductRelease(
> 100 + product=self.product,
> 101 + productseries=self.productseries)
> 102 + self.assertEqual(release, self.productseries.getLatestRelease())
> 103 +
> 104 + second_release = self.factory.makeProductRelease(
> 105 + product=self.product,
> 106 + productseries=self.productseries)

We indent parameters on method calls by four spaces, e.g.:

    second_release = self.factory.makeProductRelease(
        product=self.product, productseries=self.productseries)

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-19 14:16:08 +0000
@@ -252,6 +252,11 @@
252 "A Bazaar branch to commit translation snapshots to. "252 "A Bazaar branch to commit translation snapshots to. "
253 "Leave blank to disable."))253 "Leave blank to disable."))
254254
255 def getLatestRelease():
256 """Gets the most recent release in the series.
257
258 Returns None if there is no release."""
259
255 def getRelease(version):260 def getRelease(version):
256 """Get the release in this series that has the specified version.261 """Get the release in this series that has the specified version.
257 Return None is there is no such release.262 Return None is there is no such release.
258263
=== 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-19 14:16:08 +0000
@@ -200,7 +200,6 @@
200 service_uses_launchpad(self.codehosting_usage) or200 service_uses_launchpad(self.codehosting_usage) or
201 service_uses_launchpad(self.bug_tracking_usage))201 service_uses_launchpad(self.bug_tracking_usage))
202202
203
204 def _getMilestoneCondition(self):203 def _getMilestoneCondition(self):
205 """See `HasMilestonesMixin`."""204 """See `HasMilestonesMixin`."""
206 return (Milestone.productseries == self)205 return (Milestone.productseries == self)
@@ -451,6 +450,13 @@
451 """See ISpecificationTarget."""450 """See ISpecificationTarget."""
452 return self.product.getSpecification(name)451 return self.product.getSpecification(name)
453452
453 def getLatestRelease(self):
454 """See `IProductRelease.`"""
455 try:
456 return self.releases[0]
457 except IndexError:
458 return None
459
454 def getRelease(self, version):460 def getRelease(self, version):
455 for release in self.releases:461 for release in self.releases:
456 if release.version == version:462 if release.version == version:
457463
=== 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-19 14:16:08 +0000
@@ -24,6 +24,13 @@
24 structure context/menu:overview/remove_packaging/fmt:icon " />24 structure context/menu:overview/remove_packaging/fmt:icon " />
25 </span>25 </span>
26 </dd>26 </dd>
27 <tal:upstream-version
28 define="release series/getLatestRelease">
29 <dd tal:condition="release">
30 Lastest version:
31 <tal:version replace="release/version"/>
32 </dd>
33 </tal:upstream-version>
27 </dl>34 </dl>
2835
29 <style>36 <style>
3037
=== 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-19 14:16:08 +0000
@@ -11,6 +11,7 @@
1111
12from canonical.launchpad.ftests import login12from canonical.launchpad.ftests import login
13from canonical.testing.layers import (13from canonical.testing.layers import (
14 DatabaseFunctionalLayer,
14 LaunchpadFunctionalLayer,15 LaunchpadFunctionalLayer,
15 ZopelessDatabaseLayer,16 ZopelessDatabaseLayer,
16 )17 )
@@ -105,7 +106,6 @@
105 object_with_driver.driver = self.factory.makePerson()106 object_with_driver.driver = self.factory.makePerson()
106 return object_with_driver.driver107 return object_with_driver.driver
107108
108
109 def test_drivers_group(self):109 def test_drivers_group(self):
110 # A driver on the group is reported as one of the drivers of the110 # A driver on the group is reported as one of the drivers of the
111 # series.111 # series.
@@ -273,5 +273,33 @@
273 self.ps_set.findByTranslationsImportBranch(branch, True))273 self.ps_set.findByTranslationsImportBranch(branch, True))
274274
275275
276class TestProductSeriesReleases(TestCaseWithFactory):
277 '''Tests the releases functions for productseries.'''
278
279 layer = DatabaseFunctionalLayer
280
281 def setUp(self):
282 super(TestProductSeriesReleases, self).setUp()
283 self.product = self.factory.makeProduct()
284 self.productseries = self.factory.makeProductSeries(
285 product=self.product)
286
287 def test_getLatestRelease(self):
288 # getLatestRelease returns the most recent release.
289 self.assertIs(None, self.productseries.getLatestRelease())
290
291 release = self.factory.makeProductRelease(
292 product=self.product,
293 productseries=self.productseries)
294 self.assertEqual(release, self.productseries.getLatestRelease())
295
296 second_release = self.factory.makeProductRelease(
297 product=self.product,
298 productseries=self.productseries)
299 self.assertEqual(
300 second_release,
301 self.productseries.getLatestRelease())
302
303
276def test_suite():304def test_suite():
277 return TestLoader().loadTestsFromName(__name__)305 return TestLoader().loadTestsFromName(__name__)