~launchpad-pqm/launchpad/devel

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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
Distribution Views
==================

Lists of distribution mirrors
-----------------------------

There are several pages listing the mirrors of a distribution, and they all
share a common base class which is responsible for ordering the mirrors by
country.

    >>> from lp.registry.interfaces.distribution import IDistributionSet

    >>> distributionset = getUtility(IDistributionSet)
    >>> ubuntu = distributionset.getByName("ubuntu")
    >>> ubuntu_cdmirrors = create_view(ubuntu, name="+cdmirrors")

    >>> country_and_mirrors = ubuntu_cdmirrors.getMirrorsGroupedByCountry()
    >>> for country_and_mirror in country_and_mirrors:
    ...     country = country_and_mirror['country']
    ...     mirrors = country_and_mirror['mirrors']
    ...     for mirror in mirrors:
    ...         assert mirror.country.name == country
    ...     print "%s: %d mirror(s)" % (country, len(mirrors))
    France: 2 mirror(s)
    Germany: 1 mirror(s)
    United Kingdom: 1 mirror(s)

Lists of archive mirrors
------------------------

    >>> ubuntu_archivemirrors = create_view(ubuntu, name="+archivemirrors")
    >>> country_and_mirrors = (
    ...     ubuntu_archivemirrors.getMirrorsGroupedByCountry())
    >>> for country_and_mirror in country_and_mirrors:
    ...     country = country_and_mirror['country']
    ...     mirrors = country_and_mirror['mirrors']
    ...     for mirror in mirrors:
    ...         assert mirror.country.name == country
    ...     print "%s: %d mirror(s)" % (country, len(mirrors))
    Antarctica: 1 mirror(s)
    France: 2 mirror(s)
    United Kingdom: 1 mirror(s)


Distribution modification views
===============================


Registering a distribution
--------------------------

The +add view of the DistributionSet allows admins to register distributions.

    >>> view = create_view(distributionset, '+add')
    >>> print view.label
    Register a new distribution

    >>> print view.page_title
    Register a new distribution

The view provides a cancel link.

    >>> print view.cancel_url
    http://launchpad.dev/distros

The view accepts the basic fields to register a distribution.

    >>> view.field_names
    ['name', 'displayname', 'title', 'summary', 'description', 'domainname',
     'members', 'official_malone', 'blueprints_usage', 'translations_usage',
     'answers_usage']

    >>> login("admin@canonical.com")
    >>> form = {
    ...     'field.name': 'youbuntu',
    ...     'field.displayname': 'YoUbuntu',
    ...     'field.title': 'YoUbuntu OS',
    ...     'field.summary': 'summary',
    ...     'field.description': 'description',
    ...     'field.domainname': 'youbuntu.me',
    ...     'field.members': 'landscape-developers',
    ...     'field.require_virtualized': 'on',
    ...     'field.enabled_restricted_families': [],
    ...     'field.actions.save': 'Save',
    ...     }
    >>> view = create_initialized_view(distributionset, '+add', form=form)
    >>> view.errors
    []
    >>> print view.next_url
    http://launchpad.dev/youbuntu

    >>> distribution = distributionset.getByName("youbuntu")
    >>> print distribution.name
    youbuntu

Only admins and owners can access the view.

    >>> from canonical.launchpad.webapp.authorization import check_permission

    >>> check_permission('launchpad.Admin', view)
    True

    >>> login('no-priv@canonical.com')
    >>> check_permission('launchpad.Admin', view)
    False


Editing a distribution
----------------------

The +edit view allows an owner or admin to change a distribution. It provides
a label, page_title, and cancel_url.

    >>> login("admin@canonical.com")
    >>> view = create_view(distribution, '+edit')
    >>> print view.label
    Change YoUbuntu details

    >>> print view.page_title
    Change YoUbuntu details

    >>> print view.cancel_url
    http://launchpad.dev/youbuntu

The view accepts most of the distribution fields.

    >>> distribution.bug_tracking_usage
    <DBItem ServiceUsage.UNKNOWN, (10) Unknown>

    >>> view.field_names
    ['displayname', 'title', 'summary', 'description',
     'bug_reporting_guidelines', 'bug_reported_acknowledgement',
     'package_derivatives_email', 'icon',
     'logo', 'mugshot', 'official_malone', 'enable_bug_expiration',
     'blueprints_usage', 'translations_usage', 'answers_usage',
     'translation_focus']

    >>> del form['field.name']
    >>> del form['field.actions.save']
    >>> form['field.bug_reporting_guidelines'] = 'guidelines'
    >>> form['field.official_malone'] = 'on'
    >>> form['field.actions.change'] = 'Change'
    >>> view = create_initialized_view(distribution, '+edit', form=form)
    >>> view.errors
    []
    >>> print view.next_url
    http://launchpad.dev/youbuntu

    >>> print distribution.bug_reporting_guidelines
    guidelines

    >>> distribution.bug_tracking_usage
    <DBItem ServiceUsage.LAUNCHPAD, (20) Launchpad>

Only admins and owners can access the view.

    >>> check_permission('launchpad.Edit', view)
    True

    >>> login('no-priv@canonical.com')
    >>> check_permission('launchpad.Edit', view)
    False


Changing a distribution mirror administrator
--------------------------------------------

