Merge lp:~sinzui/launchpad/do-not-release into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~sinzui/launchpad/do-not-release
Merge into: lp:launchpad
Diff against target: 167 lines (+93/-6)
4 files modified
lib/lp/registry/browser/product.py (+17/-3)
lib/lp/registry/browser/tests/product-portlet-packages-view.txt (+74/-1)
lib/lp/registry/stories/product/xx-product-index.txt (+0/-1)
lib/lp/registry/templates/product-portlet-packages.pt (+2/-1)
To merge this branch: bzr merge lp:~sinzui/launchpad/do-not-release
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+22239@code.launchpad.net

Description of the change

This is my branch to not release suggest project packages portlet.

    lp:~sinzui/launchpad/do-not-release
    Diff size:
    Launchpad bug: https://bugs.launchpad.net/bugs/548822
    Test command: ./bin/test -vv \
        -t product-portlet-packages-view \
        -t xx-product-index
    Pre-implementation: no one
    Target release: 10.03

not release suggest project packages portlet
--------------------------------------------------------------------

The portlet that suggests packages that a project provides should not be
visible to general users because it is not yet possible to say that the
project does not provide any packages.

Rules
-----

    * The portlet should only be visible on dev, staging and edge.
    * Bonus: Do not show obsolete packages and limit the number to the
      5 most recent.

QA
--

    * Visit /gdp on edge and staging and verify the packages portlet
      suggests packages
    * Visit lp.net and verify /gdp does not suggest packages.
    * Visit /bzr and verify that every package has an upload time and that
      there are fix of them.

Lint
----

Linting changed files:
  lib/lp/registry/browser/product.py
  lib/lp/registry/browser/tests/product-portlet-packages-view.txt
  lib/lp/registry/stories/product/xx-product-index.txt
  lib/lp/registry/templates/product-portlet-packages.pt

Test
----

    * lib/lp/registry/browser/tests/product-portlet-packages-view.txt
      * Added a test for sourcepackages and can_show_portlet
    * lib/lp/registry/stories/product/xx-product-index.txt
      * Updated the test to verify that obsolete packages are not shown.

