În data de Vi, 11-12-2009 la 20:18 +0000, Guilherme Salgado a scris:
> Review: Approve
> Hi Adi,
>
> Just a couple more suggestions, but these are really trivial. Once you
> push the changes I'll submit your branch to ec2 to run the full test
> suite.
>
> Once again, thanks a lot for this improvement and the very nice cleanup!
>
> review approve
> status approved
[snip]
> In this case I think the best is to document that in the method's
> docstring (e.g. "This method must not be called if
> self.translation_group is None.") and turn the if/elif into an if/else
> with an assert, like this:
>
> if self.translation_team:
> ...
> else:
> assert self.translation_group is not None, (
> "Must not be called when there's no translation group.")
> ...
OK. Done.
> This check can go away once the if/elif is converted into an if/else
> with an assertion. The latter is preferred because it will fail
> horribly (instead of silently, like it currently does) when the property
> is used incorrectly (i.e. when translation_group is None).
Yep.
> > +
> > if not translations_person.translations_relicensing_agreement:
> > translation_license_url = PersonFormatterAPI(
> > - translations_person).url() + '/translations/+licensing'
> > - return ("To make translations in Launchpad you need to " +
> > - "agree with the " +
> > + translations_person).url(
> > + view_name='+licensing',
> > + rootsite='translations')
>
> You might not need rootsite='translations' (as this page is already on
> the translations rootsite), but I might be wrong.
I've checked the implementation for PersonFormatterAPI.url, and as far
I can understand that code, the rootsite is not automatically detected.
rootsite is required... as +licensing is not valid for main.
Also tested without rootsite and it was not created for translations.
> > +Users will see three references to the team managing these translations.
> > +
> > + >>> print user_browser.getLink(
> > + ... 'Ubuntu Spanish Translator',index=0).url
> > + http://launchpad.dev/~ubuntu-l10n-es
> > +
> > + >>> print user_browser.getLink(
> > + ... 'Ubuntu Spanish Translator',index=1).url
> > + http://launchpad.dev/~ubuntu-l10n-es
> > +
> > + >>> print user_browser.getLink(
> > + ... 'Ubuntu Spanish Translator',index=2).url
> > + http://launchpad.dev/~ubuntu-l10n-es
>
> Is it really important to show that we have 3 links to the team managing
> the translations?
Fixed.
I added new tests for checking when a translator has not agreed the
translation license and when translations are CLOSED.
Merged with devel since I modified the Factory in a branch that was just
commited and those changes also affects these tests.
@property
def access_level_description(self):
+ """Must not be called when there's no translation group."""
+
if self.user is None:
return ("You are not logged in. Please log in to work " "on translations.")
@@ -88,18 +90,13 @@
elif self.translation_group: translations_contact_link = PersonFormatterAPI( self.translation_group.owner).link(None)
-
- if translations_contact_link is None:
- #Having no translation group is a valid case, but the
- #template should not call access_level_description for
- #this condition.
- #We return a blank screen since the information about
- #missing group is displaying in a different section
- return ""
+ else:
+ assert self.translation_group is not None, (
+ "Must not be called when there's no translation
group.")
if not translations_person.translations_relicensing_agreement: translation_license_url = PersonFormatterAPI(
- translations_person).url(
+ self.user).url( view_name='+licensing', rootsite='translations')
return ("To make translations in Launchpad you need to "
@@ -123,7 +120,7 @@ permission = sample_pofile.translationpermission
if permission == TranslationPermission.CLOSED: return ("These templates can be translated only by "
- "its managers.")
+ "their managers.")
if self.translation_team is None:
return ("Since there is nobody to manage translation "
Spanish has a translation team for managing its translations and all
@@ -100,15 +103,7 @@
Users will see three references to the team managing these
translations.
Catalan has no translation team for managing translations and since
@@ -133,10 +128,7 @@
translations, please contact Ubuntu Translation Coordinators...
Members of translation team and translations admins have full access to
@@ -148,9 +140,44 @@
... admin_browser.contents, 'translation-access-level'))
You can add and review translations...
-
-For project with no translation teams, translators see a note stating
-there is no group. No access level information is displayed in this
case.
+For projects using closed translations policy, a translator that is not
+member of the translation team appointed for that language will not
+be allowed to make any changes.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.translationpermission = TranslationPermission.CLOSED
+ >>> logout()
+
+ >>> user_browser.open(
+ ... 'http://translations.launchpad.dev/ubuntu/hoary/+lang/ro')
+ >>> print extract_text(find_tag_by_id(
+ ... user_browser.contents, 'translation-access-level'))
+ These templates can be translated only by their managers...
+
+Translation policy is rolled back to not affect other tests.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.translationpermission = TranslationPermission.RESTRICTED
+ >>> logout()
+
+Translators that have not agreed with the license can not make
+translations, and will see a link to the license page.
+
+ >>> no_license_browser = setupBrowser(
+ ... auth='Basic <email address hidden>:test')
+ >>> no_license_browser.open(
+ ... 'http://translations.launchpad.dev/ubuntu/hoary/+lang/ro')
+ >>> print extract_text(find_tag_by_id(
+ ... no_license_browser.contents, 'translation-access-level'))
+ To make translations in Launchpad you need to agree with
+ the Translations licensing...
+
+ >>> print no_license_browser.getLink(
+ ... 'Translations licensing').url
+ http://translations.launchpad.dev/~dude/+licensing
+
+For project with no translation group, translators see a note stating
+this fact. No access level information is displayed.
>>> login('<email address hidden>')
>>> ubuntu.translationgroup = None
@@ -166,4 +193,10 @@
... user_browser.contents, 'translation-access-level'))
Templates which are more important to translate are listed first.
+Translation group configuration is rolled back to not affect other
tests.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.translationgroup = utg
+ >>> logout()
+
The details of the page are tested at the view level.
În data de Vi, 11-12-2009 la 20:18 +0000, Guilherme Salgado a scris: n_group is None.") and turn the if/elif into an if/else n_team: n_group is not None, (
> Review: Approve
> Hi Adi,
>
> Just a couple more suggestions, but these are really trivial. Once you
> push the changes I'll submit your branch to ec2 to run the full test
> suite.
>
> Once again, thanks a lot for this improvement and the very nice cleanup!
>
> review approve
> status approved
[snip]
> In this case I think the best is to document that in the method's
> docstring (e.g. "This method must not be called if
> self.translatio
> with an assert, like this:
>
> if self.translatio
> ...
> else:
> assert self.translatio
> "Must not be called when there's no translation group.")
> ...
OK. Done.
> This check can go away once the if/elif is converted into an if/else
> with an assertion. The latter is preferred because it will fail
> horribly (instead of silently, like it currently does) when the property
> is used incorrectly (i.e. when translation_group is None).
Yep.
> > + person. translations_ relicensing_ agreement: license_ url = PersonFormatterAPI( person) .url() + '/translations/ +licensing' person) .url( '+licensing' , 'translations' ) 'translations' (as this page is already on API.url, and as far
> > if not translations_
> > translation_
> > - translations_
> > - return ("To make translations in Launchpad you need to " +
> > - "agree with the " +
> > + translations_
> > + view_name=
> > + rootsite=
>
> You might not need rootsite=
> the translations rootsite), but I might be wrong.
I've checked the implementation for PersonFormatter
I can understand that code, the rootsite is not automatically detected.
rootsite is required... as +licensing is not valid for main.
Also tested without rootsite and it was not created for translations.
> > +Users will see three references to the team managing these translations. getLink( ,index= 0).url launchpad. dev/~ubuntu- l10n-es getLink( ,index= 1).url launchpad. dev/~ubuntu- l10n-es getLink( ,index= 2).url launchpad. dev/~ubuntu- l10n-es
> > +
> > + >>> print user_browser.
> > + ... 'Ubuntu Spanish Translator'
> > + http://
> > +
> > + >>> print user_browser.
> > + ... 'Ubuntu Spanish Translator'
> > + http://
> > +
> > + >>> print user_browser.
> > + ... 'Ubuntu Spanish Translator'
> > + http://
>
> Is it really important to show that we have 3 links to the team managing
> the translations?
Fixed.
I added new tests for checking when a translator has not agreed the
translation license and when translations are CLOSED.
Merged with devel since I modified the Factory in a branch that was just
commited and those changes also affects these tests.
Cheers.
Here is the diff.
=== modified file 'lib/lp/ translations/ browser/ serieslanguage. py' translations/ browser/ serieslanguage. py 2009-12-11 20:11:06 translations/ browser/ serieslanguage. py 2009-12-12 06:19:24
--- lib/lp/
+0000
+++ lib/lp/
+0000
@@ -75,6 +75,8 @@
@property level_descripti on(self) :
"on translations.") n_group:
translati ons_contact_ link = PersonFormatterAPI(
self. translation_ group.owner) .link(None) contact_ link is None: level_descripti on for n_group is not None, (
def access_
+ """Must not be called when there's no translation group."""
+
if self.user is None:
return ("You are not logged in. Please log in to work "
@@ -88,18 +90,13 @@
elif self.translatio
-
- if translations_
- #Having no translation group is a valid case, but the
- #template should not call access_
- #this condition.
- #We return a blank screen since the information about
- #missing group is displaying in a different section
- return ""
+ else:
+ assert self.translatio
+ "Must not be called when there's no translation
group.")
if not translations_ person. translations_ relicensing_ agreement:
translati on_license_ url = PersonFormatterAPI( person) .url(
view_name= '+licensing' ,
rootsite= 'translations' )
permissio n = sample_ pofile. translationperm ission ission. CLOSED:
return ("These templates can be translated only by "
- translations_
+ self.user).url(
return ("To make translations in Launchpad you need to "
@@ -123,7 +120,7 @@
if permission == TranslationPerm
- "its managers.")
+ "their managers.")
if self.translatio n_team is None:
return ("Since there is nobody to manage translation "
=== modified file translations/ stories/ standalone/ xx-serieslangua ge-index. txt' translations/ stories/ standalone/ xx-serieslangua ge-index. txt translations/ stories/ standalone/ xx-serieslangua ge-index. txt l10n-es" , ILaunchpadCeleb rities) .ubuntu translationgrou p = utg translationperm ission = TranslationPerm ission. RESTRICTED makeTranslator( st_coordinator) translator = factory. makeTranslator(
'lib/lp/
--- lib/lp/
2009-12-11 20:11:06 +0000
+++ lib/lp/
2009-12-12 06:49:16 +0000
@@ -65,12 +65,15 @@
>>> st_coordinator = factory.makePerson(
... name="ubuntu-
... displayname='Ubuntu Spanish Translators')
-
+ >>> dude = factory.makePerson(
+ ... name="dude", <email address hidden>", password="test")
>>> ubuntu = getUtility(
>>> ubuntu.
>>> ubuntu.
>>> translators = factory.
... 'es', group=utg, person=
+ >>> no_license_
+ ... 'es', person=dude, license=False)
>>> logout()
Spanish has a translation team for managing its translations and all
@@ -100,15 +103,7 @@
Users will see three references to the team managing these
translations.
>>> print user_browser. getLink( ,index= 0).url launchpad. dev/~ubuntu- l10n-es getLink( ,index= 1).url launchpad. dev/~ubuntu- l10n-es getLink( ,index= 2).url launchpad. dev/~ubuntu- l10n-es
- ... 'Ubuntu Spanish Translator'
- http://
-
- >>> print user_browser.
- ... 'Ubuntu Spanish Translator'
- http://
-
- >>> print user_browser.
- ... 'Ubuntu Spanish Translator'
+ ... 'Ubuntu Spanish Translator').url
http://
Catalan has no translation team for managing translations and since
@@ -133,10 +128,7 @@
translations, please contact Ubuntu Translation Coordinators...
>>> print user_browser. getLink( ,index= 0).url launchpad. dev/~utc- team getLink( ,index= 1).url launchpad. dev/~utc- team
- ... 'Ubuntu Translation Coordinators'
- http://
- >>> print user_browser.
- ... 'Ubuntu Translation Coordinators'
+ ... 'Ubuntu Translation Coordinators').url
http://
Members of translation team and translations admins have full access to contents, 'translation- access- level') )
@@ -148,9 +140,44 @@
... admin_browser.
You can add and review translations...
- translationperm ission = TranslationPerm ission. CLOSED translations. launchpad. dev/ubuntu/ hoary/+ lang/ro') text(find_ tag_by_ id( contents, 'translation- access- level') ) translationperm ission = TranslationPerm ission. RESTRICTED browser. open( translations. launchpad. dev/ubuntu/ hoary/+ lang/ro') text(find_ tag_by_ id( browser. contents, 'translation- access- level') ) browser. getLink( translations. launchpad. dev/~dude/ +licensing
-For project with no translation teams, translators see a note stating
-there is no group. No access level information is displayed in this
case.
+For projects using closed translations policy, a translator that is not
+member of the translation team appointed for that language will not
+be allowed to make any changes.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.
+ >>> logout()
+
+ >>> user_browser.open(
+ ... 'http://
+ >>> print extract_
+ ... user_browser.
+ These templates can be translated only by their managers...
+
+Translation policy is rolled back to not affect other tests.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.
+ >>> logout()
+
+Translators that have not agreed with the license can not make
+translations, and will see a link to the license page.
+
+ >>> no_license_browser = setupBrowser(
+ ... auth='Basic <email address hidden>:test')
+ >>> no_license_
+ ... 'http://
+ >>> print extract_
+ ... no_license_
+ To make translations in Launchpad you need to agree with
+ the Translations licensing...
+
+ >>> print no_license_
+ ... 'Translations licensing').url
+ http://
+
+For project with no translation group, translators see a note stating
+this fact. No access level information is displayed.
>>> login('<email address hidden>') translationgrou p = None contents, 'translation- access- level') )
>>> ubuntu.
@@ -166,4 +193,10 @@
... user_browser.
Templates which are more important to translate are listed first.
+Translation group configuration is rolled back to not affect other translationgrou p = utg
tests.
+
+ >>> login('<email address hidden>')
+ >>> ubuntu.
+ >>> logout()
+
The details of the page are tested at the view level.
--
Adi Roiban