Merge lp:~cjohnston/launchpad/ppa-rtm-fixes into lp:launchpad

Proposed by Chris Johnston
Status: Rejected
Rejected by: William Grant
Proposed branch: lp:~cjohnston/launchpad/ppa-rtm-fixes
Merge into: lp:launchpad
Diff against target: 504 lines (+130/-57)
9 files modified
lib/lp/code/javascript/tests/test_requestbuild_overlay.html (+1/-1)
lib/lp/soyuz/browser/archive.py (+2/-3)
lib/lp/soyuz/browser/tests/archive-views.txt (+8/-8)
lib/lp/soyuz/doc/vocabularies.txt (+13/-13)
lib/lp/soyuz/model/archive.py (+7/-1)
lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt (+47/-10)
lib/lp/soyuz/tests/test_archive.py (+25/-1)
lib/lp/soyuz/tests/test_vocabularies.py (+1/-1)
lib/lp/soyuz/vocabularies.py (+26/-19)
To merge this branch: bzr merge lp:~cjohnston/launchpad/ppa-rtm-fixes
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+229777@code.launchpad.net
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/javascript/tests/test_requestbuild_overlay.html'
--- lib/lp/code/javascript/tests/test_requestbuild_overlay.html 2012-10-26 09:54:28 +0000
+++ lib/lp/code/javascript/tests/test_requestbuild_overlay.html 2014-08-29 01:29:58 +0000
@@ -73,7 +73,7 @@
73 <script type="text/x-template" id="requestbuilds-form-template">73 <script type="text/x-template" id="requestbuilds-form-template">
74 <div class="form" id="launchpad-form-widgets">74 <div class="form" id="launchpad-form-widgets">
75 <select id="field.archive" name="field.archive" size="1" >75 <select id="field.archive" name="field.archive" size="1" >
76 <option selected="selected" value="mark/ppa">76 <option selected="selected" value="~mark/ubuntu/ppa">
77 PPA for Mark Shuttleworth</option>77 PPA for Mark Shuttleworth</option>
78 </select>78 </select>
79 <input name="field.archive-empty-marker" type="hidden" value="1" />79 <input name="field.archive-empty-marker" type="hidden" value="1" />
8080
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2014-08-01 08:47:00 +0000
+++ lib/lp/soyuz/browser/archive.py 2014-08-29 01:29:58 +0000
@@ -1391,6 +1391,7 @@
1391 for archive in archives:1391 for archive in archives:
1392 label = '%s [%s]' % (archive.displayname, archive.reference)1392 label = '%s [%s]' % (archive.displayname, archive.reference)
1393 terms.append(SimpleTerm(archive, archive.reference, label))1393 terms.append(SimpleTerm(archive, archive.reference, label))
1394 terms.sort(key=lambda x: x.value.reference)
1394 return SimpleVocabulary(terms)1395 return SimpleVocabulary(terms)
13951396
13961397
@@ -1627,10 +1628,8 @@
1627 canonical_url(dependency), archive_dependency.title)1628 canonical_url(dependency), archive_dependency.title)
1628 else:1629 else:
1629 dependency_label = archive_dependency.title1630 dependency_label = archive_dependency.title
1630 dependency_token = '%s/%s' % (
1631 dependency.owner.name, dependency.name)
1632 term = SimpleTerm(1631 term = SimpleTerm(
1633 dependency, dependency_token, dependency_label)1632 dependency, dependency.reference, dependency_label)
1634 terms.append(term)1633 terms.append(term)
1635 return form.Fields(1634 return form.Fields(
1636 List(__name__='selected_dependencies',1635 List(__name__='selected_dependencies',
16371636
=== modified file 'lib/lp/soyuz/browser/tests/archive-views.txt'
--- lib/lp/soyuz/browser/tests/archive-views.txt 2014-07-24 09:37:03 +0000
+++ lib/lp/soyuz/browser/tests/archive-views.txt 2014-08-29 01:29:58 +0000
@@ -716,7 +716,7 @@
716716
717Let's emulate a dependency addition. Note that the form contains, a717Let's emulate a dependency addition. Note that the form contains, a
718empty 'selected_dependencies' (as it was rendered in the empty718empty 'selected_dependencies' (as it was rendered in the empty
719request) and 'dependency_candidate' contains a valid PPA owner name.719request) and 'dependency_candidate' contains a valid PPA name.
720Validation checks are documented in720Validation checks are documented in
721pagetests/ppa/xx-edit-dependencies.txt.721pagetests/ppa/xx-edit-dependencies.txt.
722722
@@ -724,7 +724,7 @@
724 ... cprov.archive, name="+edit-dependencies",724 ... cprov.archive, name="+edit-dependencies",
725 ... form={725 ... form={
726 ... 'field.selected_dependencies': [],726 ... 'field.selected_dependencies': [],
727 ... 'field.dependency_candidate': 'mark/ppa',727 ... 'field.dependency_candidate': '~mark/ubuntu/ppa',
728 ... 'field.primary_dependencies': 'UPDATES',728 ... 'field.primary_dependencies': 'UPDATES',
729 ... 'field.primary_components': 'ALL_COMPONENTS',729 ... 'field.primary_components': 'ALL_COMPONENTS',
730 ... 'field.actions.save': 'Save',730 ... 'field.actions.save': 'Save',
@@ -762,7 +762,7 @@
762 PPA for Mark Shuttleworth762 PPA for Mark Shuttleworth
763763
764 >>> print dependency.token764 >>> print dependency.token
765 mark/ppa765 ~mark/ubuntu/ppa
766766
767 >>> print dependency.title.escapedtext767 >>> print dependency.title.escapedtext
768 <a href="http://launchpad.dev/~mark/+archive/ubuntu/ppa">PPA for Mark768 <a href="http://launchpad.dev/~mark/+archive/ubuntu/ppa">PPA for Mark
@@ -794,7 +794,7 @@
794 PPA for Mark Shuttleworth794 PPA for Mark Shuttleworth
795795
796 >>> print dependency.token796 >>> print dependency.token
797 mark/ppa797 ~mark/ubuntu/ppa
798798
799 >>> print dependency.title799 >>> print dependency.title
800 PPA for Mark Shuttleworth800 PPA for Mark Shuttleworth
@@ -805,7 +805,7 @@
805 >>> view = create_initialized_view(805 >>> view = create_initialized_view(
806 ... cprov.archive, name="+edit-dependencies",806 ... cprov.archive, name="+edit-dependencies",
807 ... form={807 ... form={
808 ... 'field.selected_dependencies': ['mark/ppa'],808 ... 'field.selected_dependencies': ['~mark/ubuntu/ppa'],
809 ... 'field.dependency_candidate': '',809 ... 'field.dependency_candidate': '',
810 ... 'field.primary_dependencies': 'UPDATES',810 ... 'field.primary_dependencies': 'UPDATES',
811 ... 'field.primary_components': 'ALL_COMPONENTS',811 ... 'field.primary_components': 'ALL_COMPONENTS',
@@ -849,7 +849,7 @@
849 >>> view.widgets.get('primary_dependencies')._getCurrentValue()849 >>> view.widgets.get('primary_dependencies')._getCurrentValue()
850 <DBItem PackagePublishingPocket.UPDATES, (20) Updates>850 <DBItem PackagePublishingPocket.UPDATES, (20) Updates>
851851
852A similar widget is used for the primary archive component overrides ,852A similar widget is used for the primary archive component overrides,
853which contains two pre-defined options. By default all PPAs use all853which contains two pre-defined options. By default all PPAs use all
854ubuntu components available to satisfy build dependencies, i.e. the854ubuntu components available to satisfy build dependencies, i.e. the
855'multiverse' component.855'multiverse' component.
@@ -965,7 +965,7 @@
965 <DBItem PackagePublishingPocket.UPDATES, (20) Updates>965 <DBItem PackagePublishingPocket.UPDATES, (20) Updates>
966966
967Dependencies on private PPAs can be only set if the user performing967Dependencies on private PPAs can be only set if the user performing
968the action also have permission to view the private PPA and if the968the action also has permission to view the private PPA and if the
969context PPA is also private.969context PPA is also private.
970970
971The latter guarantee that the P3A buildd_secret won't get exposed in971The latter guarantee that the P3A buildd_secret won't get exposed in
@@ -988,7 +988,7 @@
988988
989 >>> add_private_form = {989 >>> add_private_form = {
990 ... 'field.selected_dependencies': [],990 ... 'field.selected_dependencies': [],
991 ... 'field.dependency_candidate': 'pirulito-team/ppa',991 ... 'field.dependency_candidate': '~pirulito-team/ubuntu/ppa',
992 ... 'field.primary_dependencies': 'UPDATES',992 ... 'field.primary_dependencies': 'UPDATES',
993 ... 'field.primary_components': 'FOLLOW_PRIMARY',993 ... 'field.primary_components': 'FOLLOW_PRIMARY',
994 ... 'field.actions.save': 'Save',994 ... 'field.actions.save': 'Save',
995995
=== modified file 'lib/lp/soyuz/doc/vocabularies.txt'
--- lib/lp/soyuz/doc/vocabularies.txt 2013-07-12 06:14:22 +0000
+++ lib/lp/soyuz/doc/vocabularies.txt 2014-08-29 01:29:58 +0000
@@ -189,13 +189,13 @@
189 * value: the IArchive object;189 * value: the IArchive object;
190 * title: the first line of the PPA description text.190 * title: the first line of the PPA description text.
191191
192 >>> cprov_term = vocabulary.getTermByToken('cprov/ppa')192 >>> cprov_term = vocabulary.getTermByToken('~cprov/ubuntu/ppa')
193193
194 >>> print cprov_term.token194 >>> print cprov_term.token
195 cprov/ppa195 ~cprov/ubuntu/ppa
196196
197 >>> print cprov_term.value197 >>> print cprov_term.value
198 <Archive ...>198 <... lp.soyuz.model.archive.Archive instance ...>
199199
200 >>> print cprov_term.title200 >>> print cprov_term.title
201 packages to help my friends.201 packages to help my friends.
@@ -216,15 +216,15 @@
216216
217 >>> cprov_search = vocabulary.search(u'cprov')217 >>> cprov_search = vocabulary.search(u'cprov')
218 >>> print_search_results(cprov_search)218 >>> print_search_results(cprov_search)
219 cprov/ppa: packages to help my friends.219 ~cprov/ubuntu/ppa: packages to help my friends.
220220
221 >>> celso_search = vocabulary.search(u'celso')221 >>> celso_search = vocabulary.search(u'celso')
222 >>> print_search_results(celso_search)222 >>> print_search_results(celso_search)
223 cprov/ppa: packages to help my friends.223 ~cprov/ubuntu/ppa: packages to help my friends.
224224
225 >>> friends_search = vocabulary.search(u'friends')225 >>> friends_search = vocabulary.search(u'friends')
226 >>> print_search_results(friends_search)226 >>> print_search_results(friends_search)
227 cprov/ppa: packages to help my friends.227 ~cprov/ubuntu/ppa: packages to help my friends.
228228
229We will create an additional PPA for Celso named 'testing'229We will create an additional PPA for Celso named 'testing'
230230
@@ -242,15 +242,15 @@
242242
243 >>> cprov_search = vocabulary.search(u'cprov')243 >>> cprov_search = vocabulary.search(u'cprov')
244 >>> print_search_results(cprov_search)244 >>> print_search_results(cprov_search)
245 cprov/ppa: packages to help my friends.245 ~cprov/ubuntu/ppa: packages to help my friends.
246 cprov/testing: testing packages.246 ~cprov/ubuntu/testing: testing packages.
247247
248The vocabulary search also supports specific named PPA lookups248The vocabulary search also supports specific named PPA lookups
249follwing the same combined syntax used to build unique tokens.249follwing the same combined syntax used to build unique tokens.
250250
251 >>> named_search = vocabulary.search(u'cprov/testing')251 >>> named_search = vocabulary.search(u'~cprov/ubuntu/testing')
252 >>> print_search_results(named_search)252 >>> print_search_results(named_search)
253 cprov/testing: testing packages.253 ~cprov/ubuntu/testing: testing packages.
254254
255As mentioned the PPA vocabulary term title only contains the first255As mentioned the PPA vocabulary term title only contains the first
256line of the PPA description.256line of the PPA description.
@@ -258,14 +258,14 @@
258 >>> cprov.archive.description = "Single line."258 >>> cprov.archive.description = "Single line."
259 >>> flush_database_updates()259 >>> flush_database_updates()
260260
261 >>> cprov_term = vocabulary.getTermByToken('cprov/ppa')261 >>> cprov_term = vocabulary.getTermByToken('~cprov/ubuntu/ppa')
262 >>> print cprov_term.title262 >>> print cprov_term.title
263 Single line.263 Single line.
264264
265 >>> cprov.archive.description = "First line\nSecond line."265 >>> cprov.archive.description = "First line\nSecond line."
266 >>> flush_database_updates()266 >>> flush_database_updates()
267267
268 >>> cprov_term = vocabulary.getTermByToken('cprov/ppa')268 >>> cprov_term = vocabulary.getTermByToken('~cprov/ubuntu/ppa')
269 >>> print cprov_term.title269 >>> print cprov_term.title
270 First line270 First line
271271
@@ -274,7 +274,7 @@
274 >>> cprov.archive.description = None274 >>> cprov.archive.description = None
275 >>> flush_database_updates()275 >>> flush_database_updates()
276276
277 >>> cprov_term = vocabulary.getTermByToken('cprov/ppa')277 >>> cprov_term = vocabulary.getTermByToken('~cprov/ubuntu/ppa')
278 >>> print cprov_term.title278 >>> print cprov_term.title
279 No description available279 No description available
280280
281281
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2014-08-14 10:08:28 +0000
+++ lib/lp/soyuz/model/archive.py 2014-08-29 01:29:58 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2013 Canonical Ltd. This software is licensed under the1# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Database class for table Archive."""4"""Database class for table Archive."""
@@ -1076,7 +1076,13 @@
1076 raise ArchiveDependencyError(1076 raise ArchiveDependencyError(
1077 "Non-primary archives only support the '%s' component." %1077 "Non-primary archives only support the '%s' component." %
1078 dependency.default_component.name)1078 dependency.default_component.name)
1079 if dependency.distribution != self.distribution:
1080 raise ArchiveDependencyError(
1081 "This dependency uses a different archive.")
10791082
1083 if not dependency.enabled:
1084 raise ArchiveDependencyError(
1085 "This dependency is not active.")
1080 return ArchiveDependency(1086 return ArchiveDependency(
1081 archive=self, dependency=dependency, pocket=pocket,1087 archive=self, dependency=dependency, pocket=pocket,
1082 component=component)1088 component=component)
10831089
=== modified file 'lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt'
--- lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2014-07-24 09:37:03 +0000
+++ lib/lp/soyuz/stories/ppa/xx-edit-dependencies.txt 2014-08-29 01:29:58 +0000
@@ -112,7 +112,7 @@
112is rendered on top of the page and the list of dependencies available112is rendered on top of the page and the list of dependencies available
113for removal is updated.113for removal is updated.
114114
115 >>> admin_browser.getControl("Add PPA dependency").value = 'mark/ppa'115 >>> admin_browser.getControl("Add PPA dependency").value = '~mark/ubuntu/ppa'
116 >>> admin_browser.getControl("Save").click()116 >>> admin_browser.getControl("Save").click()
117 >>> print_feedback_messages(admin_browser.contents)117 >>> print_feedback_messages(admin_browser.contents)
118 Dependency added: PPA for Mark Shuttleworth118 Dependency added: PPA for Mark Shuttleworth
@@ -123,7 +123,7 @@
123123
124Trying to add a dependency that is already recorded results in a error.124Trying to add a dependency that is already recorded results in a error.
125125
126 >>> admin_browser.getControl("Add PPA dependency").value = 'mark/ppa'126 >>> admin_browser.getControl("Add PPA dependency").value = '~mark/ubuntu/ppa'
127 >>> admin_browser.getControl("Save").click()127 >>> admin_browser.getControl("Save").click()
128 >>> print_feedback_messages(admin_browser.contents)128 >>> print_feedback_messages(admin_browser.contents)
129 There is 1 error.129 There is 1 error.
@@ -132,7 +132,7 @@
132Trying to add a dependency for the context PPA itself also results in132Trying to add a dependency for the context PPA itself also results in
133a error.133a error.
134134
135 >>> admin_browser.getControl("Add PPA dependency").value = 'cprov/ppa'135 >>> admin_browser.getControl("Add PPA dependency").value = '~cprov/ubuntu/ppa'
136 >>> admin_browser.getControl("Save").click()136 >>> admin_browser.getControl("Save").click()
137 >>> print_feedback_messages(admin_browser.contents)137 >>> print_feedback_messages(admin_browser.contents)
138 There is 1 error.138 There is 1 error.
@@ -140,7 +140,7 @@
140140
141If it's a new dependency everything is fine.141If it's a new dependency everything is fine.
142142
143 >>> admin_browser.getControl("Add PPA dependency").value = 'no-priv/ppa'143 >>> admin_browser.getControl("Add PPA dependency").value = '~no-priv/ubuntu/ppa'
144 >>> admin_browser.getControl("Save").click()144 >>> admin_browser.getControl("Save").click()
145 >>> print_feedback_messages(admin_browser.contents)145 >>> print_feedback_messages(admin_browser.contents)
146 Dependency added: PPA for No Privileges Person146 Dependency added: PPA for No Privileges Person
@@ -234,7 +234,7 @@
234234
235 >>> admin_browser.getControl(235 >>> admin_browser.getControl(
236 ... name="field.selected_dependencies").value = [236 ... name="field.selected_dependencies").value = [
237 ... 'mark/ppa', 'no-priv/ppa']237 ... '~mark/ubuntu/ppa', '~no-priv/ubuntu/ppa']
238 >>> admin_browser.getControl("Save").click()238 >>> admin_browser.getControl("Save").click()
239 >>> print_feedback_messages(admin_browser.contents)239 >>> print_feedback_messages(admin_browser.contents)
240 Dependencies removed:240 Dependencies removed:
@@ -258,6 +258,43 @@
258 ... user_browser.contents, 'archive-dependencies')258 ... user_browser.contents, 'archive-dependencies')
259 None259 None
260260
261We should also make sure that a user is unable to add a disabled PPA as a
262dependency.
263
264 # Disable Mark's PPA.
265 >>> login('foo.bar@canonical.com')
266 >>> from zope.component import getUtility
267 >>> from lp.registry.interfaces.person import IPersonSet
268 >>> mark = getUtility(IPersonSet).getByName('mark')
269 >>> mark.archive.disable()
270 >>> logout()
271
272 # Attempt to add Mark's PPA
273 >>> admin_browser.getControl("Add PPA dependency").value = '~mark/ubuntu/ppa'
274 >>> admin_browser.getControl("Save").click()
275 >>> print_feedback_messages(admin_browser.contents)
276 There is 1 error.
277 Invalid value
278
279 # When the page is reloaded, there shouldn't be any dependencies.
280 >>> admin_browser.reload()
281 >>> print_ppa_dependencies(admin_browser.contents)
282 No dependencies recorded for this PPA yet.
283
284Re-enable Mark's PPA for subsequent tests.
285
286 >>> login('foo.bar@canonical.com')
287 >>> mark.archive.enable()
288 >>> logout()
289
290Clear the page.
291
292 >>> admin_browser.getControl("Add PPA dependency").value = ''
293 >>> admin_browser.getControl("Save").click()
294 >>> admin_browser.reload()
295 >>> print_ppa_dependencies(admin_browser.contents)
296 No dependencies recorded for this PPA yet.
297
261== Primary dependencies ==298== Primary dependencies ==
262299
263A user can modify how a PPA depends on its corresponding300A user can modify how a PPA depends on its corresponding
@@ -420,7 +457,7 @@
420457
421First we will create a PPA dependency for No privileged' PPA.458First we will create a PPA dependency for No privileged' PPA.
422459
423 >>> admin_browser.getControl("Add PPA dependency").value = 'no-priv/ppa'460 >>> admin_browser.getControl("Add PPA dependency").value = '~no-priv/ubuntu/ppa'
424 >>> admin_browser.getControl("Save").click()461 >>> admin_browser.getControl("Save").click()
425 >>> print_feedback_messages(admin_browser.contents)462 >>> print_feedback_messages(admin_browser.contents)
426 Dependency added: PPA for No Privileges Person463 Dependency added: PPA for No Privileges Person
@@ -450,12 +487,12 @@
450RELEASE.487RELEASE.
451488
452 >>> admin_browser.getControl(489 >>> admin_browser.getControl(
453 ... name="field.selected_dependencies").value = ['no-priv/ppa']490 ... name="field.selected_dependencies").value = ['~no-priv/ubuntu/ppa']
454491
455 >>> admin_browser.getControl(492 >>> admin_browser.getControl(
456 ... "Use all Ubuntu components available.").selected = True493 ... "Use all Ubuntu components available.").selected = True
457494
458 >>> admin_browser.getControl("Add PPA dependency").value = 'mark/ppa'495 >>> admin_browser.getControl("Add PPA dependency").value = '~mark/ubuntu/ppa'
459496
460 >>> admin_browser.getControl(497 >>> admin_browser.getControl(
461 ... "Basic (only released packages).").selected = True498 ... "Basic (only released packages).").selected = True
@@ -513,9 +550,9 @@
513550
514 >>> admin_browser.getLink('Edit PPA dependencies').click()551 >>> admin_browser.getLink('Edit PPA dependencies').click()
515552
516 >>> admin_browser.getControl("Add PPA dependency").value = 'no-priv/ppa'553 >>> admin_browser.getControl("Add PPA dependency").value = '~no-priv/ubuntu/ppa'
517 >>> admin_browser.getControl(554 >>> admin_browser.getControl(
518 ... name="field.selected_dependencies").value = ['mark/ppa']555 ... name="field.selected_dependencies").value = ['~mark/ubuntu/ppa']
519 >>> admin_browser.getControl(556 >>> admin_browser.getControl(
520 ... "Default (security dependencies and recommended updates)."557 ... "Default (security dependencies and recommended updates)."
521 ... ).selected = True558 ... ).selected = True
522559
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2014-08-07 07:53:27 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2014-08-29 01:29:58 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2013 Canonical Ltd. This software is licensed under the1# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test Archive features."""4"""Test Archive features."""
@@ -1415,6 +1415,30 @@
1415 PackagePublishingPocket.RELEASE)1415 PackagePublishingPocket.RELEASE)
1416 self.assertContentEqual(archive.dependencies, [archive_dependency])1416 self.assertContentEqual(archive.dependencies, [archive_dependency])
14171417
1418 def test_dependency_has_different_distribution(self):
1419 # A public archive may not depend on a private archive.
1420 archive = self.factory.makeArchive()
1421 distro = self.factory.makeDistribution()
1422 dependency = self.factory.makeArchive(
1423 distribution=distro, owner=archive.owner)
1424 with person_logged_in(archive.owner):
1425 with ExpectedException(
1426 ArchiveDependencyError,
1427 "This dependency uses a different archive."):
1428 archive.addArchiveDependency(
1429 dependency, PackagePublishingPocket.RELEASE)
1430
1431 def test_dependency_is_disabled(self):
1432 # A public archive may not depend on a private archive.
1433 archive = self.factory.makeArchive()
1434 dependency = self.factory.makeArchive(
1435 owner=archive.owner, enabled=False)
1436 with person_logged_in(archive.owner):
1437 with ExpectedException(
1438 ArchiveDependencyError,
1439 "This dependency is not active."):
1440 archive.addArchiveDependency(
1441 dependency, PackagePublishingPocket.RELEASE)
14181442
1419class TestArchiveDependencies(TestCaseWithFactory):1443class TestArchiveDependencies(TestCaseWithFactory):
14201444
14211445
=== modified file 'lib/lp/soyuz/tests/test_vocabularies.py'
--- lib/lp/soyuz/tests/test_vocabularies.py 2014-06-11 08:29:40 +0000
+++ lib/lp/soyuz/tests/test_vocabularies.py 2014-08-29 01:29:58 +0000
@@ -22,5 +22,5 @@
22 term = vocab.toTerm(archive)22 term = vocab.toTerm(archive)
23 self.assertThat(term, MatchesStructure.byEquality(23 self.assertThat(term, MatchesStructure.byEquality(
24 value=archive,24 value=archive,
25 token='%s/%s' % (archive.owner.name, archive.name),25 token=archive.reference,
26 title='No description available'))26 title='No description available'))
2727
=== modified file 'lib/lp/soyuz/vocabularies.py'
--- lib/lp/soyuz/vocabularies.py 2013-09-10 06:28:26 +0000
+++ lib/lp/soyuz/vocabularies.py 2014-08-29 01:29:58 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2013 Canonical Ltd. This software is licensed under the GNU1# Copyright 2009-2014 Canonical Ltd. This software is licensed under the GNU
2# Affero General Public License version 3 (see the file LICENSE).2# Affero General Public License version 3 (see the file LICENSE).
33
4"""Soyuz vocabularies."""4"""Soyuz vocabularies."""
@@ -20,6 +20,7 @@
20from zope.component import getUtility20from zope.component import getUtility
21from zope.interface import implements21from zope.interface import implements
22from zope.schema.vocabulary import SimpleTerm22from zope.schema.vocabulary import SimpleTerm
23from zope.security.interfaces import Unauthorized
2324
24from lp.registry.model.distroseries import DistroSeries25from lp.registry.model.distroseries import DistroSeries
25from lp.registry.model.person import Person26from lp.registry.model.person import Person
@@ -32,6 +33,7 @@
32 SQLObjectVocabularyBase,33 SQLObjectVocabularyBase,
33 )34 )
34from lp.soyuz.enums import ArchivePurpose35from lp.soyuz.enums import ArchivePurpose
36from lp.soyuz.interfaces.archive import IArchiveSet
35from lp.soyuz.model.archive import Archive37from lp.soyuz.model.archive import Archive
36from lp.soyuz.model.component import Component38from lp.soyuz.model.component import Component
37from lp.soyuz.model.distroarchseries import DistroArchSeries39from lp.soyuz.model.distroarchseries import DistroArchSeries
@@ -88,6 +90,7 @@
88 _orderBy = ['Person.name, Archive.name']90 _orderBy = ['Person.name, Archive.name']
89 _clauseTables = ['Person']91 _clauseTables = ['Person']
90 _filter = And(92 _filter = And(
93 Archive._enabled == True,
91 Person.q.id == Archive.q.ownerID,94 Person.q.id == Archive.q.ownerID,
92 Archive.q.purpose == ArchivePurpose.PPA)95 Archive.q.purpose == ArchivePurpose.PPA)
93 displayname = 'Select a PPA'96 displayname = 'Select a PPA'
@@ -95,35 +98,33 @@
9598
96 def toTerm(self, archive):99 def toTerm(self, archive):
97 """See `IVocabulary`."""100 """See `IVocabulary`."""
98 description = archive.description101 try:
99 if description:102 description = archive.description
100 summary = description.splitlines()[0]103 if description:
101 else:104 summary = description.splitlines()[0]
102 summary = "No description available"105 else:
106 summary = "No description available"
107 except Unauthorized:
108 summary = None
103109
104 token = '%s/%s' % (archive.owner.name, archive.name)110 token = archive.reference
105111
106 return SimpleTerm(archive, token, summary)112 return SimpleTerm(archive, token, summary)
107113
108 def getTermByToken(self, token):114 def getTermByToken(self, token):
109 """See `IVocabularyTokenized`."""115 """See `IVocabularyTokenized`."""
110 try:116 try:
111 owner_name, archive_name = token.split('/')117 owner_name, distro_name, archive_name = token.split('/')
112 except ValueError:118 except ValueError:
113 raise LookupError(token)119 raise LookupError(token)
114120
115 clause = And(121 obj = getUtility(IArchiveSet).getByReference(token)
116 self._filter,
117 Person.name == owner_name,
118 Archive.name == archive_name)
119
120 obj = self._table.selectOne(
121 clause, clauseTables=self._clauseTables)
122
123 if obj is None:122 if obj is None:
124 raise LookupError(token)123 return LookupError(token)
125 else:124 elif obj.enabled:
126 return self.toTerm(obj)125 return self.toTerm(obj)
126 else:
127 raise LookupError(token)
127128
128 def search(self, query, vocab_filter=None):129 def search(self, query, vocab_filter=None):
129 """Return a resultset of archives.130 """Return a resultset of archives.
@@ -135,8 +136,14 @@
135136
136 query = query.lower()137 query = query.lower()
137138
139 if query.startswith('~'):
140 query = query.strip('~')
138 try:141 try:
139 owner_name, archive_name = query.split('/')142 query_split = query.split('/')
143 if len(query_split) == 3:
144 owner_name, distro_name, archive_name = query_split
145 else:
146 owner_name, archive_name = query_split
140 except ValueError:147 except ValueError:
141 clause = And(148 clause = And(
142 self._filter,149 self._filter,