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

Proposed by Richard Harding on 2012-10-25
Status: Merged
Approved by: j.c.sackett on 2012-10-25
Approved revision: no longer in the source branch.
Merged at revision: 16197
Proposed branch: lp:~rharding/launchpad/limit_product_types_1066904
Merge into: lp:launchpad
Diff against target: 61 lines (+24/-2)
2 files modified
lib/lp/registry/browser/product.py (+11/-2)
lib/lp/registry/browser/tests/test_product.py (+13/-0)
To merge this branch: bzr merge lp:~rharding/launchpad/limit_product_types_1066904
Reviewer Review Type Date Requested Status
j.c.sackett (community) 2012-10-25 Approve on 2012-10-25
Review via email: mp+131368@code.launchpad.net

Commit Message

Limit the information type widget vocabulary on project modifications.

Description of the Change

= Summary =

The vocabulary of the information type isn't currently limited to the only
allowed information types.

This forces the information type to only be rendered as the three permitted.

== Implementation Notes ==

This just alters the widget to have a different set of vocabulary and adds a
test to make sure it's limited.

== Tests ==

registry/browser/test_product.py

To post a comment you must log in.
j.c.sackett (jcsackett) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/product.py'
2--- lib/lp/registry/browser/product.py 2012-10-25 09:03:19 +0000
3+++ lib/lp/registry/browser/product.py 2012-10-25 14:33:19 +0000
4@@ -111,6 +111,7 @@
5 from lp.app.interfaces.headings import IEditableContextTitle
6 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
7 from lp.app.utilities import json_dump_information_types
8+from lp.app.vocabularies import InformationTypeVocabulary
9 from lp.app.widgets.date import DateWidget
10 from lp.app.widgets.itemswidgets import (
11 CheckBoxMatrixWidget,
12@@ -1392,7 +1393,11 @@
13 ]
14 custom_widget('licenses', LicenseWidget)
15 custom_widget('license_info', GhostWidget)
16- custom_widget('information_type', LaunchpadRadioWidgetWithDescription)
17+ custom_widget(
18+ 'information_type',
19+ LaunchpadRadioWidgetWithDescription,
20+ vocabulary=InformationTypeVocabulary(
21+ types=PUBLIC_PROPRIETARY_INFORMATION_TYPES))
22
23 @property
24 def next_url(self):
25@@ -1917,7 +1922,11 @@
26 custom_widget('homepageurl', TextWidget, displayWidth=30)
27 custom_widget('licenses', LicenseWidget)
28 custom_widget('license_info', GhostWidget)
29- custom_widget('information_type', LaunchpadRadioWidgetWithDescription)
30+ custom_widget(
31+ 'information_type',
32+ LaunchpadRadioWidgetWithDescription,
33+ vocabulary=InformationTypeVocabulary(
34+ types=PUBLIC_PROPRIETARY_INFORMATION_TYPES))
35
36 custom_widget(
37 'owner', PersonPickerWidget, header="Select the maintainer",
38
39=== modified file 'lib/lp/registry/browser/tests/test_product.py'
40--- lib/lp/registry/browser/tests/test_product.py 2012-10-25 09:03:19 +0000
41+++ lib/lp/registry/browser/tests/test_product.py 2012-10-25 14:33:19 +0000
42@@ -487,6 +487,19 @@
43 'field.license_info': license_info,
44 }
45
46+ def test_limited_information_types_allowed(self):
47+ """Products can only be PUBLIC_PROPRIETARY_INFORMATION_TYPES"""
48+ product = self.factory.makeProduct()
49+ with FeatureFixture({u'disclosure.private_projects.enabled': u'on'}):
50+ login_person(product.owner)
51+ view = create_initialized_view(
52+ product,
53+ '+edit',
54+ principal=product.owner)
55+ info_types = [t.name for t in view.widgets['information_type'].vocabulary]
56+ expected = ['PUBLIC', 'PROPRIETARY', 'EMBARGOED']
57+ self.assertEqual(expected, info_types)
58+
59 def test_change_information_type_proprietary(self):
60 product = self.factory.makeProduct(name='fnord')
61 with FeatureFixture({u'disclosure.private_projects.enabled': u'on'}):