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
1=== modified file 'lib/lp/registry/interfaces/productseries.py'
2--- lib/lp/registry/interfaces/productseries.py 2010-09-23 02:15:42 +0000
3+++ lib/lp/registry/interfaces/productseries.py 2010-10-19 14:16:08 +0000
4@@ -252,6 +252,11 @@
5 "A Bazaar branch to commit translation snapshots to. "
6 "Leave blank to disable."))
7
8+ def getLatestRelease():
9+ """Gets the most recent release in the series.
10+
11+ Returns None if there is no release."""
12+
13 def getRelease(version):
14 """Get the release in this series that has the specified version.
15 Return None is there is no such release.
16
17=== modified file 'lib/lp/registry/model/productseries.py'
18--- lib/lp/registry/model/productseries.py 2010-09-23 01:46:29 +0000
19+++ lib/lp/registry/model/productseries.py 2010-10-19 14:16:08 +0000
20@@ -200,7 +200,6 @@
21 service_uses_launchpad(self.codehosting_usage) or
22 service_uses_launchpad(self.bug_tracking_usage))
23
24-
25 def _getMilestoneCondition(self):
26 """See `HasMilestonesMixin`."""
27 return (Milestone.productseries == self)
28@@ -451,6 +450,13 @@
29 """See ISpecificationTarget."""
30 return self.product.getSpecification(name)
31
32+ def getLatestRelease(self):
33+ """See `IProductRelease.`"""
34+ try:
35+ return self.releases[0]
36+ except IndexError:
37+ return None
38+
39 def getRelease(self, version):
40 for release in self.releases:
41 if release.version == version:
42
43=== modified file 'lib/lp/registry/templates/sourcepackage-upstream-connections.pt'
44--- lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-07-16 08:57:54 +0000
45+++ lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-10-19 14:16:08 +0000
46@@ -24,6 +24,13 @@
47 structure context/menu:overview/remove_packaging/fmt:icon " />
48 </span>
49 </dd>
50+ <tal:upstream-version
51+ define="release series/getLatestRelease">
52+ <dd tal:condition="release">
53+ Lastest version:
54+ <tal:version replace="release/version"/>
55+ </dd>
56+ </tal:upstream-version>
57 </dl>
58
59 <style>
60
61=== modified file 'lib/lp/registry/tests/test_productseries.py'
62--- lib/lp/registry/tests/test_productseries.py 2010-10-04 19:50:45 +0000
63+++ lib/lp/registry/tests/test_productseries.py 2010-10-19 14:16:08 +0000
64@@ -11,6 +11,7 @@
65
66 from canonical.launchpad.ftests import login
67 from canonical.testing.layers import (
68+ DatabaseFunctionalLayer,
69 LaunchpadFunctionalLayer,
70 ZopelessDatabaseLayer,
71 )
72@@ -105,7 +106,6 @@
73 object_with_driver.driver = self.factory.makePerson()
74 return object_with_driver.driver
75
76-
77 def test_drivers_group(self):
78 # A driver on the group is reported as one of the drivers of the
79 # series.
80@@ -273,5 +273,33 @@
81 self.ps_set.findByTranslationsImportBranch(branch, True))
82
83
84+class TestProductSeriesReleases(TestCaseWithFactory):
85+ '''Tests the releases functions for productseries.'''
86+
87+ layer = DatabaseFunctionalLayer
88+
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)
107+ self.assertEqual(
108+ second_release,
109+ self.productseries.getLatestRelease())
110+
111+
112 def test_suite():
113 return TestLoader().loadTestsFromName(__name__)