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

Proposed by Richard Harding
Status: Superseded
Proposed branch: lp:~rharding/launchpad/remove_assigned_specs_1068817
Merge into: lp:launchpad
Diff against target: 117 lines (+20/-14)
5 files modified
lib/lp/registry/doc/person-account.txt (+5/-2)
lib/lp/registry/doc/person.txt (+3/-1)
lib/lp/registry/interfaces/person.py (+0/-2)
lib/lp/registry/javascript/product_views.js (+4/-0)
lib/lp/registry/model/person.py (+8/-9)
To merge this branch: bzr merge lp:~rharding/launchpad/remove_assigned_specs_1068817
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+131556@code.launchpad.net

This proposal has been superseded by a proposal from 2012-10-26.

Commit message

Remove person.assigned_specifications as it's limited in use and is a possible way to shoot yourself in the foot.

Description of the change

= Summary =

person.assigned_specs is a limited used property that can be a potential way
to shoot yourself in the foot since it doesn't deal with checking permissions
on items.

Its single use case is in tests and deactivating an account when you do in
fact want to make sure you catch all specifications that need to be
unassigned.

== Pre Implementation ==

Had a chat with Aaron around the reasoning for cleaning this up.

== Implementation Notes ==

We just replace the simple query directly into the deactivate account work.
It's doing a lot of work and this doesn't add much to it.

The larger update is to the tests since many of the doctests used this as a
shortcut to get to the list of assigned specs.

== Tests ==

registry/doc/person.txt
registry/doc/person-account.txt

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/doc/person-account.txt'
2--- lib/lp/registry/doc/person-account.txt 2012-10-24 07:49:54 +0000
3+++ lib/lp/registry/doc/person-account.txt 2012-10-26 08:58:29 +0000
4@@ -12,6 +12,7 @@
5 process. Matsubara's account was created during a code import.
6
7 >>> from zope.component import getUtility
8+ >>> from lp.blueprints.enums import SpecificationFilter
9 >>> from lp.services.identity.interfaces.emailaddress import (
10 ... IEmailAddressSet,
11 ... )
12@@ -100,7 +101,8 @@
13 >>> foobar.searchTasks(params).count() > 0
14 True
15
16- >>> len(foobar.assigned_specs) > 0
17+ >>> foobar.specifications(
18+ ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count() > 0
19 True
20
21 >>> foobar_pillars = []
22@@ -173,7 +175,8 @@
23
24 ...no assigned specs...
25
26- >>> len(foobar.assigned_specs)
27+ >>> foobar.specifications(
28+ ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count()
29 0
30
31 ...no owned teams...
32
33=== modified file 'lib/lp/registry/doc/person.txt'
34--- lib/lp/registry/doc/person.txt 2012-10-23 02:30:37 +0000
35+++ lib/lp/registry/doc/person.txt 2012-10-26 08:58:29 +0000
36@@ -1183,7 +1183,9 @@
37
38 These 2 specifications are assigned to Carlos:
39
40- >>> for spec in carlos.assigned_specs:
41+ >>> assigned_specs = carlos.specifications(
42+ ... carlos, filter=[SpecificationFilter.ASSIGNEE])
43+ >>> for spec in assigned_specs:
44 ... print spec.name
45 svg-support
46 extension-manager-upgrades
47
48=== modified file 'lib/lp/registry/interfaces/person.py'
49--- lib/lp/registry/interfaces/person.py 2012-10-24 23:45:42 +0000
50+++ lib/lp/registry/interfaces/person.py 2012-10-26 08:58:29 +0000
51@@ -848,8 +848,6 @@
52 "Any specifications related to this person, either because the are "
53 "a subscriber, or an assignee, or a drafter, or the creator. "
54 "Sorted newest-first.")
55- assigned_specs = Attribute(
56- "Specifications assigned to this person, sorted newest first.")
57 assigned_specs_in_progress = Attribute(
58 "Specifications assigned to this person whose implementation is "
59 "started but not yet completed, sorted newest first.")
60
61=== modified file 'lib/lp/registry/javascript/product_views.js'
62--- lib/lp/registry/javascript/product_views.js 2012-10-05 19:50:03 +0000
63+++ lib/lp/registry/javascript/product_views.js 2012-10-26 08:58:29 +0000
64@@ -24,6 +24,10 @@
65 info_type.cache_to_choicesource(
66 LP.cache.information_type_data));
67
68+ // We are not doing ajax saves of the information type so we need to
69+ // disable the flash on save for the widget.
70+ widget.set('flashEnabled', false);
71+
72 // When the information type changes, check if we should show/hide
73 // UI components.
74 widget.on('save', function (ev) {
75
76=== modified file 'lib/lp/registry/model/person.py'
77--- lib/lp/registry/model/person.py 2012-10-24 23:45:42 +0000
78+++ lib/lp/registry/model/person.py 2012-10-26 08:58:29 +0000
79@@ -798,12 +798,6 @@
80 person=self, time_zone=time_zone, latitude=latitude,
81 longitude=longitude, last_modified_by=user)
82
83- # specification-related joins
84- @property
85- def assigned_specs(self):
86- return shortlist(Specification.selectBy(
87- assignee=self, orderBy=['-datecreated']))
88-
89 @property
90 def assigned_specs_in_progress(self):
91 replacements = sqlvalues(assignee=self)
92@@ -2174,8 +2168,8 @@
93 product_set = getUtility(IProductSet)
94 non_public_products = product_set.get_users_private_products(self)
95 if non_public_products.count() != 0:
96- errors.append(('This account cannot be deactivated because it owns '
97- 'the following non-public products: ') +
98+ errors.append(('This account cannot be deactivated because it owns'
99+ ' the following non-public products: ') +
100 ','.join([p.name for p in non_public_products]))
101
102 if self.account_status != AccountStatus.ACTIVE:
103@@ -2225,8 +2219,13 @@
104 "Bugtask %s assignee isn't the one expected: %s != %s" % (
105 bug_task.id, bug_task.assignee.name, self.name))
106 bug_task.transitionToAssignee(None)
107- for spec in self.assigned_specs:
108+
109+ assigned_specs = self.specifications(
110+ self,
111+ filter=[SpecificationFilter.ASSIGNEE])
112+ for spec in assigned_specs:
113 spec.assignee = None
114+
115 registry_experts = getUtility(ILaunchpadCelebrities).registry_experts
116 for team in Person.selectBy(teamowner=self):
117 team.teamowner = registry_experts