Hi, Don't worry about the communication problem ... be happy :) I have opened a new bug for TAL expression used for raising an exception. I have merged the tests for translation permissions. Here is the diff. Thanks! === modified file 'lib/lp/registry/browser/distroseries.py' --- lib/lp/registry/browser/distroseries.py 2010-02-17 13:06:35 +0000 +++ lib/lp/registry/browser/distroseries.py 2010-02-24 14:57:59 +0000 @@ -37,10 +37,8 @@ from lp.services.worlddata.interfaces.country import ICountry from lp.registry.interfaces.series import SeriesStatus from lp.registry.interfaces.distroseries import IDistroSeries -from lp.translations.browser.browser_helpers import ( +from lp.translations.browser.distroseries import ( check_distroseries_translations_viewable) -from lp.translations.interfaces.distroserieslanguage import ( - IDistroSeriesLanguageSet) from lp.services.worlddata.interfaces.language import ILanguageSet from lp.registry.browser.structuralsubscription import ( StructuralSubscriptionMenuMixin, @@ -81,19 +79,12 @@ except IndexError: # Unknown language code. raise NotFoundError - distroserieslang = self.context.getDistroSeriesLanguage(lang) - if distroserieslang is None: - # There is no IDistroSeriesLanguage yet for this IDistroSeries, - # but we still need to list it as an available language, so we - # generate a dummy one so users have a chance to get to it in the - # navigation and start adding translations for it. - distroserieslangset = getUtility(IDistroSeriesLanguageSet) - distroserieslang = distroserieslangset.getDummy( - self.context, lang) + distroserieslang = self.context.getDistroSeriesLanguageOrDummy(lang) # Check if user is able to view the translations for - # this distribution series + # this distribution series language. + # If not, raise TranslationUnavailable. check_distroseries_translations_viewable(self.context) return distroserieslang === modified file 'lib/lp/registry/browser/sourcepackage.py' --- lib/lp/registry/browser/sourcepackage.py 2010-02-17 13:06:35 +0000 +++ lib/lp/registry/browser/sourcepackage.py 2010-02-24 14:55:26 +0000 @@ -40,7 +40,7 @@ from lp.registry.interfaces.packaging import IPackaging from lp.registry.interfaces.pocket import PackagePublishingPocket from lp.registry.interfaces.sourcepackage import ISourcePackage -from lp.translations.browser.browser_helpers import ( +from lp.translations.browser.distroseries import ( check_distroseries_translations_viewable) from lp.translations.interfaces.potemplate import IPOTemplateSet from canonical.launchpad import _ @@ -68,7 +68,8 @@ # If we are able to view the translations for distribution series # we should also be allowed to see them for a distribution - # source package + # source package. + # If not, raise TranslationUnavailable. check_distroseries_translations_viewable(self.context.distroseries) return sourcepackage_pots === modified file 'lib/lp/registry/doc/distroseries.txt' --- lib/lp/registry/doc/distroseries.txt 2010-01-21 14:53:29 +0000 +++ lib/lp/registry/doc/distroseries.txt 2010-02-18 18:56:44 +0000 @@ -1,4 +1,5 @@ -= DistroSeries = +DistroSeries +============ From the DerivationOverview spec : @@ -200,7 +201,8 @@ True -== Package searching == +Package searching +----------------- You can search through binary packages publishing in a distribution release by using the searchPackages method, which uses magical fti: @@ -223,7 +225,8 @@ DistroSeriesBinaryPackage: at -== DistroSeriess have components and sections == +DistroSeriess have components and sections +------------------------------------------ A distroseries has some number of components and/or sections which are valid for that distroseries. These selections are used by (among @@ -286,7 +289,8 @@ partner -== DistroSeries can be initialised from their parents == +DistroSeries can be initialised from their parents +-------------------------------------------------- When a distroseries is derived from another distroseries (be it a derivative distribution, or simply the next release in a sequence from @@ -396,74 +400,8 @@ netapplet -Hiding translations -------------------- - -The hide_all_translations flag, if set, hides a distroseries' -translations in the user interface. The check for visibility happens in -checkTranslationsViewable. - - >>> untranslatable_series = factory.makeDistroRelease() - >>> untranslatable_series.hide_all_translations = False - -When translations are visible, checkTranslationsViewable() completes -normally. - - >>> from canonical.launchpad.webapp.interfaces import ( - ... TranslationUnavailable) - >>> def get_visibility_notice(series): - ... """Print the notice about series' translations being hidden.""" - ... try: - ... series.checkTranslationsViewable() - ... except TranslationUnavailable, e: - ... return str(e) - ... return None - - >>> print get_visibility_notice(untranslatable_series) - None - -But when translations are hidden, it raises TranslationUnavailable. - - >>> untranslatable_series.hide_all_translations = True - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series... - -Exactly what message is displayed depends on the series' status. - - >>> untranslatable_series.status = SeriesStatus.EXPERIMENTAL - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not available yet. - - >>> untranslatable_series.status = SeriesStatus.DEVELOPMENT - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not available yet. - - >>> untranslatable_series.status = SeriesStatus.FROZEN - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not currently available. - Please come back soon. - - >>> untranslatable_series.status = SeriesStatus.CURRENT - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not currently available. - Please come back soon. - - >>> untranslatable_series.status = SeriesStatus.SUPPORTED - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not currently available. - Please come back soon. - - >>> untranslatable_series.status = SeriesStatus.OBSOLETE - >>> print get_visibility_notice(untranslatable_series) - This release series is obsolete. Its translations are no longer - available. - - >>> untranslatable_series.status = SeriesStatus.FUTURE - >>> print get_visibility_notice(untranslatable_series) - Translations for this release series are not available yet. - - -== Translatable Packages and Packaging == +Translatable Packages and Packaging +----------------------------------- You can easily find out what packages are translatable in a distribution release: @@ -637,7 +575,8 @@ True -== SourcePackagePublishingHistory == +SourcePackagePublishingHistory +------------------------------ IDistroSeries.getSourcePackagePublishing returns all the ISPPH records for a given status in a given pocket. It makes easy to @@ -1011,7 +950,8 @@ thinclient-local-devices -= Drivers = +Drivers +======= Distributions have drivers, who are people that have permission to approve bugs and features for specific releases. The rules are that: @@ -1093,7 +1033,8 @@ mark -== Lastest Uploads == +Lastest Uploads +--------------- IDistroSeries provides the 'getLatestUpload' method which returns a list of the last 5 (five) IDistroSeriesSourcePackageRelease (IDRSPR) @@ -1119,7 +1060,8 @@ 0 -== Getting build records for a distro series == +Getting build records for a distro series +----------------------------------------- IDistroSeries inherits the IHasBuildRecords interfaces and therefore provides a getBuildRecords() method. === modified file 'lib/lp/translations/browser/browser_helpers.py' --- lib/lp/translations/browser/browser_helpers.py 2010-02-17 13:06:35 +0000 +++ lib/lp/translations/browser/browser_helpers.py 2010-02-24 14:57:39 +0000 @@ -6,7 +6,6 @@ __metaclass__ = type __all__ = [ - 'check_distroseries_translations_viewable', 'contract_rosetta_escapes', 'convert_newlines_to_web_form', 'count_lines', @@ -20,9 +19,6 @@ from xml.sax.saxutils import escape as xml_escape from canonical.launchpad import helpers -from canonical.launchpad.webapp.authorization import check_permission -from canonical.launchpad.webapp.interfaces import TranslationUnavailable -from lp.registry.interfaces.series import SeriesStatus from lp.translations.interfaces.translations import TranslationConstants @@ -191,47 +187,3 @@ raise UnrecognisedCFormatString(string) return segments - - -def check_distroseries_translations_viewable(distroseries): - """Check that these distribution series translations are visible. - - Launchpad admins, Translations admins, and users with admin - rights on the `IDistroSeries` are always allowed. - - Checks the `hide_all_translations` flag. If it is set, these - translations are not to be shown to the public. In that case an - appropriate message is composed based on the series' `status`, - and a `TranslationUnavailable` exception is raised. - - :return: Returns normally if this series' translations are - viewable to the current user. - :raise TranslationUnavailable: if this series' translations are - hidden and the user is not one of the limited caste that is - allowed to access them. - """ - - if not distroseries.hide_all_translations: - # Yup, viewable. - return - - if check_permission( - 'launchpad.TranslationsAdmin', distroseries): - return - - future = [ - SeriesStatus.EXPERIMENTAL, - SeriesStatus.DEVELOPMENT, - SeriesStatus.FUTURE, - ] - if distroseries.status in future: - raise TranslationUnavailable( - "Translations for this release series are not available yet.") - elif distroseries.status == SeriesStatus.OBSOLETE: - raise TranslationUnavailable( - "This release series is obsolete. Its translations are no " - "longer available.") - else: - raise TranslationUnavailable( - "Translations for this release series are not currently " - "available. Please come back soon.") === modified file 'lib/lp/translations/browser/distroseries.py' --- lib/lp/translations/browser/distroseries.py 2010-02-17 13:06:35 +0000 +++ lib/lp/translations/browser/distroseries.py 2010-02-24 14:57:14 +0000 @@ -11,6 +11,7 @@ 'DistroSeriesTranslationsAdminView', 'DistroSeriesTranslationsMenu', 'DistroSeriesView', + 'check_distroseries_translations_viewable', ] from zope.component import getUtility @@ -19,6 +20,7 @@ from canonical.launchpad import helpers from canonical.launchpad.webapp import action from canonical.launchpad.webapp.authorization import check_permission +from canonical.launchpad.webapp.interfaces import TranslationUnavailable from canonical.launchpad.webapp.launchpadform import LaunchpadEditFormView from canonical.launchpad.webapp.menu import ( Link, NavigationMenu, enabled_with_permission) @@ -26,9 +28,8 @@ canonical_url, LaunchpadView) from lp.registry.interfaces.distroseries import IDistroSeries +from lp.registry.interfaces.series import SeriesStatus from lp.translations.browser.translations import TranslationsMixin -from lp.translations.browser.browser_helpers import ( - check_distroseries_translations_viewable) from lp.translations.interfaces.distroserieslanguage import ( IDistroSeriesLanguageSet) from lp.translations.interfaces.potemplate import IPOTemplateSet @@ -183,6 +184,8 @@ def checkTranslationsViewable(self): """ Check if user can view translations for this `IDistroSeries`""" + # Is user allowed allowed to see translations for this distroseries? + # If not, raise TranslationUnavailable. check_distroseries_translations_viewable(self.context) def distroserieslanguages(self): @@ -252,3 +255,47 @@ def language_packs(self): return Link('+language-packs', 'Language packs') + + +def check_distroseries_translations_viewable(distroseries): + """Check that these distribution series translations are visible. + + Launchpad admins, Translations admins, and users with admin + rights on the `IDistroSeries` are always allowed. + + Checks the `hide_all_translations` flag. If it is set, these + translations are not to be shown to the public. In that case an + appropriate message is composed based on the series' `status`, + and a `TranslationUnavailable` exception is raised. + + :return: Returns normally if this series' translations are + viewable to the current user. + :raise TranslationUnavailable: if this series' translations are + hidden and the user is not one of the limited caste that is + allowed to access them. + """ + + if not distroseries.hide_all_translations: + # Yup, viewable. + return + + if check_permission( + 'launchpad.TranslationsAdmin', distroseries): + return + + future = [ + SeriesStatus.EXPERIMENTAL, + SeriesStatus.DEVELOPMENT, + SeriesStatus.FUTURE, + ] + if distroseries.status in future: + raise TranslationUnavailable( + "Translations for this release series are not available yet.") + elif distroseries.status == SeriesStatus.OBSOLETE: + raise TranslationUnavailable( + "This release series is obsolete. Its translations are no " + "longer available.") + else: + raise TranslationUnavailable( + "Translations for this release series are not currently " + "available. Please come back soon.") === modified file 'lib/lp/translations/browser/tests/distroseries-views.txt' --- lib/lp/translations/browser/tests/distroseries-views.txt 2009-12-13 11:55:40 +0000 +++ lib/lp/translations/browser/tests/distroseries-views.txt 2010-02-24 14:32:58 +0000 @@ -1,9 +1,9 @@ -= DistroSeries translations view classes = +DistroSeries translations view classes +====================================== + +Let's use ubuntu/hoary for these tests. >>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest - -Let's use ubuntu/hoary for these tests. - >>> from canonical.launchpad.interfaces import IDistributionSet >>> from lp.registry.interfaces.series import SeriesStatus >>> ubuntu = getUtility(IDistributionSet).getByName('ubuntu') @@ -15,7 +15,9 @@ >>> login('