~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
Administering POTemplates
=========================


Product templates
-----------------

The POTemplate admin page lets us to edit any aspect of that object, that's
why we need to be a Rosetta Expert or a Launchpad admin to use it.

An unprivileged user cannot reach the POTemplate administration page.

    >>> user_browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-2.2/+admin')
    Traceback (most recent call last):
    ...
    Unauthorized:...

Jordi, a Rosetta expert, can.

    >>> browser = setupBrowser(auth='Basic jordi@ubuntu.com:test')
    >>> browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-2.2/+admin')
    >>> print browser.url
    http://translations...dev/evolution/trunk/+pots/evolution-2.2/+admin

Now, we should be sure that the admin form gets all required fields to allow
a Rosetta Expert to administer it.

    >>> browser.getControl(name='field.name').value
    'evolution-2.2'
    >>> browser.getControl('Translation domain').value
    'evolution-2.2'
    >>> browser.getControl(name='field.description').value
    'Template for evolution in hoary'
    >>> print browser.getControl(name='field.header').value
    Project-Id-Version: PACKAGE VERSION
    Report-Msgid-Bugs-To:
    POT-Creation-Date: 2005-08-25 14:56+0200
    PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
    Last-Translator: FULL NAME <EMAIL@ADDRESS>
    Language-Team: LANGUAGE <LL@li.org>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=CHARSET
    Content-Transfer-Encoding: 8bit
    Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
    <BLANKLINE>
    >>> browser.getControl(name='field.iscurrent').value
    True
    >>> browser.getControl(name='field.owner').value
    'rosetta-admins'
    >>> browser.getControl(name='field.productseries').value
    'evolution/trunk'
    >>> browser.getControl(name='field.distroseries').value
    ['']
    >>> browser.getControl(name='field.sourcepackagename').value
    ''
    >>> browser.getControl(name='field.sourcepackageversion').value
    ''
    >>> browser.getControl(name='field.binarypackagename').value
    ''
    >>> browser.getControl(name='field.languagepack').value
    False
    >>> browser.getControl(name='field.path').value
    'po/evolution-2.2.pot'

An administrator can also access the POTemplate administration page.

    >>> admin_browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-2.2/+admin')
    >>> print admin_browser.url
    http://translations...dev/evolution/trunk/+pots/evolution-2.2/+admin

Now, we should be sure that the admin form gets all required fields to allow
an admin to administer it.

    >>> admin_browser.getControl(name='field.name').value
    'evolution-2.2'
    >>> admin_browser.getControl('Translation domain').value
    'evolution-2.2'
    >>> admin_browser.getControl(name='field.description').value
    'Template for evolution in hoary'
    >>> print admin_browser.getControl(name='field.header').value
    Project-Id-Version: PACKAGE VERSION
    Report-Msgid-Bugs-To:
    POT-Creation-Date: 2005-08-25 14:56+0200
    PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
    Last-Translator: FULL NAME <EMAIL@ADDRESS>
    Language-Team: LANGUAGE <LL@li.org>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=CHARSET
    Content-Transfer-Encoding: 8bit
    Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
    <BLANKLINE>
    >>> admin_browser.getControl(name='field.iscurrent').value
    True
    >>> admin_browser.getControl(name='field.owner').value
    'rosetta-admins'
    >>> admin_browser.getControl(name='field.productseries').value
    'evolution/trunk'
    >>> admin_browser.getControl(name='field.distroseries').value
    ['']
    >>> admin_browser.getControl(name='field.sourcepackagename').value
    ''
    >>> admin_browser.getControl(name='field.sourcepackageversion').value
    ''
    >>> admin_browser.getControl(name='field.binarypackagename').value
    ''
    >>> admin_browser.getControl(name='field.languagepack').value
    False
    >>> admin_browser.getControl(name='field.path').value
    'po/evolution-2.2.pot'
    >>> from zope import datetime as zope_datetime
    >>> old_date_last_updated = zope_datetime.parseDatetimetz(
    ...     admin_browser.getControl('Date for last update').value)
    >>> old_date_last_updated.isoformat()
    '2005-08-25T15:27:55.264235+00:00'

And that we are able to POST it.

    >>> admin_browser.getControl('Translation domain').value = 'foo'
    >>> admin_browser.getControl('Change').click()
    >>> print admin_browser.url
    http://translations.launchpad.dev/evolution/trunk/+pots/evolution-2.2

