launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14526
[Merge] lp:~stevenk/launchpad/archive-edit-dependencies-oops into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/archive-edit-dependencies-oops into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #828133 in Launchpad itself: "Archive:+edit-dependencies OOPSes when Ubuntu dependency changed via API"
https://bugs.launchpad.net/launchpad/+bug/828133
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/archive-edit-dependencies-oops/+merge/136075
Teach Archive:+edit-dependencies about components other than multiverse. If an archive has a dependency on the Ubuntu primary archive with a component of main, which can be set via the API, the page will OOPS, since main is not in the vocab that the page builds for components. Extend it to deal with them, and only display them if they are set.
--
https://code.launchpad.net/~stevenk/launchpad/archive-edit-dependencies-oops/+merge/136075
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/archive-edit-dependencies-oops into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2012-11-13 09:36:41 +0000
+++ lib/lp/soyuz/browser/archive.py 2012-11-26 01:38:20 +0000
@@ -29,7 +29,6 @@
]
-from cgi import escape
from datetime import (
datetime,
timedelta,
@@ -1698,25 +1697,39 @@
"""Create the 'primary_components' field.
'primary_components' widget is a choice, rendered as radio-buttons,
- with two options that provides an IComponent as its value:
+ with five options that provides an IComponent as its value:
- || Option || Value ||
- || ALL_COMPONENTS || multiverse ||
- || FOLLOW_PRIMARY || None ||
+ || Option || Value ||
+ || ALL_COMPONENTS || multiverse ||
+ || FOLLOW_PRIMARY || None ||
+ || OTHER_MAIN || main ||
+ || OTHER_RESTRICTED || restricted ||
+ || OTHER_UNIVERSE || universe ||
When omitted in the form, this widget defaults to 'All ubuntu
- components' option when rendered.
+ components' option when rendered. main, restricted, universe are
+ only added to the list of options if the dependency uses them.
"""
- multiverse = getUtility(IComponentSet)['multiverse']
+ componentset = getUtility(IComponentSet)
all_components = SimpleTerm(
- multiverse, 'ALL_COMPONENTS',
+ componentset['multiverse'], 'ALL_COMPONENTS',
_('Use all %s components available.' %
self.context.distribution.displayname))
follow_primary = SimpleTerm(
None, 'FOLLOW_PRIMARY',
_('Use the same components used for each source in the %s '
'primary archive.' % self.context.distribution.displayname))
+ extra_components = {
+ 'main': SimpleTerm(
+ componentset['main'], 'OTHER_MAIN',
+ _('Unsupported component (main)')),
+ 'restricted': SimpleTerm(
+ componentset['restricted'], 'OTHER_RESTRICTED',
+ _('Unsupported component (restricted)')),
+ 'universe': SimpleTerm(
+ componentset['universe'], 'OTHER_UNIVERSE',
+ _('Unsupported component (universe)'))}
primary_dependency = self.context.getArchiveDependency(
self.context.distribution.main_archive)
@@ -1727,6 +1740,8 @@
default_value = primary_dependency.component
terms = [all_components, follow_primary]
+ if default_value and default_value.name in extra_components:
+ terms.append(extra_components[default_value.name])
primary_components_vocabulary = SimpleVocabulary(terms)
current_term = primary_components_vocabulary.getTerm(default_value)
=== modified file 'lib/lp/soyuz/model/archivedependency.py'
--- lib/lp/soyuz/model/archivedependency.py 2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/model/archivedependency.py 2012-11-26 01:38:20 +0000
@@ -1,8 +1,6 @@
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-# pylint: disable-msg=E0611,W0212
-
"""Database class for ArchiveDependency."""
__metaclass__ = type
=== modified file 'lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt'
--- lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2012-01-15 11:06:57 +0000
+++ lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2012-11-26 01:38:20 +0000
@@ -406,6 +406,34 @@
(*) Use the same components used for each source in the Ubuntu
primary archive.
+If we set the primary dependency to just main, which can only be done via the
+API or the objects themselves, the form will show it to allow the user to
+change it.
+
+ >>> from zope.component import getUtility
+ >>> from lp.registry.interfaces.distribution import IDistributionSet
+ >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
+ >>> from lp.soyuz.interfaces.component import IComponentSet
+ >>> from lp.testing import login_celebrity
+ >>> ignored = login_celebrity('admin')
+ >>> archive = factory.makeArchive()
+ >>> main = getUtility(IComponentSet)['main']
+ >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu').main_archive
+ >>> ignored = archive.addArchiveDependency(
+ ... ubuntu, PackagePublishingPocket.RELEASE, component=main)
+ >>> url = canonical_url(archive)
+ >>> logout()
+ >>> admin_browser.open(url)
+ >>> admin_browser.getLink('Edit PPA dependencies').click()
+ >>> print_radio_button_field(
+ ... admin_browser.contents, 'primary_components')
+ ( ) Use all Ubuntu components available.
+ ( ) Use the same components used for each source in the Ubuntu
+ primary archive.
+ (*) Unsupported component (main)
+ >>> admin_browser.open('http://launchpad.dev/~cprov/+archive/ppa')
+ >>> admin_browser.getLink('Edit PPA dependencies').click()
+
== Everything in one click ==
Follow ups