Merge lp:~wgrant/launchpad/bug-1087225 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 16644
Proposed branch: lp:~wgrant/launchpad/bug-1087225
Merge into: lp:launchpad
Diff against target: 70 lines (+15/-9)
2 files modified
lib/lp/blueprints/stories/blueprints/xx-dependencies.txt (+1/-1)
lib/lp/blueprints/vocabularies/specificationdependency.py (+14/-8)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1087225
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+165543@code.launchpad.net

Commit message

Adjust SpecificationDependenciesVocabulary to use IDs rather than names as the unique key, since spec names are only unique within a pillar.

Description of the change

Adjust SpecificationDependenciesVocabulary to use IDs rather than names as the unique key, since spec names are only unique within a pillar.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
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/blueprints/stories/blueprints/xx-dependencies.txt'
2--- lib/lp/blueprints/stories/blueprints/xx-dependencies.txt 2012-12-10 13:43:47 +0000
3+++ lib/lp/blueprints/stories/blueprints/xx-dependencies.txt 2013-05-24 07:33:29 +0000
4@@ -97,7 +97,7 @@
5 expect to be redirected to the blueprint page.
6
7 >>> owner_browser.getControl(
8- ... 'Dependency').value = ['extension-manager-upgrades']
9+ ... 'Dependency').value = ['1']
10 >>> owner_browser.getControl('Continue').click()
11 >>> owner_browser.url
12 'http://blueprints.launchpad.dev/firefox/+spec/canvas'
13
14=== modified file 'lib/lp/blueprints/vocabularies/specificationdependency.py'
15--- lib/lp/blueprints/vocabularies/specificationdependency.py 2013-01-25 03:30:08 +0000
16+++ lib/lp/blueprints/vocabularies/specificationdependency.py 2013-05-24 07:33:29 +0000
17@@ -9,9 +9,8 @@
18 'SpecificationDependenciesVocabulary',
19 ]
20
21-from operator import attrgetter
22-
23 from storm.locals import (
24+ And,
25 SQL,
26 Store,
27 )
28@@ -23,6 +22,12 @@
29 recursive_blocked_query,
30 Specification,
31 )
32+from lp.blueprints.model.specificationdependency import (
33+ SpecificationDependency,
34+ )
35+from lp.blueprints.model.specificationsearch import (
36+ get_specification_privacy_filter,
37+ )
38 from lp.registry.interfaces.pillar import IPillarNameSet
39 from lp.services.database.stormexpr import fti_search
40 from lp.services.webapp import (
41@@ -33,7 +38,6 @@
42 from lp.services.webapp.vocabulary import (
43 CountableIterator,
44 IHugeVocabulary,
45- NamedSQLObjectVocabulary,
46 SQLObjectVocabularyBase,
47 )
48
49@@ -196,14 +200,16 @@
50 return self._is_valid_candidate(obj)
51
52
53-class SpecificationDependenciesVocabulary(NamedSQLObjectVocabulary):
54+class SpecificationDependenciesVocabulary(SQLObjectVocabularyBase):
55 """List specifications on which the current specification depends."""
56
57 _table = Specification
58 _orderBy = 'title'
59
60- def __iter__(self):
61+ @property
62+ def _filter(self):
63 user = getattr(getUtility(ILaunchBag), 'user', None)
64- for spec in sorted(
65- self.context.getDependencies(user), key=attrgetter('title')):
66- yield SimpleTerm(spec, spec.name, spec.title)
67+ return And(
68+ SpecificationDependency.specificationID == self.context.id,
69+ SpecificationDependency.dependencyID == Specification.id,
70+ *get_specification_privacy_filter(user))