Implementation
--------------

    * lib/lp/registry/browser/product.py
      * Added a property to test if the portlet should be shown.
        This property will continue to be used after development. In the
        future it will replace the lpnet check with a check for a confirmation
        that the project is already known not to be packaged.
      * Add a property to filter the obsolete sourcepackages and limit them
        to 5.
    * lib/lp/registry/templates/product-portlet-packages.pt
      * Updated the template to use the two properties.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Looks good.

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/browser/product.py'
2--- lib/lp/registry/browser/product.py 2010-03-23 15:35:39 +0000
3+++ lib/lp/registry/browser/product.py 2010-03-26 17:36:44 +0000
4@@ -452,7 +452,7 @@
5 'bugsupervisor',
6 'securitycontact',
7 'cve',
8- 'subscribe'
9+ 'subscribe',
10 )
11
12 def filebug(self):
13@@ -978,6 +978,20 @@
14 orientation='vertical')
15 suggestions = None
16
17+ @cachedproperty
18+ def sourcepackages(self):
19+ """The project's latest source packages."""
20+ current_packages = [
21+ sp for sp in self.context.sourcepackages
22+ if sp.currentrelease is not None]
23+ current_packages.reverse()
24+ return current_packages[0:5]
25+
26+ @cachedproperty
27+ def can_show_portlet(self):
28+ """Are there packages, or can packages be suggested."""
29+ return len(self.sourcepackages) > 0 or not config.launchpad.is_lpnet
30+
31 def setUpFields(self):
32 """See `LaunchpadFormView`."""
33 super(ProductPackagesPortletView, self).setUpFields()
34@@ -1341,6 +1355,7 @@
35 # supervisor.
36 self.validate_private_bugs(data)
37
38+
39 class ProductAddSeriesView(LaunchpadFormView):
40 """A form to add new product series"""
41
42@@ -1742,8 +1757,7 @@
43 description=description,
44 licenses=data['licenses'],
45 license_info=data['license_info'],
46- project=project
47- )
48+ project=project)
49
50 def main_action(self, data):
51 """See `MultiStepView`."""
52
53=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
54--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-23 14:52:14 +0000
55+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-26 17:36:44 +0000
56@@ -61,7 +61,8 @@
57 provides. Links from distribution packages to upstream projects
58 let distribution and upstream maintainers share bugs, patches, and
59 translations efficiently.
60- There are no unlinked source packages that are a good match. Can you suggest one?
61+ There are no unlinked source packages that are a good match. Can you
62+ suggest one?
63 Link to Ubuntu package
64
65
66@@ -182,3 +183,75 @@
67 >>> for dsp in view.suggestions:
68 ... print dsp.name
69 bingo
70+
71+The can_show_portlet property indicates that the portlet can be rendered. The
72+portlet is not rendered if there are no source packages and the environment
73+is lpnet.
74+
75+ >>> config.launchpad.is_lpnet
76+ False
77+
78+ >>> view.sourcepackages
79+ []
80+
81+ >>> view.can_show_portlet
82+ True
83+
84+ >>> print extract_text(view.render())
85+ All packages
86+ Packages in Ubuntu ...
87+
88+ >>> test_data = """
89+ ... [launchpad]
90+ ... is_lpnet: True
91+ ... """
92+ >>> config.push('test_data', test_data)
93+ >>> config.launchpad.is_lpnet
94+ True
95+
96+ >>> view = create_initialized_view(
97+ ... product, name="+portlet-packages", principal=product.owner)
98+ >>> view.can_show_portlet
99+ False
100+
101+ >>> print extract_text(view.render())
102+ <BLANKLINE>
103+
104+ >>> ignore = config.pop('test_data')
105+
106+The view's sourcepackages property filters out obsolete packages and
107+reverses the order so that the latest packages for the current ubuntu
108+series are shown first.
109+
110+ >>> from lp.registry.interfaces.packaging import (
111+ ... IPackagingUtil, PackagingType)
112+
113+ >>> packaging_util = getUtility(IPackagingUtil)
114+ >>> series = ubuntu.currentseries
115+ >>> spn = factory.makeSourcePackageName(name="a-obsolete-package")
116+ >>> packaging_util.createPackaging(
117+ ... product.development_focus, spn, ubuntu.currentseries,
118+ ... PackagingType.PRIME, owner=product.owner)
119+ >>> spn = factory.makeSourcePackageName(name="b-recent-package")
120+ >>> spph = factory.makeSourcePackagePublishingHistory(
121+ ... sourcepackagename=spn, distroseries=ubuntu.currentseries)
122+ >>> packaging_util.createPackaging(
123+ ... product.development_focus, spn, ubuntu.currentseries,
124+ ... PackagingType.PRIME, owner=product.owner)
125+ >>> spn = factory.makeSourcePackageName(name="c-current-package")
126+ >>> spph = factory.makeSourcePackagePublishingHistory(
127+ ... sourcepackagename=spn, distroseries=ubuntu.currentseries)
128+ >>> packaging_util.createPackaging(
129+ ... product.development_focus, spn, ubuntu.currentseries,
130+ ... PackagingType.PRIME, owner=product.owner)
131+ >>> for package in product.sourcepackages:
132+ ... print package.name
133+ a-obsolete-package
134+ b-recent-package
135+ c-current-package
136+
137+ >>> view = create_initialized_view(product, name="+portlet-packages")
138+ >>> for package in view.sourcepackages:
139+ ... print package.name
140+ c-current-package
141+ b-recent-package
142
143=== modified file 'lib/lp/registry/stories/product/xx-product-index.txt'
144--- lib/lp/registry/stories/product/xx-product-index.txt 2010-03-09 01:45:05 +0000
145+++ lib/lp/registry/stories/product/xx-product-index.txt 2010-03-26 17:36:44 +0000
146@@ -360,7 +360,6 @@
147 ... find_tag_by_id(user_browser.contents, 'portlet-packages'))
148 All packages
149 Packages in Ubuntu
150- “mozilla-firefox” source package in Hoary
151 “mozilla-firefox” source package in Warty Version 0.9 uploaded on...
152
153 A product that has linked packages now displays suggestions and asks
154
155=== modified file 'lib/lp/registry/templates/product-portlet-packages.pt'
156--- lib/lp/registry/templates/product-portlet-packages.pt 2010-03-08 19:42:11 +0000
157+++ lib/lp/registry/templates/product-portlet-packages.pt 2010-03-26 17:36:44 +0000
158@@ -3,7 +3,8 @@
159 xmlns:metal="http://xml.zope.org/namespaces/metal"
160 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
161 omit-tag=""
162- define="packages context/sourcepackages">
163+ define="packages view/sourcepackages"
164+ condition="view/can_show_portlet">
165
166 <div class="portlet" id="portlet-packages">
167 <h2>