Merge lp:~edwin-grubbs/launchpad/bug-552619-suggesting-removed-packages into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-552619-suggesting-removed-packages
Merge into: lp:launchpad
Diff against target: 66 lines (+26/-10)
2 files modified
lib/lp/registry/browser/product.py (+9/-7)
lib/lp/registry/browser/tests/product-portlet-packages-view.txt (+17/-3)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-552619-suggesting-removed-packages
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+22912@code.launchpad.net

Commit message

Fix problem where the project index page would suggest linking to an ubuntu package that had been deleted.

Description of the change

Summary
-------

ubuntu.searchSourcePackages() was returning packages that are invalid
suggestions since it does not filter on the status of the entries in the
SourcePackagePublishingHistory table.

Implementation details
----------------------

Instead of extending the search functionality, I matched the assertion
in the model by checking the SourcePackage.currentrelease for
ubuntu.currentseries. ubuntu.searchSourcePackages() actually returns
DistributionSourcePackage objects. The SourcePackage objects for the
currentseries is accessed as the development_version attribute on the
DistributionSourcePackage.

Tests
-----

./bin/test -vv -t product-portlet-packages-view

Demo and Q/A
------------

On launchpad.dev:
* Run this query on the launchpad_dev db:
  UPDATE sourcepackagepublishinghistory SET distroseries = 22, status=3;
  * Open http://launchpad.dev/firefox
    * There should be no packages suggested in the Packages in Ubuntu
      portlet.

On edge:
* Open https://edge.launchpad.net/waf
  * The "waf" package should not be suggested in the Packages in Ubuntu
    portlet.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) :
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-26 17:32:19 +0000
3+++ lib/lp/registry/browser/product.py 2010-04-06 22:11:10 +0000
4@@ -996,19 +996,21 @@
5 """See `LaunchpadFormView`."""
6 super(ProductPackagesPortletView, self).setUpFields()
7 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
8- source_packages = ubuntu.searchSourcePackages(
9+ distro_source_packages = ubuntu.searchSourcePackages(
10 self.context.name, has_packaging=False,
11 publishing_distroseries=ubuntu.currentseries)
12 # Based upon the matches, create a new vocabulary with
13 # term descriptions that include a link to the source package.
14 self.suggestions = []
15 vocab_terms = []
16- for package in source_packages[:20]:
17- self.suggestions.append(package)
18- item_url = canonical_url(package)
19- description = """<a href="%s">%s</a>""" % (
20- item_url, escape(package.name))
21- vocab_terms.append(SimpleTerm(package, package.name, description))
22+ for package in distro_source_packages[:20]:
23+ if package.development_version.currentrelease is not None:
24+ self.suggestions.append(package)
25+ item_url = canonical_url(package)
26+ description = """<a href="%s">%s</a>""" % (
27+ item_url, escape(package.name))
28+ vocab_terms.append(
29+ SimpleTerm(package, package.name, description))
30 vocabulary = SimpleVocabulary(vocab_terms)
31 self.form_fields = form.Fields(
32 Choice(__name__='distributionsourcepackage',
33
34=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
35--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-26 16:12:55 +0000
36+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-04-06 22:11:10 +0000
37@@ -96,12 +96,26 @@
38 >>> for dsp in view.suggestions:
39 ... print dsp.name
40
41+A source package that does NOT have a publishing history in the PENDING
42+or PUBLISHED statuses will NOT be suggested.
43+
44+ >>> from lp.soyuz.interfaces.publishing import PackagePublishingStatus
45+ >>> spph = factory.makeSourcePackagePublishingHistory(
46+ ... sourcepackagename=spn, distroseries=ubuntu.currentseries,
47+ ... status=PackagePublishingStatus.DELETED)
48+ >>> (ubuntu, product, spn) = updateCache()
49+ >>> view = create_initialized_view(
50+ ... product, name="+portlet-packages",
51+ ... principal=product.owner)
52+ >>> for dsp in view.suggestions:
53+ ... print dsp.name
54+
55 A source package that does have a publishing history for the current
56-Ubuntu series will be suggested.
57+Ubuntu series in the PUBLISHED status will be suggested.
58
59 >>> spph = factory.makeSourcePackagePublishingHistory(
60- ... sourcepackagename=spn, distroseries=ubuntu.currentseries)
61- >>> (ubuntu, product, spn) = updateCache()
62+ ... sourcepackagename=spn, distroseries=ubuntu.currentseries,
63+ ... status=PackagePublishingStatus.PUBLISHED)
64 >>> view = create_initialized_view(
65 ... product, name="+portlet-packages",
66 ... principal=product.owner)