launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02003
[Merge] lp:~sinzui/launchpad/prefill-homepageurl-0 into lp:launchpad/devel
Curtis Hovey has proposed merging lp:~sinzui/launchpad/prefill-homepageurl-0 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
This is my branch to prefill the homepageurl when registering projects
for packages.
lp:~sinzui/launchpad/prefill-homepageurl-0
Diff size: 101
Launchpad bug: https://bugs.launchpad.net/bugs/621778
Test command: ./bin/test -vv -t TestSourcePackageViewHelpers
Pre-implementation: jelmer
Target release: 10.12
Prefill the homepageurl when registering projects for packages
--------------------------------------------------------------
This is the final branch needed to support prefilling the project's
homepageurl with the homepage url from the source package release.
All the data, forms, and helpers are in place. The helpers need to
pass the homepageurl to the form.
Rules
-----
* Update get_register_upstream_url() in browser/sourcepackage.py to
include the homepageurl field.
QA
--
* Visit https://qastaging.launchpad.net/ubuntu/+source/maven-plugin-tools
* Choose to register a new project
* Verify that the homepageurl is
http://maven.apache.org/plugins/maven-javadoc-plugin/
Lint
----
Linting changed files:
lib/lp/registry/browser/sourcepackage.py
lib/lp/registry/browser/tests/test_sourcepackage_views.py
Implementation
--------------
Updated get_register_upstream_url to add the homepageurl using the
SP's currentrelease. The value cannot be None because that is serialised
as 'None' which causes a form error since it is not a valid url.
Refactored the setup for a test so that an SP with publishing history is
available to test the homepage.
lib/lp/registry/browser/sourcepackage.py
lib/lp/registry/browser/tests/test_sourcepackage_views.py
--
https://code.launchpad.net/~sinzui/launchpad/prefill-homepageurl-0/+merge/41652
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/prefill-homepageurl-0 into lp:launchpad/devel.
=== modified file 'lib/lp/registry/browser/sourcepackage.py'
--- lib/lp/registry/browser/sourcepackage.py 2010-11-10 13:45:32 +0000
+++ lib/lp/registry/browser/sourcepackage.py 2010-11-23 20:41:41 +0000
@@ -115,6 +115,11 @@
distroseries_string = "%s/%s" % (
source_package.distroseries.distribution.name,
source_package.distroseries.name)
+ current_release = source_package.currentrelease
+ if current_release is not None and current_release.homepage is not None:
+ homepage = current_release.homepage
+ else:
+ homepage = ''
params = {
'_return_url': canonical_url(source_package),
'field.source_package_name': source_package.sourcepackagename.name,
@@ -122,6 +127,7 @@
'field.name': source_package.name,
'field.displayname': displayname,
'field.title': displayname,
+ 'field.homepageurl': homepage,
'field.__visited_steps__': ProjectAddStepOne.step_name,
'field.actions.continue': 'Continue',
}
=== modified file 'lib/lp/registry/browser/tests/test_sourcepackage_views.py'
--- lib/lp/registry/browser/tests/test_sourcepackage_views.py 2010-11-09 23:29:12 +0000
+++ lib/lp/registry/browser/tests/test_sourcepackage_views.py 2010-11-23 20:41:41 +0000
@@ -10,6 +10,7 @@
from zope.component import getUtility
from zope.interface import implements
+from zope.security.proxy import removeSecurityProxy
from canonical.launchpad.testing.pages import find_tag_by_id
from canonical.testing.layers import DatabaseFunctionalLayer
@@ -67,7 +68,7 @@
self.assertEqual((expected_base, expected_params),
(base, params))
- def test_get_register_upstream_url_summary(self):
+ def _makePublishedSourcePackage(self):
test_publisher = SoyuzTestPublisher()
test_data = test_publisher.makeSourcePackageSummaryData()
source_package_name = (
@@ -79,7 +80,10 @@
# updateDistroSeriesPackageCache reconnects the db, so the
# objects need to be reloaded.
distroseries = getUtility(IDistroSeriesSet).get(distroseries_id)
- source_package = distroseries.getSourcePackage(source_package_name)
+ return distroseries.getSourcePackage(source_package_name)
+
+ def test_get_register_upstream_url_summary(self):
+ source_package = self._makePublishedSourcePackage()
url = get_register_upstream_url(source_package)
expected_base = '/projects/+new'
expected_params = [
@@ -130,7 +134,9 @@
distroseries=FakeDistroSeries(
name='walrus',
distribution=FakeDistribution(name='zoobuntu')),
- releases=[releases])
+ releases=[releases],
+ currentrelease=Faker(homepage=None),
+ )
url = get_register_upstream_url(source_package)
expected_base = '/projects/+new'
@@ -153,6 +159,32 @@
self.assertEqual((expected_base, expected_params),
(base, params))
+ def test_get_register_upstream_url_homepage(self):
+ source_package = self._makePublishedSourcePackage()
+ # SourcePackageReleases cannot be modified by users.
+ removeSecurityProxy(
+ source_package.currentrelease).homepage = 'http://eg.dom/bonkers'
+ url = get_register_upstream_url(source_package)
+ expected_base = '/projects/+new'
+ expected_params = [
+ ('_return_url',
+ 'http://launchpad.dev/youbuntu/busy/+source/bonkers'),
+ ('field.__visited_steps__', 'projectaddstep1'),
+ ('field.actions.continue', 'Continue'),
+ ('field.displayname', 'Bonkers'),
+ ('field.distroseries', 'youbuntu/busy'),
+ ('field.homepageurl', 'http://eg.dom/bonkers'),
+ ('field.name', 'bonkers'),
+ ('field.source_package_name', 'bonkers'),
+ ('field.summary', 'summary for flubber-bin\n'
+ + 'summary for flubber-lib'),
+ ('field.title', 'Bonkers'),
+ ]
+ base, query = urllib.splitquery(url)
+ params = cgi.parse_qsl(query)
+ self.assertEqual((expected_base, expected_params),
+ (base, params))
+
class TestSourcePackageUpstreamConnectionsView(TestCaseWithFactory):