Merge lp:~gary/launchpad/bug548-db-2 into lp:launchpad/db-devel

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 10177
Proposed branch: lp:~gary/launchpad/bug548-db-2
Merge into: lp:launchpad/db-devel
Diff against target: 454 lines (+313/-1)
8 files modified
database/sampledata/current-dev.sql (+106/-0)
database/sampledata/current.sql (+106/-0)
database/schema/comments.sql (+3/-0)
database/schema/patch-2208-38-0.sql (+7/-0)
database/schema/security.cfg (+2/-0)
lib/lp/bugs/doc/bugnotification-sending.txt (+19/-0)
lib/lp/registry/interfaces/person.py (+22/-1)
lib/lp/registry/model/person.py (+48/-0)
To merge this branch: bzr merge lp:~gary/launchpad/bug548-db-2
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Stuart Bishop (community) db Approve
Robert Collins db Pending
Review via email: mp+48318@code.launchpad.net

Commit message

[r=allenap,stub][ui=none][bug=548] Add "selfgenerated_bugnotifications" as a global option for people so that we can work on bug 548. Only in the DB at this time, since the actual implementation is not yet done.

Description of the change

I made https://code.launchpad.net/~gary/launchpad/bug548-db/+merge/48263 in order to try and add a column to person named "selfgenerated_bugnotifications" so that we can work on bug 548 on devel after the upcoming rollout. The intended use is as described in https://dev.launchpad.net/yellow/Subscriptions#Turning%20off%20emails%20about%20your%20own%20actions .

Beyond some relatively superficial problems, Stuart and Robert expressed fundamental concern about adding more columns to the Person table. Stuart suggested an alternate approach, and implemented the SQL for me. Thank you!

His SQL had two aspects I had to remove. The first, which I did with his blessing, is that I switched from using a trigger to create PersonSettings to using __init__. This fixed some access problems I found in tests, in which a newly-created Person object would not yet have a PersonSettings object around.

The other aspect is that he had moved verbose_bugnotifications to the personsettings table. He wants personsettings to only hold information pertinent to people, rather than teams. It turns out that verbose_bugnotifications is an attribute used by teams, and tested as such. Therefore, I did not have to change the Person table at all, which made this branch a lot smaller than it was initially.

On the downside, in his original change, the Person table actually shrank a very small bit, while in the current version, it merely stays as it was. Making another table for shared Person-Team settings is unnecessary and out of scope for this branch.

I threw in a quick test to show that the new attribute was available. I was reading doctests to figure out what was going on and found them helpful, so I just threw the smoketest in there for now. When we actually have this feature implemented, I will advocate maintaining the doctests for new readers like me, while moving exceptional cases to unit tests.

Gary

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Fine.

I suspect PersonSettings will end up with team settings too, but for now this is fine.

review: Approve (db)
Revision history for this message
Gavin Panella (allenap) wrote :

I really like the:

+ @cachedproperty
+ def _person_settings(self):
...
+ delegates(IPersonSettings, context='_person_settings')

pattern. Neat.

review: Approve
Revision history for this message
Gary Poster (gary) wrote :

