1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
Private team participation
==========================
Public teams can perform any role in Launchpad. Private teams
have some restrictions in the roles they can perform.
Bugs
====
Bug subscriptions
-----------------
>>> # Create the necessary teams.
>>> team_owner = factory.makePerson(name='team-owner')
>>> from lp.registry.interfaces.person import IPersonSet, PersonVisibility
>>> admin_user = getUtility(IPersonSet).getByEmail('admin@canonical.com')
>>> login_person(admin_user)
>>> priv_team = factory.makeTeam(name='private-team',
... owner=team_owner,
... visibility=PersonVisibility.PRIVATE)
A private team can be subscribed to a bug.
>>> bug = factory.makeBug()
>>> priv_subscription = bug.subscribe(priv_team, team_owner)
A private team can subscribe others to a bug (the `subscribed_by`
person).
>>> priv_subscription = bug.subscribe(team_owner, priv_team)
The same team can also unsubscribe the person.
>>> bug.unsubscribe(team_owner, priv_team)
Only the person can unsubscribe him or her self.
>>> priv_subscription = bug.subscribe(team_owner, priv_team)
>>> bug.unsubscribe(team_owner, team_owner)
Bug task assignee
-----------------
A private team can be the assignee for a bug task.
>>> bugtask = bug.default_bugtask
>>> bugtask.transitionToAssignee(priv_team)
>>> print bugtask.assignee.name
private-team
Branches
========
Branch ownership
----------------
Private teams can be assigned as the owner of a branch
>>> branch = factory.makeBranch()
>>> branch.setOwner(priv_team, user=admin_user)
Branch subscriptions
--------------------
Private teams can subscribe to branches.
>>> from lp.code.enums import (
... BranchSubscriptionDiffSize,
... BranchSubscriptionNotificationLevel,
... CodeReviewNotificationLevel)
>>> branch = factory.makeBranch()
>>> subscription = branch.subscribe(
... priv_team,
... BranchSubscriptionNotificationLevel.DIFFSONLY,
... BranchSubscriptionDiffSize.WHOLEDIFF,
... CodeReviewNotificationLevel.STATUS, team_owner)
>>> print subscription.person.name
private-team
Branch visibility policies
--------------------------
Private teams can have branch visibility policies.
>>> def teamname(team):
... if team is None:
... return "*everyone*"
... else:
... return team.displayname
>>> def print_team_policies(context):
... for item in context.getBranchVisibilityTeamPolicies():
... print "%s: %s" % (teamname(item.team), item.rule.title)
>>> from lp.code.enums import BranchVisibilityRule
>>> from lp.registry.interfaces.product import IProductSet
>>> evolution = getUtility(IProductSet).getByName('evolution')
>>> print_team_policies(evolution)
>>> evolution.setBranchVisibilityTeamPolicy(
... priv_team, BranchVisibilityRule.PRIVATE)
>>> print_team_policies(evolution)
Private Team: Private
PPAs
====
PPA ownership
-------------
Private teams can own PPAs.
>>> from lp.soyuz.enums import ArchivePurpose
>>> from lp.soyuz.interfaces.archive import IArchiveSet
>>> from lp.registry.interfaces.distribution import (
... IDistributionSet)
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
>>> archive_set = getUtility(IArchiveSet)
>>> private_archive = archive_set.new(
... owner=priv_team, purpose=ArchivePurpose.PPA,
... distribution=ubuntu, name='private-team-archive',
... require_virtualized=False)
PPA subscriptions
-----------------
Private teams can be subscribed to private PPAs.
>>> login('foo.bar@canonical.com')
>>> another_priv_team = factory.makeTeam(name='another-private-team',
... owner=team_owner,
... visibility=PersonVisibility.PRIVATE)
>>> # We must login as the archive owner to add the subscription.
>>> login_person(team_owner)
>>> subscription = private_archive.newSubscription(
... subscriber=another_priv_team,
... registrant=team_owner)
>>> transaction.commit()
Structural Subscriptions
========================
Structural Subscription to Products
-----------------------------------
Private teams can have structural subscriptions to products.
>>> firefox = getUtility(IProductSet).getByName('firefox')
>>> sub = firefox.addSubscription(
... subscriber=priv_team, subscribed_by=team_owner)
>>> sub.target
<Product at ...>
Structural Subscription to Distributions
----------------------------------------
Private teams can have structural subscriptions to distros.
>>> ubuntu = getUtility(IDistributionSet).getByName("ubuntu")
>>> sub = ubuntu.addSubscription(
... subscriber=priv_team, subscribed_by=team_owner)
>>> sub.target
<Distribution 'Ubuntu' (ubuntu)>
Project Roles
=============
Registrant
----------
Only a person can register a project, not a team, so no team, public
or private, can be the project registrant.
>>> login_person(admin_user)
>>> public_team = factory.makeTeam(name='public-team',
... owner=team_owner,
... visibility=PersonVisibility.PUBLIC)
>>> product = factory.makeProduct(registrant=team_owner)
>>> product = factory.makeProduct(registrant=public_team)
>>> product = factory.makeProduct(registrant=priv_team)
Traceback (most recent call last):
...
PrivatePersonLinkageError: Cannot link person
(name=private-team, visibility=PRIVATE) to
<Product at...
Maintainer/Owner
----------------
A public team and a private team can be a project owner.
>>> # The registrant must be specified or it will default to the owner.
>>> product = factory.makeProduct(registrant=admin_user)
>>> product.owner = public_team
>>> product.owner = priv_team
Driver
------
A public team and a private team can be a project driver.
>>> product = factory.makeProduct()
>>> product.driver = priv_team
Bug Supervisor
--------------
A public team and a private team can be a project bug supervisor.
>>> product = factory.makeProduct()
>>> product.setBugSupervisor(public_team, admin_user)
>>> product.setBugSupervisor(priv_team, admin_user)
Product Series Roles
====================
Owner
-----
A public team and a private team can be a product series owner.
>>> product = factory.makeProduct(registrant=admin_user,
... owner=public_team)
>>> product_series = factory.makeProductSeries(product, owner=public_team)
>>> product_series = factory.makeProductSeries(product, owner=priv_team)
Driver
------
A public team and a private team can be a product series driver.
>>> product = factory.makeProduct(registrant=admin_user,
... owner=public_team)
>>> product_series = factory.makeProductSeries(product, owner=public_team)
>>> product_series.driver = public_team
>>> product_series.driver = priv_team
Product Release Roles
=====================
Owner
-----
A public team and a private team can be a product series owner.
>>> product = factory.makeProduct(registrant=admin_user,
... owner=public_team)
>>> product_series = factory.makeProductSeries(product, owner=public_team)
>>> product_milestone = factory.makeMilestone(
... product=product, productseries=product_series)
>>> product_release = factory.makeProductRelease(
... product=product, milestone=product_milestone)
>>> product_release.owner = public_team
>>> product_release.owner = priv_team
Some artifacts of a product change ownership when the product owner
changes. The artifacts are product series, product release, and
translation import queue entries.
>>> product = factory.makeProduct(registrant=admin_user)
>>> product_series = factory.makeProductSeries(
... product=product, owner=public_team)
>>> product_release = factory.makeProductRelease(product=product)
>>> from lp.translations.interfaces.translationimportqueue import (
... ITranslationImportQueue)
>>> import_queue = getUtility(ITranslationImportQueue)
>>> entry = import_queue.addOrUpdateEntry(
... u'po/sr.po', 'foo', True, public_team,
... productseries=product_series)
>>> product.owner = public_team
>>> product.owner = priv_team
Team Membership
===============
Mixing public and private teams can create interesting situations.
Not every type of team can become a member of other types.
>>> from lp.registry.interfaces.person import PrivatePersonLinkageError
>>> reviewer = factory.makePerson()
>>> def join_team(joined_type, joiner_type):
... joined = factory.makeTeam(owner=team_owner,
... visibility=joined_type)
... joiner = factory.makeTeam(owner=team_owner,
... visibility=joiner_type)
... print "%s <- %s: " % (joined_type, joiner_type),
... try:
... joined.addMember(joiner, reviewer=reviewer)
... except PrivatePersonLinkageError:
... print "Not Allowed"
... else:
... print "Allowed"
>>> public = PersonVisibility.PUBLIC
>>> private = PersonVisibility.PRIVATE
>>> visibility_list = list(PersonVisibility.items)
>>> for joined in visibility_list:
... for joiner in visibility_list:
... join_team(joined, joiner)
... print "---"
Public <- Public: Allowed
Public <- Private: Not Allowed
---
Private <- Public: Allowed
Private <- Private: Not Allowed
---
|