Merge lp:~jtv/launchpad/enum-translationpermission into lp:launchpad

Proposed by Jeroen T. Vermeulen on 2010-11-05
Status: Merged
Approved by: Jeroen T. Vermeulen on 2010-11-05
Approved revision: no longer in the source branch.
Merged at revision: 11873
Proposed branch: lp:~jtv/launchpad/enum-translationpermission
Merge into: lp:launchpad
Diff against target: 377 lines (+72/-80)
17 files modified
lib/lp/registry/model/distribution.py (+1/-1)
lib/lp/registry/model/product.py (+1/-1)
lib/lp/registry/model/projectgroup.py (+2/-2)
lib/lp/translations/browser/serieslanguage.py (+1/-1)
lib/lp/translations/browser/tests/translationmessage-views.txt (+1/-2)
lib/lp/translations/doc/pofile.txt (+2/-1)
lib/lp/translations/doc/rosetta-poimport-script.txt (+1/-2)
lib/lp/translations/doc/translationgroup.txt (+1/-2)
lib/lp/translations/doc/translationmessage.txt (+1/-2)
lib/lp/translations/enums.py (+50/-0)
lib/lp/translations/interfaces/pofile.py (+1/-1)
lib/lp/translations/interfaces/translationgroup.py (+1/-54)
lib/lp/translations/model/pofile.py (+4/-2)
lib/lp/translations/model/translationsperson.py (+2/-4)
lib/lp/translations/stories/standalone/xx-serieslanguage-index.txt (+1/-2)
lib/lp/translations/stories/standalone/xx-translation-access-display.txt (+1/-2)
lib/lp/translations/utilities/tests/test_file_importer.py (+1/-1)
To merge this branch: bzr merge lp:~jtv/launchpad/enum-translationpermission
Reviewer Review Type Date Requested Status
Abel Deuring (community) code 2010-11-05 Approve on 2010-11-05
Review via email: mp+40192@code.launchpad.net

Commit Message

Move TranslationPermission into enums.

Description of the Change

= Moving TranslationPermission into enums =

We just added an enums.py to Translations. This branch moves one of our enums in there, hopefully reducing the pressure towards circular imports a bit.

The only way to be sure that I got it all right is to run all tests, which should be just what EC2 is doing for me right now.

Jeroen

To post a comment you must log in.
Abel Deuring (adeuring) wrote :

