Merge lp:~rharding/launchpad/changing_maintainer_1077841 into lp:launchpad

Proposed by Richard Harding on 2012-12-04
Status: Merged
Approved by: Richard Harding on 2012-12-04
Approved revision: no longer in the source branch.
Merged at revision: 16341
Proposed branch: lp:~rharding/launchpad/changing_maintainer_1077841
Merge into: lp:launchpad
Diff against target: 102 lines (+12/-8)
6 files modified
lib/lp/app/templates/inline-picker.pt (+1/-1)
lib/lp/registry/configure.zcml (+1/-2)
lib/lp/registry/interfaces/product.py (+7/-1)
lib/lp/registry/model/product.py (+0/-4)
lib/lp/registry/stories/webservice/xx-project-registry.txt (+1/-0)
lib/lp/registry/tests/test_product.py (+2/-0)
To merge this branch: bzr merge lp:~rharding/launchpad/changing_maintainer_1077841
Reviewer Review Type Date Requested Status
Abel Deuring (community) code 2012-12-04 Approve on 2012-12-04
Review via email: mp+137849@code.launchpad.net

Commit Message

Add private property to Product so that it has LP.cache.context.private for the JS pickers to determine context.

Description of the Change

= Summary =

The bug is that the JavaScript in the picker is throwing an invalid message to
the user when they change the maintainer of a project. In looking, this is
because that JavaScript it determine if things are private by looking at
LP.cache.context.private, which project isn't implementing.

== Pre Implementation ==

Talked with Abel some during implementation to debug .zcml work.

== Implementation Notes ==

The trick here is in the IProduct interface through IInformationType and from
IPrivacy. However, it's not exported so it doesn't get dumped with the rest of
the Product data into LP.cache.context when you're on the product home screen.

To fix this, I added the property to the IProductPublic interface and removed
the IInformationType from the zcml. I then had to allow the attribute
IInformationType was supplying. This basically hid away the private from
IPrivacy, but exposed my updated one in IProjectPublic.

The private method on the Product model is just a simple check against
PRIVATE_INFORMATION_TYPES.

== Tests ==

For testing, I just updated the existing information type tests to not only
verify it gets the right information type, but that the private property is
correct.

The JavaScript is correct as long as the context is correct so there aren't
any changes actually required in there.

To post a comment you must log in.
Abel Deuring (adeuring) :
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/app/templates/inline-picker.pt'
2--- lib/lp/app/templates/inline-picker.pt 2012-06-15 16:23:50 +0000
3+++ lib/lp/app/templates/inline-picker.pt 2012-12-05 11:58:24 +0000
4@@ -23,7 +23,7 @@
5 <script tal:condition="view/can_write"
6 tal:content="structure string:
7 LPJS.use('lp.app.picker', 'lp.client', function(Y) {
8- var picker_config = ${view/json_config}
9+ var picker_config = ${view/json_config};
10 picker_config.validate_callback = Y.lp.app.picker.public_private_warning;
11 Y.on('load', function(e) {
12 Y.lp.app.picker.addPickerPatcher(
13
14=== modified file 'lib/lp/registry/configure.zcml'
15--- lib/lp/registry/configure.zcml 2012-12-04 13:52:02 +0000
16+++ lib/lp/registry/configure.zcml 2012-12-05 11:58:24 +0000
17@@ -1272,11 +1272,10 @@
18 <require
19 permission="launchpad.Edit"
20 interface="lp.registry.interfaces.product.IProductEditRestricted"/>
21- <allow
22- interface="lp.app.interfaces.informationtype.IInformationType"/>
23 <require
24 permission="launchpad.Edit"
25 set_schema="lp.app.interfaces.informationtype.IInformationType"/>
26+ <allow attributes="information_type" />
27 <require
28 permission="launchpad.Edit"
29 set_attributes="answers_usage blueprints_usage codehosting_usage
30
31=== modified file 'lib/lp/registry/interfaces/product.py'
32--- lib/lp/registry/interfaces/product.py 2012-11-26 21:01:54 +0000
33+++ lib/lp/registry/interfaces/product.py 2012-12-05 11:58:24 +0000
34@@ -427,6 +427,13 @@
35 def userCanView(user):
36 """True if the given user has access to this product."""
37
38+ private = exported(
39+ Bool(
40+ title=_("Product is confidential"), required=False,
41+ readonly=True, default=False,
42+ description=_(
43+ "This product is visible only to those with access grants.")))
44+
45
46 class IProductLimitedView(IHasIcon, IHasLogo, IHasOwner, ILaunchpadUsage):
47 """Attributes that must be visible for person with artifact grants
48@@ -476,7 +483,6 @@
49 description=_("The restricted team, moderated team, or person "
50 "who maintains the project information in "
51 "Launchpad.")))
52-
53 project = exported(
54 ReferenceChoice(
55 title=_('Part of'),
56
57=== modified file 'lib/lp/registry/model/product.py'
58--- lib/lp/registry/model/product.py 2012-12-01 00:59:46 +0000
59+++ lib/lp/registry/model/product.py 2012-12-05 11:58:24 +0000
60@@ -1807,10 +1807,6 @@
61 def people(self):
62 return getUtility(IPersonSet)
63
64- @property
65- def private(self):
66- return self.information_type in PRIVATE_INFORMATION_TYPES
67-
68 @classmethod
69 def latest(cls, user, quantity=5):
70 """See `IProductSet`."""
71
72=== modified file 'lib/lp/registry/stories/webservice/xx-project-registry.txt'
73--- lib/lp/registry/stories/webservice/xx-project-registry.txt 2012-10-12 14:53:10 +0000
74+++ lib/lp/registry/stories/webservice/xx-project-registry.txt 2012-12-05 11:58:24 +0000
75@@ -177,6 +177,7 @@
76 name: u'firefox'
77 official_bug_tags: []
78 owner_link: u'http://.../~name12'
79+ private: False
80 private_bugs: False
81 programming_language: None
82 project_group_link: u'http://.../mozilla'
83
84=== modified file 'lib/lp/registry/tests/test_product.py'
85--- lib/lp/registry/tests/test_product.py 2012-11-29 17:12:20 +0000
86+++ lib/lp/registry/tests/test_product.py 2012-12-05 11:58:24 +0000
87@@ -633,6 +633,7 @@
88 store.reset()
89 product = store.get(Product, product.id)
90 self.assertEqual(InformationType.PROPRIETARY, product.information_type)
91+ self.assertTrue(product.private)
92
93 def test_product_information_type_default(self):
94 # Default information_type is PUBLIC
95@@ -640,6 +641,7 @@
96 product = getUtility(IProductSet).createProduct(
97 owner, 'fnord', 'Fnord', 'Fnord', 'test 1', 'test 2')
98 self.assertEqual(InformationType.PUBLIC, product.information_type)
99+ self.assertFalse(product.private)
100
101 invalid_information_types = [info_type for info_type in
102 InformationType.items if info_type not in