Going back to the form we can see that the changes are saved and also,
the date when the template was last updated is now newer than previous
value.

    >>> admin_browser.getLink('Administer').click()
    >>> admin_browser.getControl('Translation domain').value
    'foo'
    >>> zope_datetime.parseDatetimetz(admin_browser.getControl(
    ...     'Date for last update').value) > old_date_last_updated
    True

We can also change the switch to note whether the template must be
exported as part of language packs.

    >>> admin_browser.getControl(name='field.languagepack').value = True
    >>> admin_browser.getControl('Change').click()

Finally, let's rename 'evolution-2.2' to 'evolution-renamed'.

    >>> admin_browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-2.2/+admin')

Lets use this opportunity to check if languagepack was changed successfully
above.

    >>> admin_browser.getControl(name='field.languagepack').value
    True

And now let's get back to renaming.

    >>> admin_browser.getControl(name='field.name').value = (
    ...     'evolution-renamed')
    >>> admin_browser.getControl('Change').click()
    >>> print admin_browser.url
    http://translations.launchpad.dev/evolution/trunk/+pots/evolution-renamed

Administrators can disable and then make changes to a disabled template.

    >>> admin_browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-renamed/+admin')
    >>> admin_browser.getControl(name='field.iscurrent').value = False
    >>> admin_browser.getControl('Change').click()
    >>> print admin_browser.url
    http://translations.launchpad.dev/evolution/trunk/+pots/evolution-renamed

Now we will reenable the template.

    >>> admin_browser.open(
    ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
    ...     'evolution-renamed/+admin')
    >>> admin_browser.getControl(name='field.iscurrent').value = True
    >>> admin_browser.getControl('Change').click()
    >>> print admin_browser.url
    http://translations.launchpad.dev/evolution/trunk/+pots/evolution-renamed


Distribution templates
----------------------

Distributions get slightly wider permissions to manage their templates
autonomously.

    >>> from lp.registry.model.distribution import Distribution
    >>> from lp.translations.model.potemplate import POTemplateSet
    >>> login('admin@canonical.com')
    >>> ubuntu = Distribution.selectOneBy(name='ubuntu')
    >>> hoary = ubuntu['hoary']
    >>> templateset = POTemplateSet()

    >>> login(ANONYMOUS)
    >>> package = factory.makeSourcePackageName()
    >>> templatesubset = templateset.getSubset(
    ...     distroseries=hoary, sourcepackagename=package)
    >>> template_owner = factory.makePerson()
    >>> template = templatesubset.new(
    ...     'foo', 'foo', 'foo.pot', template_owner)

    >>> distro_owner = factory.makePerson('do@example.com', password='test')
    >>> ubuntu.owner = distro_owner

    >>> group_owner = factory.makePerson('go@example.com', password='test')
    >>> translation_group = factory.makeTranslationGroup(group_owner)
    >>> ubuntu.translationgroup = translation_group
    >>> logout()

    >>> template_admin_url = str(
    ...     'http://translations.launchpad.dev/ubuntu/hoary/'
    ...     '+source/%s/+pots/%s/+admin' % (package.name, template.name))

A distribution's owner can manage the distribution's templates.

    >>> distro_owner_browser = setupBrowser(auth='Basic do@example.com:test')
    >>> distro_owner_browser.open(template_admin_url)
    >>> distro_owner_browser.getControl(name='field.path').value = 'bar.pot'
    >>> distro_owner_browser.getControl('Change').click()

    >>> print template.path
    bar.pot

This privilege also extends to items that require "edit" permissions.

    >>> distro_owner_browser.open(template_admin_url)
    >>> distro_owner_browser.getControl(name='field.priority').value = '321'
    >>> distro_owner_browser.getControl('Change').click()

If the distribution has a translation group assigned, the group's owners
can manage the distribution's translation templates as well.

    >>> group_owner_browser = setupBrowser(auth='Basic go@example.com:test')
    >>> group_owner_browser.open(template_admin_url)
    >>> group_owner_browser.getControl(name='field.path').value = 'splat.pot'
    >>> group_owner_browser.getControl(name='field.priority').value = '543'
    >>> group_owner_browser.getControl('Change').click()

    >>> print template.path
    splat.pot

Distribution translation coordinators can disable and manage disabled
templates.

    >>> group_owner_browser.open(template_admin_url)
    >>> group_owner_browser.getControl(name='field.iscurrent').value = False
    >>> group_owner_browser.getControl('Change').click()
    >>> group_owner_browser.open(template_admin_url)
    >>> group_owner_browser.getControl(name='field.iscurrent').value = True
    >>> group_owner_browser.getControl('Change').click()