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

Proposed by Richard Harding
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 16204
Proposed branch: lp:~rharding/launchpad/remove_assigned_specs_1068817
Merge into: lp:launchpad
Prerequisite: lp:~rharding/launchpad/fix_flash_1066898
Diff against target: 101 lines (+15/-14)
4 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/model/person.py (+7/-9)
To merge this branch: bzr merge lp:~rharding/launchpad/remove_assigned_specs_1068817
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+131558@code.launchpad.net

This proposal supersedes a proposal from 2012-10-26.

Commit message

Remove person.assigned_specs due to limited use and to prevent possible leakage.

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.
Revision history for this message
Aaron Bentley (abentley) :
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/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 13:32:24 +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-26 07:15:49 +0000
35+++ lib/lp/registry/doc/person.txt 2012-10-26 13:32:24 +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-26 07:18:55 +0000
50+++ lib/lp/registry/interfaces/person.py 2012-10-26 13:32:24 +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
58 def findVisibleAssignedInProgressSpecs(user):
59 """List specifications in progress assigned to this person.
60
61=== modified file 'lib/lp/registry/model/person.py'
62--- lib/lp/registry/model/person.py 2012-10-26 07:18:55 +0000
63+++ lib/lp/registry/model/person.py 2012-10-26 13:32:24 +0000
64@@ -799,12 +799,6 @@
65 person=self, time_zone=time_zone, latitude=latitude,
66 longitude=longitude, last_modified_by=user)
67
68- # specification-related joins
69- @property
70- def assigned_specs(self):
71- return shortlist(Specification.selectBy(
72- assignee=self, orderBy=['-datecreated']))
73-
74 def findVisibleAssignedInProgressSpecs(self, user):
75 """See `IPerson`."""
76 return self.specifications(user, in_progress=True, quantity=5,
77@@ -2175,8 +2169,8 @@
78 product_set = getUtility(IProductSet)
79 non_public_products = product_set.get_users_private_products(self)
80 if non_public_products.count() != 0:
81- errors.append(('This account cannot be deactivated because it owns '
82- 'the following non-public products: ') +
83+ errors.append(('This account cannot be deactivated because it owns'
84+ ' the following non-public products: ') +
85 ','.join([p.name for p in non_public_products]))
86
87 if self.account_status != AccountStatus.ACTIVE:
88@@ -2226,8 +2220,12 @@
89 "Bugtask %s assignee isn't the one expected: %s != %s" % (
90 bug_task.id, bug_task.assignee.name, self.name))
91 bug_task.transitionToAssignee(None)
92- for spec in self.assigned_specs:
93+
94+ assigned_specs = Store.of(self).find(
95+ Specification, assignee=self)
96+ for spec in assigned_specs:
97 spec.assignee = None
98+
99 registry_experts = getUtility(ILaunchpadCelebrities).registry_experts
100 for team in Person.selectBy(teamowner=self):
101 team.teamowner = registry_experts