looks good

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/model/distribution.py'
2--- lib/lp/registry/model/distribution.py 2010-11-02 20:10:56 +0000
3+++ lib/lp/registry/model/distribution.py 2010-11-05 15:25:01 +0000
4@@ -188,7 +188,7 @@
5 SourcePackagePublishingHistory,
6 )
7 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
8-from lp.translations.interfaces.translationgroup import TranslationPermission
9+from lp.translations.enums import TranslationPermission
10 from lp.translations.model.hastranslationimports import (
11 HasTranslationImportsMixin,
12 )
13
14=== modified file 'lib/lp/registry/model/product.py'
15--- lib/lp/registry/model/product.py 2010-11-02 20:10:56 +0000
16+++ lib/lp/registry/model/product.py 2010-11-05 15:25:01 +0000
17@@ -161,10 +161,10 @@
18 cachedproperty,
19 get_property_cache,
20 )
21+from lp.translations.enums import TranslationPermission
22 from lp.translations.interfaces.customlanguagecode import (
23 IHasCustomLanguageCodes,
24 )
25-from lp.translations.interfaces.translationgroup import TranslationPermission
26 from lp.translations.model.customlanguagecode import (
27 CustomLanguageCode,
28 HasCustomLanguageCodesMixin,
29
30=== modified file 'lib/lp/registry/model/projectgroup.py'
31--- lib/lp/registry/model/projectgroup.py 2010-11-02 20:10:56 +0000
32+++ lib/lp/registry/model/projectgroup.py 2010-11-05 15:25:01 +0000
33@@ -104,7 +104,7 @@
34 StructuralSubscriptionTargetMixin,
35 )
36 from lp.services.worlddata.model.language import Language
37-from lp.translations.interfaces.translationgroup import TranslationPermission
38+from lp.translations.enums import TranslationPermission
39
40
41 class ProjectGroup(SQLBase, BugTargetBase, HasSpecificationsMixin,
42@@ -175,7 +175,7 @@
43 def getConfigurableProducts(self):
44 return [product for product in self.products
45 if check_permission('launchpad.Edit', product)]
46-
47+
48 @property
49 def drivers(self):
50 """See `IHasDrivers`."""
51
52=== modified file 'lib/lp/translations/browser/serieslanguage.py'
53--- lib/lp/translations/browser/serieslanguage.py 2010-09-27 16:49:22 +0000
54+++ lib/lp/translations/browser/serieslanguage.py 2010-11-05 15:25:01 +0000
55@@ -18,13 +18,13 @@
56 from canonical.launchpad.webapp.publisher import Navigation
57 from lp.app.browser.tales import PersonFormatterAPI
58 from lp.services.propertycache import cachedproperty
59+from lp.translations.enums import TranslationPermission
60 from lp.translations.interfaces.distroserieslanguage import (
61 IDistroSeriesLanguage,
62 )
63 from lp.translations.interfaces.productserieslanguage import (
64 IProductSeriesLanguage,
65 )
66-from lp.translations.interfaces.translationgroup import TranslationPermission
67 from lp.translations.interfaces.translationsperson import ITranslationsPerson
68
69
70
71=== modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt'
72--- lib/lp/translations/browser/tests/translationmessage-views.txt 2010-10-27 20:53:18 +0000
73+++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-11-05 15:25:01 +0000
74@@ -684,8 +684,7 @@
75
76 We need to force timestamp update, since suggestions are submitted too fast.
77
78- >>> from lp.translations.interfaces.translationgroup import (
79- ... TranslationPermission)
80+ >>> from lp.translations.enums import TranslationPermission
81 >>> pofile = factory.makePOFile('es')
82 >>> potemplate = pofile.potemplate
83 >>> potmsgset = factory.makePOTMsgSet(potemplate, sequence=1)
84
85=== modified file 'lib/lp/translations/doc/pofile.txt'
86--- lib/lp/translations/doc/pofile.txt 2010-10-18 22:24:59 +0000
87+++ lib/lp/translations/doc/pofile.txt 2010-11-05 15:25:01 +0000
88@@ -393,8 +393,9 @@
89 >>> from canonical.launchpad.interfaces.launchpad import (
90 ... ILaunchpadCelebrities)
91 >>> from lp.registry.interfaces.product import IProductSet
92+ >>> from lp.translations.enums import TranslationPermission
93 >>> from lp.translations.interfaces.translationgroup import (
94- ... ITranslationGroupSet, TranslationPermission)
95+ ... ITranslationGroupSet)
96 >>> from canonical.launchpad.ftests import login
97 >>> from lp.translations.model.pofile import POFile
98 >>> person_set = getUtility(IPersonSet)
99
100=== modified file 'lib/lp/translations/doc/rosetta-poimport-script.txt'
101--- lib/lp/translations/doc/rosetta-poimport-script.txt 2010-10-29 05:58:51 +0000
102+++ lib/lp/translations/doc/rosetta-poimport-script.txt 2010-11-05 15:25:01 +0000
103@@ -57,8 +57,7 @@
104 enough (but we could go with "open" as well, which would allow not
105 only suggestions but full translations as well).
106
107- >>> from lp.translations.interfaces.translationgroup import (
108- ... TranslationPermission)
109+ >>> from lp.translations.enums import TranslationPermission
110 >>> product = pofile.potemplate.productseries.product
111 >>> product.translationpermission = TranslationPermission.STRUCTURED
112
113
114=== modified file 'lib/lp/translations/doc/translationgroup.txt'
115--- lib/lp/translations/doc/translationgroup.txt 2010-10-03 15:30:06 +0000
116+++ lib/lp/translations/doc/translationgroup.txt 2010-11-05 15:25:01 +0000
117@@ -58,8 +58,7 @@
118
119 Let's only allow translators from that group to translate.
120
121- >>> from lp.translations.interfaces.translationgroup import (
122- ... TranslationPermission)
123+ >>> from lp.translations.enums import TranslationPermission
124 >>> evolution.translationpermission = TranslationPermission.CLOSED
125
126 No Privileges Person isn't allowed to translate into Welsh.
127
128=== modified file 'lib/lp/translations/doc/translationmessage.txt'
129--- lib/lp/translations/doc/translationmessage.txt 2010-10-28 03:55:41 +0000
130+++ lib/lp/translations/doc/translationmessage.txt 2010-11-05 15:25:01 +0000
131@@ -112,8 +112,7 @@
132 >>> product = productseries.product
133 >>> product.translationgroup = factory.makeTranslationGroup(product.owner)
134
135- >>> from lp.translations.interfaces.translationgroup import (
136- ... TranslationPermission)
137+ >>> from lp.translations.enums import TranslationPermission
138 >>> product.translationpermission = TranslationPermission.STRUCTURED
139
140 The only Serbian reviewer in this translation group is 'name16' user.
141
142=== modified file 'lib/lp/translations/enums.py'
143--- lib/lp/translations/enums.py 2010-10-29 05:58:51 +0000
144+++ lib/lp/translations/enums.py 2010-11-05 15:25:01 +0000
145@@ -6,6 +6,7 @@
146 __metaclass__ = type
147 __all__ = [
148 'RosettaImportStatus',
149+ 'TranslationPermission',
150 ]
151
152 from lazr.enum import (
153@@ -65,3 +66,52 @@
154
155 The reviewer needs more information before this entry can be approved.
156 """)
157+
158+
159+class TranslationPermission(DBEnumeratedType):
160+ """Translation Permission System
161+
162+ Projects groups, products and distributions can all have content that
163+ needs to be translated. In this case, Launchpad Translations allows them
164+ to decide how open they want that translation process to be. At one
165+ extreme, anybody can add or edit any translation, without review. At the
166+ other, only the designated translator for that group in that language can
167+ add or edit its translation files. This schema enumerates the options.
168+ """
169+
170+ OPEN = DBItem(1, """
171+ Open
172+
173+ This group allows totally open access to its translations. Any
174+ logged-in user can add or edit translations in any language, without
175+ any review.""")
176+
177+ STRUCTURED = DBItem(20, """
178+ Structured
179+
180+ This group has designated translators for certain languages. In
181+ those languages, people who are not designated translators can only
182+ make suggestions. However, in languages which do not yet have a
183+ designated translator, anybody can edit the translations directly,
184+ with no further review.""")
185+
186+ RESTRICTED = DBItem(100, """
187+ Restricted
188+
189+ This group allows only designated translators to edit the
190+ translations of its files. You can become a designated translator
191+ either by joining an existing language translation team for this
192+ project, or by getting permission to start a new team for a new
193+ language. People who are not designated translators can still make
194+ suggestions for new translations, but those suggestions need to be
195+ reviewed before being accepted by the designated translator.""")
196+
197+ CLOSED = DBItem(200, """
198+ Closed
199+
200+ This group allows only designated translators to edit or add
201+ translations. You can become a designated translator either by
202+ joining an existing language translation team for this
203+ project, or by getting permission to start a new team for a new
204+ language. People who are not designated translators will not be able
205+ to add suggestions.""")
206
207=== modified file 'lib/lp/translations/interfaces/pofile.py'
208--- lib/lp/translations/interfaces/pofile.py 2010-09-01 16:04:16 +0000
209+++ lib/lp/translations/interfaces/pofile.py 2010-11-05 15:25:01 +0000
210@@ -42,9 +42,9 @@
211 from canonical.launchpad import _
212 from canonical.launchpad.webapp.interfaces import ILaunchBag
213 from lp.registry.interfaces.person import IPerson
214+from lp.translations.enums import TranslationPermission
215 from lp.translations.interfaces.potemplate import IPOTemplate
216 from lp.translations.interfaces.rosettastats import IRosettaStats
217-from lp.translations.interfaces.translationgroup import TranslationPermission
218 from lp.translations.interfaces.translationsperson import ITranslationsPerson
219
220
221
222=== modified file 'lib/lp/translations/interfaces/translationgroup.py'
223--- lib/lp/translations/interfaces/translationgroup.py 2010-09-03 06:37:26 +0000
224+++ lib/lp/translations/interfaces/translationgroup.py 2010-11-05 15:25:01 +0000
225@@ -11,13 +11,8 @@
226 'ITranslationPolicy',
227 'ITranslationGroup',
228 'ITranslationGroupSet',
229- 'TranslationPermission',
230 ]
231
232-from lazr.enum import (
233- DBEnumeratedType,
234- DBItem,
235- )
236 from zope.interface import (
237 Attribute,
238 Interface,
239@@ -38,55 +33,7 @@
240 Title,
241 URIField,
242 )
243-
244-
245-class TranslationPermission(DBEnumeratedType):
246- """Translation Permission System
247-
248- Projects groups, products and distributions can all have content that
249- needs to be translated. In this case, Launchpad Translations allows them
250- to decide how open they want that translation process to be. At one
251- extreme, anybody can add or edit any translation, without review. At the
252- other, only the designated translator for that group in that language can
253- add or edit its translation files. This schema enumerates the options.
254- """
255-
256- OPEN = DBItem(1, """
257- Open
258-
259- This group allows totally open access to its translations. Any
260- logged-in user can add or edit translations in any language, without
261- any review.""")
262-
263- STRUCTURED = DBItem(20, """
264- Structured
265-
266- This group has designated translators for certain languages. In
267- those languages, people who are not designated translators can only
268- make suggestions. However, in languages which do not yet have a
269- designated translator, anybody can edit the translations directly,
270- with no further review.""")
271-
272- RESTRICTED = DBItem(100, """
273- Restricted
274-
275- This group allows only designated translators to edit the
276- translations of its files. You can become a designated translator
277- either by joining an existing language translation team for this
278- project, or by getting permission to start a new team for a new
279- language. People who are not designated translators can still make
280- suggestions for new translations, but those suggestions need to be
281- reviewed before being accepted by the designated translator.""")
282-
283- CLOSED = DBItem(200, """
284- Closed
285-
286- This group allows only designated translators to edit or add
287- translations. You can become a designated translator either by
288- joining an existing language translation team for this
289- project, or by getting permission to start a new team for a new
290- language. People who are not designated translators will not be able
291- to add suggestions.""")
292+from lp.translations.enums import TranslationPermission
293
294
295 class ITranslationPolicy(Interface):
296
297=== modified file 'lib/lp/translations/model/pofile.py'
298--- lib/lp/translations/model/pofile.py 2010-10-29 10:17:14 +0000
299+++ lib/lp/translations/model/pofile.py 2010-11-05 15:25:01 +0000
300@@ -70,7 +70,10 @@
301 from lp.registry.interfaces.person import validate_public_person
302 from lp.registry.model.person import Person
303 from lp.services.propertycache import cachedproperty
304-from lp.translations.enums import RosettaImportStatus
305+from lp.translations.enums import (
306+ RosettaImportStatus,
307+ TranslationPermission,
308+ )
309 from lp.translations.interfaces.pofile import (
310 IPOFile,
311 IPOFileSet,
312@@ -85,7 +88,6 @@
313 from lp.translations.interfaces.translationexporter import (
314 ITranslationExporter,
315 )
316-from lp.translations.interfaces.translationgroup import TranslationPermission
317 from lp.translations.interfaces.translationimporter import (
318 ITranslationImporter,
319 NotExportedFromLaunchpad,
320
321=== modified file 'lib/lp/translations/model/translationsperson.py'
322--- lib/lp/translations/model/translationsperson.py 2010-08-31 23:03:45 +0000
323+++ lib/lp/translations/model/translationsperson.py 2010-11-05 15:25:01 +0000
324@@ -32,10 +32,8 @@
325 from lp.registry.model.projectgroup import ProjectGroup
326 from lp.registry.model.teammembership import TeamParticipation
327 from lp.services.worlddata.model.language import Language
328-from lp.translations.interfaces.translationgroup import (
329- ITranslationGroupSet,
330- TranslationPermission,
331- )
332+from lp.translations.enums import TranslationPermission
333+from lp.translations.interfaces.translationgroup import ITranslationGroupSet
334 from lp.translations.interfaces.translationsperson import ITranslationsPerson
335 from lp.translations.interfaces.translator import ITranslatorSet
336 from lp.translations.model.pofile import POFile
337
338=== modified file 'lib/lp/translations/stories/standalone/xx-serieslanguage-index.txt'
339--- lib/lp/translations/stories/standalone/xx-serieslanguage-index.txt 2010-10-03 15:30:06 +0000
340+++ lib/lp/translations/stories/standalone/xx-serieslanguage-index.txt 2010-11-05 15:25:01 +0000
341@@ -54,8 +54,7 @@
342 >>> from zope.component import getUtility
343 >>> from canonical.launchpad.interfaces.launchpad import (
344 ... ILaunchpadCelebrities)
345- >>> from lp.translations.interfaces.translationgroup import (
346- ... TranslationPermission)
347+ >>> from lp.translations.enums import TranslationPermission
348 >>> login('foo.bar@canonical.com')
349 >>> utc_owner = factory.makePerson(displayname='Some Guy')
350 >>> utc_team = factory.makeTeam(
351
352=== modified file 'lib/lp/translations/stories/standalone/xx-translation-access-display.txt'
353--- lib/lp/translations/stories/standalone/xx-translation-access-display.txt 2010-10-18 22:24:59 +0000
354+++ lib/lp/translations/stories/standalone/xx-translation-access-display.txt 2010-11-05 15:25:01 +0000
355@@ -126,8 +126,7 @@
356 If Evolution's translation is set to Closed mode, Joe will not be able
357 to submit suggestions.
358
359- >>> from lp.translations.interfaces.translationgroup import (
360- ... TranslationPermission)
361+ >>> from lp.translations.enums import TranslationPermission
362 >>> evolution.translationpermission = TranslationPermission.CLOSED
363 >>> user_browser.open(
364 ... 'http://translations.launchpad.dev/'
365
366=== modified file 'lib/lp/translations/utilities/tests/test_file_importer.py'
367--- lib/lp/translations/utilities/tests/test_file_importer.py 2010-10-04 20:46:55 +0000
368+++ lib/lp/translations/utilities/tests/test_file_importer.py 2010-11-05 15:25:01 +0000
369@@ -12,7 +12,7 @@
370 from canonical.testing.layers import ZopelessDatabaseLayer
371 from lp.registry.interfaces.person import IPersonSet
372 from lp.testing import TestCaseWithFactory
373-from lp.translations.interfaces.translationgroup import TranslationPermission
374+from lp.translations.enums import TranslationPermission
375 from lp.translations.interfaces.translationimporter import (
376 OutdatedTranslationError,
377 )