Merge lp:~wgrant/launchpad/rework-bug-default-type-0 into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 15724
Proposed branch: lp:~wgrant/launchpad/rework-bug-default-type-0
Merge into: lp:launchpad
Diff against target: 161 lines (+32/-30)
6 files modified
lib/lp/bugs/browser/bugtarget.py (+7/-12)
lib/lp/bugs/interfaces/bug.py (+4/-4)
lib/lp/bugs/mail/commands.py (+12/-7)
lib/lp/bugs/model/bug.py (+4/-2)
lib/lp/bugs/xmlrpc/bug.py (+1/-1)
lib/lp/testing/factory.py (+4/-4)
To merge this branch: bzr merge lp:~wgrant/launchpad/rework-bug-default-type-0
Reviewer Review Type Date Requested Status
Richard Harding (community) Approve
Review via email: mp+117378@code.launchpad.net

Commit message

Fix bug creation defaults pretty much everywhere to not be InformationType.PUBLIC, but None. createBug replaces None with the context's default.

Description of the change

This branch is the first in a series of maybe four to rework bug information type defaults, which will eventually allow us to default to Proprietary when a project is so configured.

The web, mail, and XML-RPC interfaces each had their own special variety of manually overriding information types when creating bugs. And they all tended to set it to PUBLIC when the overrides didn't apply, rather than leaving it for the core createBug API to figure out what it should be. This led to createBug containing this wonderful piece of logic:

         if params.product and params.product.private_bugs:
             # If the private_bugs flag is set on a product, then
             # force the new bug report to be private.
             if params.information_type == InformationType.PUBLIC:
                 params.information_type = InformationType.USERDATA

"You wanted it public? Ha, I know better! Even if you are the bug supervisor and explicitly selected Public."

I've changed default through most of the code to None. createBug understands None to mean that the target's default should be used -- currently Private if private_bugs is set and Public otherwise, but soon to be a little more complex than that. View code that wants to override it in some circumstances (eg. because apport has asked for something to be private, or the user has selected the "This bug is a security vulnerability" checkbox) sets it explicitly, but otherwise leaves it None.

