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
=== modified file 'lib/lp/registry/doc/person-account.txt'
--- lib/lp/registry/doc/person-account.txt 2012-10-24 07:49:54 +0000
+++ lib/lp/registry/doc/person-account.txt 2012-10-26 08:58:29 +0000
@@ -12,6 +12,7 @@
12process. Matsubara's account was created during a code import.12process. Matsubara's account was created during a code import.
1313
14 >>> from zope.component import getUtility14 >>> from zope.component import getUtility
15 >>> from lp.blueprints.enums import SpecificationFilter
15 >>> from lp.services.identity.interfaces.emailaddress import (16 >>> from lp.services.identity.interfaces.emailaddress import (
16 ... IEmailAddressSet,17 ... IEmailAddressSet,
17 ... )18 ... )
@@ -100,7 +101,8 @@
100 >>> foobar.searchTasks(params).count() > 0101 >>> foobar.searchTasks(params).count() > 0
101 True102 True
102103
103 >>> len(foobar.assigned_specs) > 0104 >>> foobar.specifications(
105 ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count() > 0
104 True106 True
105107
106 >>> foobar_pillars = []108 >>> foobar_pillars = []
@@ -173,7 +175,8 @@
173175
174...no assigned specs...176...no assigned specs...
175177
176 >>> len(foobar.assigned_specs)178 >>> foobar.specifications(
179 ... foobar, filter=[SpecificationFilter.ASSIGNEE]).count()
177 0180 0
178181
179...no owned teams...182...no owned teams...
180183
=== modified file 'lib/lp/registry/doc/person.txt'
--- lib/lp/registry/doc/person.txt 2012-10-23 02:30:37 +0000
+++ lib/lp/registry/doc/person.txt 2012-10-26 08:58:29 +0000
@@ -1183,7 +1183,9 @@
11831183
1184These 2 specifications are assigned to Carlos:1184These 2 specifications are assigned to Carlos:
11851185
1186 >>> for spec in carlos.assigned_specs:1186 >>> assigned_specs = carlos.specifications(
1187 ... carlos, filter=[SpecificationFilter.ASSIGNEE])
1188 >>> for spec in assigned_specs:
1187 ... print spec.name1189 ... print spec.name
1188 svg-support1190 svg-support
1189 extension-manager-upgrades1191 extension-manager-upgrades
11901192
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2012-10-24 23:45:42 +0000
+++ lib/lp/registry/interfaces/person.py 2012-10-26 08:58:29 +0000
@@ -848,8 +848,6 @@
848 "Any specifications related to this person, either because the are "848 "Any specifications related to this person, either because the are "
849 "a subscriber, or an assignee, or a drafter, or the creator. "849 "a subscriber, or an assignee, or a drafter, or the creator. "
850 "Sorted newest-first.")850 "Sorted newest-first.")
851 assigned_specs = Attribute(
852 "Specifications assigned to this person, sorted newest first.")
853 assigned_specs_in_progress = Attribute(851 assigned_specs_in_progress = Attribute(
854 "Specifications assigned to this person whose implementation is "852 "Specifications assigned to this person whose implementation is "
855 "started but not yet completed, sorted newest first.")853 "started but not yet completed, sorted newest first.")
856854
=== modified file 'lib/lp/registry/javascript/product_views.js'
--- lib/lp/registry/javascript/product_views.js 2012-10-05 19:50:03 +0000
+++ lib/lp/registry/javascript/product_views.js 2012-10-26 08:58:29 +0000
@@ -24,6 +24,10 @@
24 info_type.cache_to_choicesource(24 info_type.cache_to_choicesource(
25 LP.cache.information_type_data));25 LP.cache.information_type_data));
2626
27 // We are not doing ajax saves of the information type so we need to
28 // disable the flash on save for the widget.
29 widget.set('flashEnabled', false);
30
27 // When the information type changes, check if we should show/hide31 // When the information type changes, check if we should show/hide
28 // UI components.32 // UI components.
29 widget.on('save', function (ev) {33 widget.on('save', function (ev) {
3034
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2012-10-24 23:45:42 +0000
+++ lib/lp/registry/model/person.py 2012-10-26 08:58:29 +0000
@@ -798,12 +798,6 @@
798 person=self, time_zone=time_zone, latitude=latitude,798 person=self, time_zone=time_zone, latitude=latitude,
799 longitude=longitude, last_modified_by=user)799 longitude=longitude, last_modified_by=user)
800800
801 # specification-related joins
802 @property
803 def assigned_specs(self):
804 return shortlist(Specification.selectBy(
805 assignee=self, orderBy=['-datecreated']))
806
807 @property801 @property
808 def assigned_specs_in_progress(self):802 def assigned_specs_in_progress(self):
809 replacements = sqlvalues(assignee=self)803 replacements = sqlvalues(assignee=self)
@@ -2174,8 +2168,8 @@
2174 product_set = getUtility(IProductSet)2168 product_set = getUtility(IProductSet)
2175 non_public_products = product_set.get_users_private_products(self)2169 non_public_products = product_set.get_users_private_products(self)
2176 if non_public_products.count() != 0:2170 if non_public_products.count() != 0:
2177 errors.append(('This account cannot be deactivated because it owns '2171 errors.append(('This account cannot be deactivated because it owns'
2178 'the following non-public products: ') +2172 ' the following non-public products: ') +
2179 ','.join([p.name for p in non_public_products]))2173 ','.join([p.name for p in non_public_products]))
21802174
2181 if self.account_status != AccountStatus.ACTIVE:2175 if self.account_status != AccountStatus.ACTIVE:
@@ -2225,8 +2219,13 @@
2225 "Bugtask %s assignee isn't the one expected: %s != %s" % (2219 "Bugtask %s assignee isn't the one expected: %s != %s" % (
2226 bug_task.id, bug_task.assignee.name, self.name))2220 bug_task.id, bug_task.assignee.name, self.name))
2227 bug_task.transitionToAssignee(None)2221 bug_task.transitionToAssignee(None)
2228 for spec in self.assigned_specs:2222
2223 assigned_specs = self.specifications(
2224 self,
2225 filter=[SpecificationFilter.ASSIGNEE])
2226 for spec in assigned_specs:
2229 spec.assignee = None2227 spec.assignee = None
2228
2230 registry_experts = getUtility(ILaunchpadCelebrities).registry_experts2229 registry_experts = getUtility(ILaunchpadCelebrities).registry_experts
2231 for team in Person.selectBy(teamowner=self):2230 for team in Person.selectBy(teamowner=self):
2232 team.teamowner = registry_experts2231 team.teamowner = registry_experts