Merge lp:~stevenk/launchpad/archive-edit-dependencies-oops into lp:launchpad

Proposed by Steve Kowalik on 2012-11-26
Status: Merged
Approved by: Steve Kowalik on 2012-11-26
Approved revision: no longer in the source branch.
Merged at revision: 16308
Proposed branch: lp:~stevenk/launchpad/archive-edit-dependencies-oops
Merge into: lp:launchpad
Diff against target: 84 lines (+35/-4)
3 files modified
lib/lp/soyuz/browser/archive.py (+7/-2)
lib/lp/soyuz/model/archivedependency.py (+0/-2)
lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt (+28/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/archive-edit-dependencies-oops
Reviewer Review Type Date Requested Status
William Grant code 2012-11-26 Approve on 2012-11-26
Review via email: mp+136075@code.launchpad.net

Commit Message

Teach Archive:+edit-dependencies about components other than multiverse. They are now added onto the components vocabulary if they're used.

Description of the Change

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.

I will claim this LoC against the stacks and stacks I have.

To post a comment you must log in.
William Grant (wgrant) wrote :

I'd add a comment to the new code.

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/soyuz/browser/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2012-11-13 09:36:41 +0000
3+++ lib/lp/soyuz/browser/archive.py 2012-11-26 02:10:26 +0000
4@@ -29,7 +29,6 @@
5 ]
6
7
8-from cgi import escape
9 from datetime import (
10 datetime,
11 timedelta,
12@@ -1705,7 +1704,8 @@
13 || FOLLOW_PRIMARY || None ||
14
15 When omitted in the form, this widget defaults to 'All ubuntu
16- components' option when rendered.
17+ components' option when rendered. Other components, such as 'main',
18+ or 'contrib' will be added to the list of options if they are used.
19 """
20 multiverse = getUtility(IComponentSet)['multiverse']
21
22@@ -1727,6 +1727,11 @@
23 default_value = primary_dependency.component
24
25 terms = [all_components, follow_primary]
26+ if default_value and default_value != multiverse:
27+ current_component = SimpleTerm(
28+ default_value, 'OTHER_COMPONENT',
29+ _('Unsupported component (%s)' % default_value.name))
30+ terms.append(current_component)
31 primary_components_vocabulary = SimpleVocabulary(terms)
32 current_term = primary_components_vocabulary.getTerm(default_value)
33
34
35=== modified file 'lib/lp/soyuz/model/archivedependency.py'
36--- lib/lp/soyuz/model/archivedependency.py 2011-12-30 06:14:56 +0000
37+++ lib/lp/soyuz/model/archivedependency.py 2012-11-26 02:10:26 +0000
38@@ -1,8 +1,6 @@
39 # Copyright 2009 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42-# pylint: disable-msg=E0611,W0212
43-
44 """Database class for ArchiveDependency."""
45
46 __metaclass__ = type
47
48=== modified file 'lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt'
49--- lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2012-01-15 11:06:57 +0000
50+++ lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2012-11-26 02:10:26 +0000
51@@ -406,6 +406,34 @@
52 (*) Use the same components used for each source in the Ubuntu
53 primary archive.
54
55+If we set the primary dependency to just main, which can only be done via the
56+API or the objects themselves, the form will show it to allow the user to
57+change it.
58+
59+ >>> from zope.component import getUtility
60+ >>> from lp.registry.interfaces.distribution import IDistributionSet
61+ >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
62+ >>> from lp.soyuz.interfaces.component import IComponentSet
63+ >>> from lp.testing import login_celebrity
64+ >>> ignored = login_celebrity('admin')
65+ >>> archive = factory.makeArchive()
66+ >>> main = getUtility(IComponentSet)['main']
67+ >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu').main_archive
68+ >>> ignored = archive.addArchiveDependency(
69+ ... ubuntu, PackagePublishingPocket.RELEASE, component=main)
70+ >>> url = canonical_url(archive)
71+ >>> logout()
72+ >>> admin_browser.open(url)
73+ >>> admin_browser.getLink('Edit PPA dependencies').click()
74+ >>> print_radio_button_field(
75+ ... admin_browser.contents, 'primary_components')
76+ ( ) Use all Ubuntu components available.
77+ ( ) Use the same components used for each source in the Ubuntu
78+ primary archive.
79+ (*) Unsupported component (main)
80+ >>> admin_browser.open('http://launchpad.dev/~cprov/+archive/ppa')
81+ >>> admin_browser.getLink('Edit PPA dependencies').click()
82+
83
84 == Everything in one click ==
85