Merge lp:~wallyworld/launchpad/improved-bugremovesubscriptions-job into lp:launchpad

Proposed by Ian Booth
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 15426
Proposed branch: lp:~wallyworld/launchpad/improved-bugremovesubscriptions-job
Merge into: lp:launchpad
Diff against target: 124 lines (+17/-30)
5 files modified
lib/lp/registry/interfaces/sharingjob.py (+2/-1)
lib/lp/registry/model/sharingjob.py (+12/-2)
lib/lp/registry/model/teammembership.py (+1/-1)
lib/lp/registry/services/sharingservice.py (+2/-2)
lib/lp/registry/services/tests/test_sharingservice.py (+0/-24)
To merge this branch: bzr merge lp:~wallyworld/launchpad/improved-bugremovesubscriptions-job
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+110447@code.launchpad.net

Commit message

Improve query filter used to find subscriptions to remove when running the RemoveBugSubscriptions job.

Description of the change

== Implementation ==

Use the grantee whose access is revoked (if one is specified) to fiyter the bug subscriptions for removal.

== Tests ==

Existing tests are sufficient, no new functionality added.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/interfaces/sharingjob.py
  lib/lp/registry/model/sharingjob.py
  lib/lp/registry/model/teammembership.py
  lib/lp/registry/services/sharingservice.py
  lib/lp/registry/services/tests/test_sharingservice.py

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/interfaces/sharingjob.py'
2--- lib/lp/registry/interfaces/sharingjob.py 2012-06-14 03:10:47 +0000
3+++ lib/lp/registry/interfaces/sharingjob.py 2012-06-15 02:31:19 +0000
4@@ -83,7 +83,8 @@
5 class IRemoveBugSubscriptionsJobSource(ISharingJobSource):
6 """An interface for acquiring IRemoveBugSubscriptionsJobs."""
7
8- def create(pillar, requestor, bugs=None, information_types=None):
9+ def create(requestor, bugs=None, grantee=None, pillar=None,
10+ information_types=None):
11 """Create a new job to remove subscriptions for the specified bugs.
12
13 Subscriptions for users who no longer have access to the bugs are
14
15=== modified file 'lib/lp/registry/model/sharingjob.py'
16--- lib/lp/registry/model/sharingjob.py 2012-06-15 00:42:38 +0000
17+++ lib/lp/registry/model/sharingjob.py 2012-06-15 02:31:19 +0000
18@@ -58,6 +58,7 @@
19 from lp.registry.model.distribution import Distribution
20 from lp.registry.model.person import Person
21 from lp.registry.model.product import Product
22+from lp.registry.model.teammembership import TeamParticipation
23 from lp.services.config import config
24 from lp.services.database.enumcol import EnumCol
25 from lp.services.database.lpstorm import IStore
26@@ -331,10 +332,19 @@
27 filters.append(
28 BugTaskFlat.distribution == self.distro)
29
30+ subscriptions_filter = [
31+ In(BugSubscription.bug_id,
32+ Select(BugTaskFlat.bug_id, where=And(*filters)))]
33+ if self.grantee:
34+ subscriptions_filter.append(
35+ In(BugSubscription.person_id,
36+ Select(
37+ TeamParticipation.personID,
38+ where=TeamParticipation.team == self.grantee))
39+ )
40 subscriptions = IStore(BugSubscription).find(
41 BugSubscription,
42- In(BugSubscription.bug_id,
43- Select(BugTaskFlat.bug_id, where=And(*filters)))
44+ *subscriptions_filter
45 )
46 for sub in subscriptions:
47 sub.bug.unsubscribe(
48
49=== modified file 'lib/lp/registry/model/teammembership.py'
50--- lib/lp/registry/model/teammembership.py 2012-06-14 07:43:06 +0000
51+++ lib/lp/registry/model/teammembership.py 2012-06-15 02:31:19 +0000
52@@ -394,7 +394,7 @@
53 # to some artifacts shared with the team. We need to run a job
54 # to remove any subscriptions to such artifacts.
55 getUtility(IRemoveBugSubscriptionsJobSource).create(
56- user, grantee=self.team)
57+ user, grantee=self.person)
58 else:
59 # Changed from an inactive state to another inactive one, so no
60 # need to fill/clean the TeamParticipation table.
61
62=== modified file 'lib/lp/registry/services/sharingservice.py'
63--- lib/lp/registry/services/sharingservice.py 2012-06-14 07:43:06 +0000
64+++ lib/lp/registry/services/sharingservice.py 2012-06-15 02:31:19 +0000
65@@ -333,7 +333,7 @@
66 # Create a job to remove subscriptions for artifacts the sharee can no
67 # longer see.
68 getUtility(IRemoveBugSubscriptionsJobSource).create(
69- user, bugs=None, pillar=pillar,
70+ user, bugs=None, grantee=sharee, pillar=pillar,
71 information_types=information_types)
72
73 @available_with_permission('launchpad.Edit', 'pillar')
74@@ -361,7 +361,7 @@
75 # longer see.
76 if bugs:
77 getUtility(IRemoveBugSubscriptionsJobSource).create(
78- user, bugs, pillar=pillar)
79+ user, bugs, grantee=sharee, pillar=pillar)
80 # XXX 2012-06-13 wallyworld bug=1012448
81 # Remove branch subscriptions when information type fully implemented.
82
83
84=== modified file 'lib/lp/registry/services/tests/test_sharingservice.py'
85--- lib/lp/registry/services/tests/test_sharingservice.py 2012-06-14 01:50:05 +0000
86+++ lib/lp/registry/services/tests/test_sharingservice.py 2012-06-15 02:31:19 +0000
87@@ -779,18 +779,6 @@
88 information_type=InformationType.USERDATA)
89 self._assert_revokeAccessGrants(distro, [bug], None)
90
91- # XXX 2012-06-13 wallyworld bug=1012448
92- # Remove branch subscriptions when information type fully implemented.
93-# def test_revokeAccessGrantsBranches(self):
94-# # Users with launchpad.Edit can delete all access for a sharee.
95-# owner = self.factory.makePerson()
96-# product = self.factory.makeProduct(owner=owner)
97-# login_person(owner)
98-# branch = self.factory.makeBranch(
99-# product=product, owner=owner,
100-# information_type=InformationType.USERDATA)
101-# self._assert_revokeAccessGrants(product, None, [branch])
102-
103 def _assert_revokeTeamAccessGrants(self, pillar, bugs, branches):
104 artifacts = []
105 if bugs:
106@@ -864,18 +852,6 @@
107 information_type=InformationType.USERDATA)
108 self._assert_revokeTeamAccessGrants(distro, [bug], None)
109
110- # XXX 2012-06-13 wallyworld bug=1012448
111- # Remove branch subscriptions when information type fully implemented.
112-# def test_revokeAccessGrantsBranches(self):
113-# # Users with launchpad.Edit can delete all access for a sharee.
114-# owner = self.factory.makePerson()
115-# product = self.factory.makeProduct(owner=owner)
116-# login_person(owner)
117-# branch = self.factory.makeBranch(
118-# product=product, owner=owner,
119-# information_type=InformationType.USERDATA)
120-# self._assert_revokeTeamAccessGrants(distro, [bug], None)
121-
122 def _assert_revokeAccessGrantsUnauthorized(self):
123 # revokeAccessGrants raises an Unauthorized exception if the user
124 # is not permitted to do so.