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
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2010-03-23 15:35:39 +0000
+++ lib/lp/registry/browser/product.py 2010-03-26 17:36:44 +0000
@@ -452,7 +452,7 @@
452 'bugsupervisor',452 'bugsupervisor',
453 'securitycontact',453 'securitycontact',
454 'cve',454 'cve',
455 'subscribe'455 'subscribe',
456 )456 )
457457
458 def filebug(self):458 def filebug(self):
@@ -978,6 +978,20 @@
978 orientation='vertical')978 orientation='vertical')
979 suggestions = None979 suggestions = None
980980
981 @cachedproperty
982 def sourcepackages(self):
983 """The project's latest source packages."""
984 current_packages = [
985 sp for sp in self.context.sourcepackages
986 if sp.currentrelease is not None]
987 current_packages.reverse()
988 return current_packages[0:5]
989
990 @cachedproperty
991 def can_show_portlet(self):
992 """Are there packages, or can packages be suggested."""
993 return len(self.sourcepackages) > 0 or not config.launchpad.is_lpnet
994
981 def setUpFields(self):995 def setUpFields(self):
982 """See `LaunchpadFormView`."""996 """See `LaunchpadFormView`."""
983 super(ProductPackagesPortletView, self).setUpFields()997 super(ProductPackagesPortletView, self).setUpFields()
@@ -1341,6 +1355,7 @@
1341 # supervisor.1355 # supervisor.
1342 self.validate_private_bugs(data)1356 self.validate_private_bugs(data)
13431357
1358
1344class ProductAddSeriesView(LaunchpadFormView):1359class ProductAddSeriesView(LaunchpadFormView):
1345 """A form to add new product series"""1360 """A form to add new product series"""
13461361
@@ -1742,8 +1757,7 @@
1742 description=description,1757 description=description,
1743 licenses=data['licenses'],1758 licenses=data['licenses'],
1744 license_info=data['license_info'],1759 license_info=data['license_info'],
1745 project=project1760 project=project)
1746 )
17471761
1748 def main_action(self, data):1762 def main_action(self, data):
1749 """See `MultiStepView`."""1763 """See `MultiStepView`."""
17501764
=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-23 14:52:14 +0000
+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-26 17:36:44 +0000
@@ -61,7 +61,8 @@
61 provides. Links from distribution packages to upstream projects61 provides. Links from distribution packages to upstream projects
62 let distribution and upstream maintainers share bugs, patches, and62 let distribution and upstream maintainers share bugs, patches, and
63 translations efficiently.63 translations efficiently.
64 There are no unlinked source packages that are a good match. Can you suggest one?64 There are no unlinked source packages that are a good match. Can you
65 suggest one?
65 Link to Ubuntu package66 Link to Ubuntu package
6667
6768
@@ -182,3 +183,75 @@
182 >>> for dsp in view.suggestions:183 >>> for dsp in view.suggestions:
183 ... print dsp.name184 ... print dsp.name
184 bingo185 bingo
186
187The can_show_portlet property indicates that the portlet can be rendered. The
188portlet is not rendered if there are no source packages and the environment
189is lpnet.
190
191 >>> config.launchpad.is_lpnet
192 False
193
194 >>> view.sourcepackages
195 []
196
197 >>> view.can_show_portlet
198 True
199
200 >>> print extract_text(view.render())
201 All packages
202 Packages in Ubuntu ...
203
204 >>> test_data = """
205 ... [launchpad]
206 ... is_lpnet: True
207 ... """
208 >>> config.push('test_data', test_data)
209 >>> config.launchpad.is_lpnet
210 True
211
212 >>> view = create_initialized_view(
213 ... product, name="+portlet-packages", principal=product.owner)
214 >>> view.can_show_portlet
215 False
216
217 >>> print extract_text(view.render())
218 <BLANKLINE>
219
220 >>> ignore = config.pop('test_data')
221
222The view's sourcepackages property filters out obsolete packages and
223reverses the order so that the latest packages for the current ubuntu
224series are shown first.
225
226 >>> from lp.registry.interfaces.packaging import (
227 ... IPackagingUtil, PackagingType)
228
229 >>> packaging_util = getUtility(IPackagingUtil)
230 >>> series = ubuntu.currentseries
231 >>> spn = factory.makeSourcePackageName(name="a-obsolete-package")
232 >>> packaging_util.createPackaging(
233 ... product.development_focus, spn, ubuntu.currentseries,
234 ... PackagingType.PRIME, owner=product.owner)
235 >>> spn = factory.makeSourcePackageName(name="b-recent-package")
236 >>> spph = factory.makeSourcePackagePublishingHistory(
237 ... sourcepackagename=spn, distroseries=ubuntu.currentseries)
238 >>> packaging_util.createPackaging(
239 ... product.development_focus, spn, ubuntu.currentseries,
240 ... PackagingType.PRIME, owner=product.owner)
241 >>> spn = factory.makeSourcePackageName(name="c-current-package")
242 >>> spph = factory.makeSourcePackagePublishingHistory(
243 ... sourcepackagename=spn, distroseries=ubuntu.currentseries)
244 >>> packaging_util.createPackaging(
245 ... product.development_focus, spn, ubuntu.currentseries,
246 ... PackagingType.PRIME, owner=product.owner)
247 >>> for package in product.sourcepackages:
248 ... print package.name
249 a-obsolete-package
250 b-recent-package
251 c-current-package
252
253 >>> view = create_initialized_view(product, name="+portlet-packages")
254 >>> for package in view.sourcepackages:
255 ... print package.name
256 c-current-package
257 b-recent-package
185258
=== modified file 'lib/lp/registry/stories/product/xx-product-index.txt'
--- lib/lp/registry/stories/product/xx-product-index.txt 2010-03-09 01:45:05 +0000
+++ lib/lp/registry/stories/product/xx-product-index.txt 2010-03-26 17:36:44 +0000
@@ -360,7 +360,6 @@
360 ... find_tag_by_id(user_browser.contents, 'portlet-packages'))360 ... find_tag_by_id(user_browser.contents, 'portlet-packages'))
361 All packages361 All packages
362 Packages in Ubuntu362 Packages in Ubuntu
363 “mozilla-firefox” source package in Hoary
364 “mozilla-firefox” source package in Warty Version 0.9 uploaded on...363 “mozilla-firefox” source package in Warty Version 0.9 uploaded on...
365364
366A product that has linked packages now displays suggestions and asks365A product that has linked packages now displays suggestions and asks
367366
=== modified file 'lib/lp/registry/templates/product-portlet-packages.pt'
--- lib/lp/registry/templates/product-portlet-packages.pt 2010-03-08 19:42:11 +0000
+++ lib/lp/registry/templates/product-portlet-packages.pt 2010-03-26 17:36:44 +0000
@@ -3,7 +3,8 @@
3 xmlns:metal="http://xml.zope.org/namespaces/metal"3 xmlns:metal="http://xml.zope.org/namespaces/metal"
4 xmlns:i18n="http://xml.zope.org/namespaces/i18n"4 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5 omit-tag=""5 omit-tag=""
6 define="packages context/sourcepackages">6 define="packages view/sourcepackages"
7 condition="view/can_show_portlet">
78
8<div class="portlet" id="portlet-packages">9<div class="portlet" id="portlet-packages">
9 <h2>10 <h2>