FileBugViewBase is still a little messy, but rework-bug-default-type-2 sorts that out.

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtarget.py'
2--- lib/lp/bugs/browser/bugtarget.py 2012-07-26 07:55:19 +0000
3+++ lib/lp/bugs/browser/bugtarget.py 2012-07-31 06:32:19 +0000
4@@ -636,12 +636,15 @@
5 title = data["title"]
6 comment = data["comment"].rstrip()
7 packagename = data.get("packagename")
8- information_type = data.get(
9- "information_type", InformationType.PUBLIC)
10- security_related = data.get("security_related", False)
11 distribution = data.get(
12 "distribution", getUtility(ILaunchBag).distribution)
13
14+ information_type = data.get("information_type")
15+ # If the old UI is enabled, security bugs are always embargoed
16+ # when filed, but can be disclosed after they've been reported.
17+ if information_type is None and data.get("security_related"):
18+ information_type = InformationType.PRIVATESECURITY
19+
20 context = self.context
21 if distribution is not None:
22 # We're being called from the generic bug filing form, so
23@@ -657,14 +660,6 @@
24 if self.request.form.get("packagename_option") == "none":
25 packagename = None
26
27- if not self.is_bug_supervisor:
28- # If the old UI is enabled, security bugs are always embargoed
29- # when filed, but can be disclosed after they've been reported.
30- if security_related:
31- information_type = InformationType.PRIVATESECURITY
32- else:
33- information_type = InformationType.PUBLIC
34-
35 linkified_ack = structured(FormattersAPI(
36 self.getAcknowledgementMessage(self.context)).text_to_html(
37 last_paragraph_class="last"))
38@@ -701,7 +696,7 @@
39 'Additional information was added to the bug description.')
40
41 if not self.is_bug_supervisor and extra_data.private:
42- if params.information_type == InformationType.PUBLIC:
43+ if params.information_type in (None, InformationType.PUBLIC):
44 params.information_type = InformationType.USERDATA
45
46 # Apply any extra options given by privileged users.
47
48=== modified file 'lib/lp/bugs/interfaces/bug.py'
49--- lib/lp/bugs/interfaces/bug.py 2012-07-30 00:05:44 +0000
50+++ lib/lp/bugs/interfaces/bug.py 2012-07-31 06:32:19 +0000
51@@ -101,9 +101,9 @@
52
53 def __init__(self, owner, title, comment=None, description=None,
54 msg=None, status=None, datecreated=None,
55- information_type=InformationType.PUBLIC, subscribers=(),
56- tags=None, subscribe_owner=True, filed_by=None,
57- importance=None, milestone=None, assignee=None, cve=None):
58+ information_type=None, subscribers=(), tags=None,
59+ subscribe_owner=True, filed_by=None, importance=None,
60+ milestone=None, assignee=None, cve=None):
61 self.owner = owner
62 self.title = title
63 self.comment = comment
64@@ -213,7 +213,7 @@
65 information_type = exported(
66 Choice(
67 title=_('Information Type'), vocabulary=InformationType,
68- required=True, readonly=True, default=InformationType.PUBLIC,
69+ required=True, readonly=True,
70 description=_(
71 'The type of information contained in this bug report.')))
72
73
74=== modified file 'lib/lp/bugs/mail/commands.py'
75--- lib/lp/bugs/mail/commands.py 2012-07-17 06:34:59 +0000
76+++ lib/lp/bugs/mail/commands.py 2012-07-31 06:32:19 +0000
77@@ -46,7 +46,10 @@
78 IllegalTarget,
79 )
80 from lp.bugs.interfaces.cve import ICveSet
81-from lp.registry.enums import InformationType
82+from lp.registry.enums import (
83+ InformationType,
84+ PUBLIC_INFORMATION_TYPES,
85+ )
86 from lp.registry.interfaces.distribution import IDistribution
87 from lp.registry.interfaces.distributionsourcepackage import (
88 IDistributionSourcePackage,
89@@ -185,12 +188,14 @@
90 stop_processing=True)
91
92 if isinstance(context, CreateBugParams):
93- if private and (
94- context.information_type == InformationType.PUBLIC):
95- context.information_type = InformationType.USERDATA
96- elif (
97- context.information_type !=
98- InformationType.PRIVATESECURITY):
99+ if private:
100+ # "private yes" forces it to Private if it isn't already.
101+ if (context.information_type is None
102+ or context.information_type in PUBLIC_INFORMATION_TYPES):
103+ context.information_type = InformationType.USERDATA
104+ elif context.information_type != InformationType.PRIVATESECURITY:
105+ # "private no" forces it to Public, except we always
106+ # force new security bugs to be private.
107 context.information_type = InformationType.PUBLIC
108 return context, current_event
109
110
111=== modified file 'lib/lp/bugs/model/bug.py'
112--- lib/lp/bugs/model/bug.py 2012-07-30 00:05:44 +0000
113+++ lib/lp/bugs/model/bug.py 2012-07-31 06:32:19 +0000
114@@ -2645,11 +2645,13 @@
115 # of its attribute values below.
116 params = snapshot_bug_params(bug_params)
117
118- if params.product and params.product.private_bugs:
119+ if params.information_type is None:
120 # If the private_bugs flag is set on a product, then
121 # force the new bug report to be private.
122- if params.information_type == InformationType.PUBLIC:
123+ if params.product and params.product.private_bugs:
124 params.information_type = InformationType.USERDATA
125+ else:
126+ params.information_type = InformationType.PUBLIC
127
128 bug, event = self._makeBug(params)
129
130
131=== modified file 'lib/lp/bugs/xmlrpc/bug.py'
132--- lib/lp/bugs/xmlrpc/bug.py 2012-07-17 06:34:59 +0000
133+++ lib/lp/bugs/xmlrpc/bug.py 2012-07-31 06:32:19 +0000
134@@ -107,7 +107,7 @@
135 if security_related:
136 information_type = InformationType.PRIVATESECURITY
137 else:
138- information_type = InformationType.PUBLIC
139+ information_type = None
140
141 params = CreateBugParams(
142 owner=self.user, title=summary, comment=comment,
143
144=== modified file 'lib/lp/testing/factory.py'
145--- lib/lp/testing/factory.py 2012-07-13 14:26:36 +0000
146+++ lib/lp/testing/factory.py 2012-07-31 06:32:19 +0000
147@@ -1652,10 +1652,10 @@
148 return branch.createBranchRevision(sequence, revision)
149
150 def makeBug(self, product=None, owner=None, bug_watch_url=None,
151- information_type=InformationType.PUBLIC, date_closed=None,
152- title=None, date_created=None, description=None,
153- comment=None, status=None, distribution=None, milestone=None,
154- series=None, tags=None, sourcepackagename=None):
155+ information_type=None, date_closed=None, title=None,
156+ date_created=None, description=None, comment=None,
157+ status=None, distribution=None, milestone=None, series=None,
158+ tags=None, sourcepackagename=None):
159 """Create and return a new, arbitrary Bug.
160
161 The bug returned uses default values where possible. See