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

Proposed by Richard Harding on 2012-10-10
Status: Merged
Approved by: Aaron Bentley on 2012-10-10
Approved revision: no longer in the source branch.
Merged at revision: 16131
Proposed branch: lp:~rharding/launchpad/bp_default_1062207
Merge into: lp:launchpad
Diff against target: 70 lines (+22/-2)
3 files modified
lib/lp/blueprints/browser/specification.py (+5/-2)
lib/lp/blueprints/browser/tests/test_specification.py (+16/-0)
lib/lp/registry/browser/product.py (+1/-0)
To merge this branch: bzr merge lp:~rharding/launchpad/bp_default_1062207
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2012-10-10 Approve on 2012-10-10
Review via email: mp+129001@code.launchpad.net

Commit Message

Add initial value date for the information_type and default to PUBLIC vs None

Description of the Change

= Summary =

The information type input widget was not getting a default value so when you
submitted the form you had an error that the field was not set.

This branch forces a default initial value.

== Implementation Notes ==

If there was no initial value from the context, the code set information type
to None. This caused the input to not have a set value on render. This changes
that None value to PUBLIC since it's the usual default.

It adds a test for all of the test cases extending the base that checks this
default value is set. It also overrides for the one test case where PUBLIC is
not a valid information type.

There's a drive by lint and setting of this default on the product
registration as well.

Note: I've filed bug #1065161 about the issue that the UX issues presented by
the choice edit widget that complicated this issue.

== Q/A ==

Per the bug, going to the +addspec page and submitting a new spec should work
without changing the information type field at all. It should get a default
value of PUBLIC.

== Tests ==

browser/tests/test_specification.py

To post a comment you must log in.
Richard Harding (rharding) wrote :

Per chat with Aaron in irc. We should be using the getDefaultSpecificationInformationType of the various pillars vs hard coding the default to being InformationType.PUBLIC.

Aaron Bentley (abentley) wrote :

At first, I thought that this would always set the value to PUBLIC, but it only does so if the context is not a Product, or the Product's default is PUBLIC. So this is a good change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/blueprints/browser/specification.py'
2--- lib/lp/blueprints/browser/specification.py 2012-09-28 19:59:35 +0000
3+++ lib/lp/blueprints/browser/specification.py 2012-10-11 12:38:28 +0000
4@@ -102,7 +102,10 @@
5 DateTimeFormatterAPI,
6 format_link,
7 )
8-from lp.app.enums import PUBLIC_PROPRIETARY_INFORMATION_TYPES
9+from lp.app.enums import (
10+ InformationType,
11+ PUBLIC_PROPRIETARY_INFORMATION_TYPES,
12+ )
13 from lp.app.utilities import json_dump_information_types
14 from lp.app.vocabularies import InformationTypeVocabulary
15 from lp.app.widgets.itemswidgets import LaunchpadRadioWidgetWithDescription
16@@ -309,7 +312,7 @@
17 @property
18 def initial_values(self):
19 """Set initial values to honor sharing policy default value."""
20- information_type = None
21+ information_type = InformationType.PUBLIC
22 if (IProduct.providedBy(self.context) or
23 IProductSeries.providedBy(self.context)):
24 information_type = (
25
26=== modified file 'lib/lp/blueprints/browser/tests/test_specification.py'
27--- lib/lp/blueprints/browser/tests/test_specification.py 2012-10-10 16:56:03 +0000
28+++ lib/lp/blueprints/browser/tests/test_specification.py 2012-10-11 12:38:28 +0000
29@@ -352,6 +352,14 @@
30 self.assertIsNot(None, info_data)
31 self.assertEqual(self.expected_keys, set(info_data.keys()))
32
33+ def test_default_info_type(self):
34+ # The default selected information type needs to be PUBLIC for new
35+ # specifications.
36+ view = self.createInitializedView()
37+ self.assertEqual(
38+ InformationType.PUBLIC,
39+ view.initial_values['information_type'])
40+
41
42 class TestNewSpecificationFromRootView(TestCaseWithFactory,
43 NewSpecificationTests):
44@@ -396,6 +404,14 @@
45 specification_sharing_policy=policy)
46 return create_initialized_view(product, '+addspec')
47
48+ def test_default_info_type(self):
49+ # In this case the default info type cannot be PUBlIC as it's not
50+ # among the allowed types.
51+ view = self.createInitializedView()
52+ self.assertEqual(
53+ InformationType.EMBARGOED,
54+ view.initial_values['information_type'])
55+
56
57 class TestNewSpecificationFromDistributionView(TestCaseWithFactory,
58 NewSpecificationTests):
59
60=== modified file 'lib/lp/registry/browser/product.py'
61--- lib/lp/registry/browser/product.py 2012-10-11 04:21:07 +0000
62+++ lib/lp/registry/browser/product.py 2012-10-11 12:38:28 +0000
63@@ -1962,6 +1962,7 @@
64 'driver': self.user.name,
65 'bug_supervisor': self.user.name,
66 'owner': self.user.name,
67+ 'information_type': InformationType.PUBLIC,
68 }
69
70 def setUpFields(self):