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
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2010-03-26 17:32:19 +0000
+++ lib/lp/registry/browser/product.py 2010-04-06 22:11:10 +0000
@@ -996,19 +996,21 @@
996 """See `LaunchpadFormView`."""996 """See `LaunchpadFormView`."""
997 super(ProductPackagesPortletView, self).setUpFields()997 super(ProductPackagesPortletView, self).setUpFields()
998 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu998 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
999 source_packages = ubuntu.searchSourcePackages(999 distro_source_packages = ubuntu.searchSourcePackages(
1000 self.context.name, has_packaging=False,1000 self.context.name, has_packaging=False,
1001 publishing_distroseries=ubuntu.currentseries)1001 publishing_distroseries=ubuntu.currentseries)
1002 # Based upon the matches, create a new vocabulary with1002 # Based upon the matches, create a new vocabulary with
1003 # term descriptions that include a link to the source package.1003 # term descriptions that include a link to the source package.
1004 self.suggestions = []1004 self.suggestions = []
1005 vocab_terms = []1005 vocab_terms = []
1006 for package in source_packages[:20]:1006 for package in distro_source_packages[:20]:
1007 self.suggestions.append(package)1007 if package.development_version.currentrelease is not None:
1008 item_url = canonical_url(package)1008 self.suggestions.append(package)
1009 description = """<a href="%s">%s</a>""" % (1009 item_url = canonical_url(package)
1010 item_url, escape(package.name))1010 description = """<a href="%s">%s</a>""" % (
1011 vocab_terms.append(SimpleTerm(package, package.name, description))1011 item_url, escape(package.name))
1012 vocab_terms.append(
1013 SimpleTerm(package, package.name, description))
1012 vocabulary = SimpleVocabulary(vocab_terms)1014 vocabulary = SimpleVocabulary(vocab_terms)
1013 self.form_fields = form.Fields(1015 self.form_fields = form.Fields(
1014 Choice(__name__='distributionsourcepackage',1016 Choice(__name__='distributionsourcepackage',
10151017
=== modified file 'lib/lp/registry/browser/tests/product-portlet-packages-view.txt'
--- lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-03-26 16:12:55 +0000
+++ lib/lp/registry/browser/tests/product-portlet-packages-view.txt 2010-04-06 22:11:10 +0000
@@ -96,12 +96,26 @@
96 >>> for dsp in view.suggestions:96 >>> for dsp in view.suggestions:
97 ... print dsp.name97 ... print dsp.name
9898
99A source package that does NOT have a publishing history in the PENDING
100or PUBLISHED statuses will NOT be suggested.
101
102 >>> from lp.soyuz.interfaces.publishing import PackagePublishingStatus
103 >>> spph = factory.makeSourcePackagePublishingHistory(
104 ... sourcepackagename=spn, distroseries=ubuntu.currentseries,
105 ... status=PackagePublishingStatus.DELETED)
106 >>> (ubuntu, product, spn) = updateCache()
107 >>> view = create_initialized_view(
108 ... product, name="+portlet-packages",
109 ... principal=product.owner)
110 >>> for dsp in view.suggestions:
111 ... print dsp.name
112
99A source package that does have a publishing history for the current113A source package that does have a publishing history for the current
100Ubuntu series will be suggested.114Ubuntu series in the PUBLISHED status will be suggested.
101115
102 >>> spph = factory.makeSourcePackagePublishingHistory(116 >>> spph = factory.makeSourcePackagePublishingHistory(
103 ... sourcepackagename=spn, distroseries=ubuntu.currentseries)117 ... sourcepackagename=spn, distroseries=ubuntu.currentseries,
104 >>> (ubuntu, product, spn) = updateCache()118 ... status=PackagePublishingStatus.PUBLISHED)
105 >>> view = create_initialized_view(119 >>> view = create_initialized_view(
106 ... product, name="+portlet-packages",120 ... product, name="+portlet-packages",
107 ... principal=product.owner)121 ... principal=product.owner)