the +selectmirroradmins allows the owner or admin to change the mirror
administrator.

    >>> login("admin@canonical.com")
    >>> view = create_view(distribution, '+selectmirroradmins')
    >>> print view.label
    Change the YoUbuntu mirror administrator

    >>> print view.page_title
    Change the YoUbuntu mirror administrator

    >>> print view.cancel_url
    http://launchpad.dev/youbuntu

The view accepts the mirror_admin field.

    >>> print distribution.mirror_admin.name
    name16

    >>> view.field_names
    ['mirror_admin']

    >>> form = {
    ...     'field.mirror_admin': 'no-priv',
    ...     'field.actions.change': 'Change',
    ...     }
    >>> view = create_initialized_view(
    ...     distribution, '+selectmirroradmins', form=form)
    >>> view.errors
    []
    >>> print view.next_url
    http://launchpad.dev/youbuntu

    >>> print distribution.mirror_admin.name
    no-priv

Only admins and owners can access the view.

    >>> check_permission('launchpad.Edit', view)
    True

    >>> login('no-priv@canonical.com')
    >>> check_permission('launchpad.Edit', view)
    False


Changing a distribution members team
------------------------------------

the +selectmirroradmins allows the owner or admin to change the members team.

    >>> login("admin@canonical.com")
    >>> view = create_view(distribution, '+selectmemberteam')
    >>> print view.label
    Change the YoUbuntu members team

    >>> print view.page_title
    Change the YoUbuntu members team

    >>> print view.cancel_url
    http://launchpad.dev/youbuntu

The view accepts the members field.

    >>> print distribution.members.name
    landscape-developers

    >>> view.field_names
    ['members']

    >>> form = {
    ...     'field.members': 'ubuntu-team',
    ...     'field.actions.change': 'Change',
    ...     }
    >>> view = create_initialized_view(
    ...     distribution, '+selectmemberteam', form=form)
    >>> view.errors
    []
    >>> print view.next_url
    http://launchpad.dev/youbuntu

    >>> print distribution.members.name
    ubuntu-team

Only admins and owners can access the view.

    >>> check_permission('launchpad.Edit', view)
    True

    >>> login('no-priv@canonical.com')
    >>> check_permission('launchpad.Edit', view)
    False


Distribution +index
===================

+index portlets
---------------

The distribution index page may contain portlets for Launchpad applications.
If the distribution does not officially use the apps, its portlet does
not appear.

    >>> from canonical.launchpad.testing.pages import find_tag_by_id

    >>> owner = distribution.owner
    >>> login_person(owner)
    >>> distribution.official_malone = False
    >>> question = factory.makeQuestion(target=distribution)
    >>> faq = factory.makeFAQ(target=distribution)
    >>> bugtask = factory.makeBugTask(target=distribution)
    >>> blueprint = factory.makeSpecification(distribution=distribution)

    >>> view = create_view(distribution, name='+index', principal=owner)
    >>> content = find_tag_by_id(view.render(), 'maincontent')
    >>> print find_tag_by_id(content, 'portlet-latest-faqs')
    None
    >>> print find_tag_by_id(content, 'portlet-latest-questions')
    None
    >>> print find_tag_by_id(content, 'portlet-latest-bugs')
    None
    >>> print find_tag_by_id(content, 'portlet-blueprints')
    None

If the distribution officially uses the application, its portlet does appear.

    >>> from canonical.testing.layers import MemcachedLayer
    >>> from lp.app.enums import ServiceUsage

    # When the cache regenerated, all users will see the change.
    >>> MemcachedLayer.purge()
    >>> distribution.answers_usage = ServiceUsage.LAUNCHPAD
    >>> distribution.blueprints_usage = ServiceUsage.LAUNCHPAD
    >>> distribution.official_malone = True

    >>> view = create_view(distribution, name='+index', principal=owner)
    >>> content = find_tag_by_id(view.render(), 'maincontent')
    >>> print find_tag_by_id(content, 'portlet-latest-faqs')['id']
    portlet-latest-faqs
    >>> print find_tag_by_id(content, 'portlet-latest-questions')['id']
    portlet-latest-questions
    >>> print find_tag_by_id(content, 'portlet-latest-bugs')['id']
    portlet-latest-bugs
    >>> print find_tag_by_id(content, 'portlet-blueprints')['id']
    portlet-blueprints


Distribution +series
--------------------

The +series view provides a page title and list of dicts that represent
the series and the CSS class to present them with.

    >>> view = create_view(ubuntu, name='+series')
    >>> print view.label
    Timeline

    >>> for styled_series in view.styled_series:
    ...     print styled_series['series'].name, styled_series['css_class']
    breezy-autotest
    grumpy
    hoary highlight
    warty


Distribution +derivatives
-------------------------

The +derivatives view provides a page title and list of dicts that represent
the derivatives and the CSS class to present them with.

    >>> view = create_view(ubuntu, name='+derivatives')
    >>> print view.label
    Derivatives

    >>> for styled_series in view.styled_series:
    ...     print styled_series['series'].name, styled_series['css_class']
    hoary-test
    krunch
    breezy-autotest
    2k5 highlight


Distribution +ppas
------------------

The +ppas view provides a page title and label, some statistics helpers
and search results.

    >>> view = create_view(ubuntu, name='+ppas')
    >>> print view.label
    Personal Package Archives for Ubuntu Linux

    # The leaf of the breadcrumbs, also used in the page-title.
    >>> print view.page_title
    Personal Package Archives