Thank you!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/sampledata/current-dev.sql'
2--- database/sampledata/current-dev.sql 2011-01-28 12:44:50 +0000
3+++ database/sampledata/current-dev.sql 2011-02-02 18:09:33 +0000
4@@ -6306,6 +6306,112 @@
5 ALTER TABLE personnotification ENABLE TRIGGER ALL;
6
7
8+ALTER TABLE personsettings DISABLE TRIGGER ALL;
9+
10+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (1, true);
11+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (2, true);
12+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (3, true);
13+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (4, true);
14+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (5, true);
15+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (6, true);
16+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (7, true);
17+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (8, true);
18+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (9, true);
19+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (10, true);
20+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (11, true);
21+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (12, true);
22+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (13, true);
23+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (14, true);
24+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (16, true);
25+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (17, true);
26+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (18, true);
27+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (19, true);
28+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (20, true);
29+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (21, true);
30+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (22, true);
31+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (23, true);
32+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (24, true);
33+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (25, true);
34+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (26, true);
35+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (27, true);
36+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (28, true);
37+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (29, true);
38+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (30, true);
39+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (31, true);
40+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (32, true);
41+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (33, true);
42+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (34, true);
43+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (35, true);
44+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (36, true);
45+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (37, true);
46+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (38, true);
47+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (39, true);
48+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (40, true);
49+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (41, true);
50+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (42, true);
51+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (43, true);
52+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (44, true);
53+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (45, true);
54+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (46, true);
55+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (47, true);
56+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (48, true);
57+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (49, true);
58+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (50, true);
59+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (51, true);
60+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (52, true);
61+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (53, true);
62+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (55, true);
63+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (56, true);
64+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (57, true);
65+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (58, true);
66+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (59, true);
67+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (60, true);
68+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (61, true);
69+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (62, true);
70+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (63, true);
71+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (64, true);
72+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (65, true);
73+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (66, true);
74+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (67, true);
75+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (68, true);
76+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (69, true);
77+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (70, true);
78+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243601, true);
79+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243602, true);
80+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243603, true);
81+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243604, true);
82+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243606, true);
83+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243607, true);
84+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243608, true);
85+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243609, true);
86+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243610, true);
87+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243611, true);
88+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243612, true);
89+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243613, true);
90+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243614, true);
91+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243615, true);
92+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243616, true);
93+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243617, true);
94+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243618, true);
95+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243620, true);
96+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243621, true);
97+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243622, true);
98+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243623, true);
99+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243624, true);
100+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243625, true);
101+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243626, true);
102+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243627, true);
103+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243628, true);
104+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243629, true);
105+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243630, true);
106+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243631, true);
107+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243632, true);
108+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243651, true);
109+
110+
111+ALTER TABLE personsettings ENABLE TRIGGER ALL;
112+
113+
114 ALTER TABLE persontransferjob DISABLE TRIGGER ALL;
115
116
117
118=== modified file 'database/sampledata/current.sql'
119--- database/sampledata/current.sql 2011-01-28 12:44:50 +0000
120+++ database/sampledata/current.sql 2011-02-02 18:09:33 +0000
121@@ -6311,6 +6311,112 @@
122 ALTER TABLE personnotification ENABLE TRIGGER ALL;
123
124
125+ALTER TABLE personsettings DISABLE TRIGGER ALL;
126+
127+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (1, true);
128+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (2, true);
129+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (3, true);
130+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (4, true);
131+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (5, true);
132+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (6, true);
133+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (7, true);
134+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (8, true);
135+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (9, true);
136+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (10, true);
137+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (11, true);
138+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (12, true);
139+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (13, true);
140+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (14, true);
141+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (16, true);
142+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (17, true);
143+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (18, true);
144+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (19, true);
145+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (20, true);
146+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (21, true);
147+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (22, true);
148+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (23, true);
149+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (24, true);
150+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (25, true);
151+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (26, true);
152+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (27, true);
153+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (28, true);
154+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (29, true);
155+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (30, true);
156+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (31, true);
157+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (32, true);
158+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (33, true);
159+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (34, true);
160+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (35, true);
161+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (36, true);
162+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (37, true);
163+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (38, true);
164+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (39, true);
165+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (40, true);
166+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (41, true);
167+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (42, true);
168+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (43, true);
169+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (44, true);
170+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (45, true);
171+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (46, true);
172+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (47, true);
173+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (48, true);
174+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (49, true);
175+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (50, true);
176+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (51, true);
177+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (52, true);
178+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (53, true);
179+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (55, true);
180+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (56, true);
181+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (57, true);
182+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (58, true);
183+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (59, true);
184+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (60, true);
185+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (61, true);
186+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (62, true);
187+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (63, true);
188+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (64, true);
189+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (65, true);
190+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (66, true);
191+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (67, true);
192+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (68, true);
193+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (69, true);
194+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (70, true);
195+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243601, true);
196+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243602, true);
197+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243603, true);
198+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243604, true);
199+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243606, true);
200+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243607, true);
201+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243608, true);
202+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243609, true);
203+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243610, true);
204+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243611, true);
205+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243612, true);
206+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243613, true);
207+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243614, true);
208+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243615, true);
209+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243616, true);
210+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243617, true);
211+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243618, true);
212+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243620, true);
213+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243621, true);
214+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243622, true);
215+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243623, true);
216+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243624, true);
217+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243625, true);
218+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243626, true);
219+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243627, true);
220+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243628, true);
221+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243629, true);
222+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243630, true);
223+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243631, true);
224+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243632, true);
225+INSERT INTO personsettings (person, selfgenerated_bugnotifications) VALUES (243651, true);
226+
227+
228+ALTER TABLE personsettings ENABLE TRIGGER ALL;
229+
230+
231 ALTER TABLE persontransferjob DISABLE TRIGGER ALL;
232
233
234
235=== modified file 'database/schema/comments.sql'
236--- database/schema/comments.sql 2011-01-28 12:44:50 +0000
237+++ database/schema/comments.sql 2011-02-02 18:09:33 +0000
238@@ -1267,6 +1267,9 @@
239 COMMENT ON COLUMN Person.visibility IS 'person.PersonVisibility enumeration which can be set to Public, Public with Private Membership, or Private.';
240 COMMENT ON COLUMN Person.verbose_bugnotifications IS 'If true, all bugnotifications sent to this Person will include the bug description.';
241
242+COMMENT ON TABLE PersonSettings IS 'Flags and settings corresponding to a Person. These are in a separate table to remove infrequently used data from the Person table itself.';
243+COMMENT ON COLUMN PersonSettings.selfgenerated_bugnotifications IS 'If true, users receive bugnotifications for actions they personally triggered.';
244+
245 COMMENT ON VIEW ValidPersonCache IS 'A materialized view listing the Person.ids of all valid people (but not teams).';
246
247 -- PersonLanguage
248
249=== added file 'database/schema/patch-2208-38-0.sql'
250--- database/schema/patch-2208-38-0.sql 1970-01-01 00:00:00 +0000
251+++ database/schema/patch-2208-38-0.sql 2011-02-02 18:09:33 +0000
252@@ -0,0 +1,7 @@
253+SET client_min_messages=ERROR;
254+
255+CREATE TABLE PersonSettings (
256+ person integer PRIMARY KEY REFERENCES Person ON DELETE CASCADE,
257+ selfgenerated_bugnotifications boolean NOT NULL DEFAULT TRUE);
258+
259+INSERT INTO LaunchpadDatabaseRevision VALUES (2208, 38, 0);
260
261=== modified file 'database/schema/security.cfg'
262--- database/schema/security.cfg 2011-02-01 18:52:06 +0000
263+++ database/schema/security.cfg 2011-02-02 18:09:33 +0000
264@@ -220,6 +220,7 @@
265 public.packaging = SELECT, INSERT, UPDATE, DELETE
266 public.personlanguage = SELECT, INSERT, UPDATE, DELETE
267 public.personlocation = SELECT, INSERT, UPDATE, DELETE
268+public.personsettings = SELECT, INSERT, UPDATE
269 public.persontransferjob = SELECT, INSERT, UPDATE, DELETE
270 public.personnotification = SELECT, INSERT, UPDATE, DELETE
271 public.pillarname = SELECT, INSERT, DELETE
272@@ -1477,6 +1478,7 @@
273 public.component = SELECT
274 public.packagebugsupervisor = SELECT
275 public.person = SELECT
276+public.personsettings = SELECT
277 public.personlanguage = SELECT
278 public.product = SELECT, UPDATE
279 public.project = SELECT, UPDATE
280
281=== modified file 'lib/lp/bugs/doc/bugnotification-sending.txt'
282--- lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-01 04:57:42 +0000
283+++ lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-02 18:09:33 +0000
284@@ -1098,6 +1098,25 @@
285 ' people very angry and has been widely regarded as a bad move',
286 '']
287
288+Self-Generated Bug Notifications
289+--------------------------------
290+
291+People (not teams) will have the choice to receive notifications from actions
292+they generated. For now, everyone receives these notifications whether they
293+want them or not. However, we can show that the attribute exists for now.
294+
295+ >>> flush_notifications()
296+ >>> switch_db_to_launchpad()
297+ >>> verbose_person.selfgenerated_bugnotifications
298+ True
299+
300+Teams do not implement this attribute.
301+
302+ >>> verbose_team.selfgenerated_bugnotifications
303+ Traceback (most recent call last):
304+ ...
305+ NotImplementedError: Teams do not support this attribute.
306+
307 Notification Recipients
308 -----------------------
309
310
311=== modified file 'lib/lp/registry/interfaces/person.py'
312--- lib/lp/registry/interfaces/person.py 2011-01-10 14:55:31 +0000
313+++ lib/lp/registry/interfaces/person.py 2011-02-02 18:09:33 +0000
314@@ -16,6 +16,7 @@
315 'IPersonClaim',
316 'IPersonPublic', # Required for a monkey patch in interfaces/archive.py
317 'IPersonSet',
318+ 'IPersonSettings',
319 'ISoftwareCenterAgentAPI',
320 'ISoftwareCenterAgentApplication',
321 'IPersonViewRestricted',
322@@ -584,10 +585,30 @@
323 description=_("The reason the person's standing is what it is."))
324
325
326+class IPersonSettings(Interface):
327+ """Settings for a person (not a team!) that are used relatively rarely.
328+
329+ We store these attributes on a separate object, PersonSettings, to which
330+ the Person class delegates. This makes it possible to shrink the size of
331+ the person record.
332+
333+ In the future, perhaps we will adapt IPerson to IPersonSettings when
334+ we want these attributes instead of delegating, so we can shrink the
335+ class, too.
336+
337+ We also may want TeamSettings and PersonTeamSettings in the future.
338+ """
339+
340+ selfgenerated_bugnotifications = Bool(
341+ title=_("Send me bug notifications for changes I make."),
342+ required=False, default=True)
343+
344+
345 class IPersonPublic(IHasBranches, IHasSpecifications,
346 IHasMergeProposals, IHasLogo, IHasMugshot, IHasIcon,
347 IHasLocation, IHasRequestedReviews, IObjectWithLocation,
348- IPrivacy, IHasBugs, IHasRecipes, IHasTranslationImports):
349+ IPrivacy, IHasBugs, IHasRecipes, IHasTranslationImports,
350+ IPersonSettings):
351 """Public attributes for a Person."""
352
353 id = Int(title=_('ID'), required=True, readonly=True)
354
355=== modified file 'lib/lp/registry/model/person.py'
356--- lib/lp/registry/model/person.py 2011-02-01 18:52:06 +0000
357+++ lib/lp/registry/model/person.py 2011-02-02 18:09:33 +0000
358@@ -36,6 +36,8 @@
359 import subprocess
360 import weakref
361
362+from lazr.delegates import delegates
363+from lazr.restful.fields import Reference
364 import pytz
365 from sqlobject import (
366 BoolCol,
367@@ -50,6 +52,7 @@
368 OR,
369 SQLConstant,
370 )
371+from storm.base import Storm
372 from storm.expr import (
373 Alias,
374 And,
375@@ -65,6 +68,10 @@
376 Upper,
377 )
378 from storm.info import ClassAlias
379+from storm.locals import (
380+ Int,
381+ Reference,
382+ )
383 from storm.store import (
384 EmptyResultSet,
385 Store,
386@@ -216,6 +223,7 @@
387 InvalidName,
388 IPerson,
389 IPersonSet,
390+ IPersonSettings,
391 ITeam,
392 PersonalStanding,
393 PersonCreationRationale,
394@@ -351,6 +359,18 @@
395 return "%s, %s" % (displayname.strip(), person.name)
396
397
398+class PersonSettings(Storm):
399+
400+ implements(IPersonSettings)
401+
402+ __storm_table__ = 'PersonSettings'
403+
404+ personID = Int("person", default=None, primary=True)
405+ person = Reference(personID, "Person.id")
406+
407+ selfgenerated_bugnotifications = BoolCol(notNull=True, default=True)
408+
409+
410 class Person(
411 SQLBase, HasBugsBase, HasSpecificationsMixin, HasTranslationImportsMixin,
412 HasBranchesMixin, HasMergeProposalsMixin, HasRequestedReviewsMixin):
413@@ -358,6 +378,33 @@
414
415 implements(IPerson, IHasIcon, IHasLogo, IHasMugshot)
416
417+ def __init__(self, *args, **kwargs):
418+ super(Person, self).__init__(*args, **kwargs)
419+ # Initialize our PersonSettings object/record.
420+ if not self.is_team:
421+ # This is a Person, not a team. Teams may want a TeamSettings
422+ # in the future.
423+ settings = PersonSettings()
424+ settings.person = self
425+
426+ @cachedproperty
427+ def _person_settings(self):
428+ if self.is_team:
429+ # Hopefully no-one ever encounters this. If someone does,
430+ # that means that the code is trying to look at
431+ # person-specific attributes on a team, and we should warn
432+ # about that explicitly to give a hint about what is wrong
433+ # (rather than merely returning None).
434+ raise NotImplementedError(
435+ 'Teams do not support this attribute.')
436+ else:
437+ # This is a person.
438+ return IStore(PersonSettings).find(
439+ PersonSettings,
440+ PersonSettings.person == self).one()
441+
442+ delegates(IPersonSettings, context='_person_settings')
443+
444 sortingColumns = SQLConstant(
445 "person_sort_key(Person.displayname, Person.name)")
446 # Redefine the default ordering into Storm syntax.
447@@ -3815,6 +3862,7 @@
448 ('teamparticipation', 'team'),
449 ('personlanguage', 'person'),
450 ('person', 'merged'),
451+ ('personsettings', 'person'),
452 ('emailaddress', 'person'),
453 # Polls are not carried over when merging teams.
454 ('poll', 'team'),

Subscribers

People subscribed via source and target branches

to status/vote changes: