Merge lp:~henninge/launchpad/bug-488765-oops-translations into lp:launchpad
| Status: | Merged | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Approved by: | Henning Eggers on 2010-01-15 | ||||||||
| Approved revision: | not available | ||||||||
| Merged at revision: | not available | ||||||||
| Proposed branch: | lp:~henninge/launchpad/bug-488765-oops-translations | ||||||||
| Merge into: | lp:launchpad | ||||||||
| Diff against target: |
236 lines (+88/-51) 4 files modified
lib/lp/translations/browser/product.py (+22/-25) lib/lp/translations/browser/tests/test_product_view.py (+2/-1) lib/lp/translations/stories/standalone/xx-product-translations.txt (+54/-15) lib/lp/translations/templates/product-translations.pt (+10/-10) |
||||||||
| To merge this branch: | bzr merge lp:~henninge/launchpad/bug-488765-oops-translations | ||||||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Guilherme Salgado (community) | code | Approve on 2010-01-15 | |
| Canonical Launchpad Engineering | code | 2010-01-14 | Pending |
|
Review via email:
|
|||
Commit Message
Fixed Product:
| Henning Eggers (henninge) wrote : | # |
| Guilherme Salgado (salgado) wrote : | # |
Hi Henning,
I have just a few suggestions to improve this branch a bit.
review needs-fixing
On Thu, 2010-01-14 at 17:22 +0000, Henning Eggers wrote:
> = Bug 488765 =
>
> A product has an attribute primary_
> product series or source package that should be translated. Returning
> source packages here seems to be a newer feature that broke a
> product's +translations page if the primary_
> package because the template assumed it's a product series.
>
> == Proposed fx ==
>
> I filed bug 507534 about that behaviour and fixed the page by
> filtering out source packages in the view so that only product series
> are displayed by the template.
>
> I also discovered that bug 371632 can be fixed with this.
>
> == Implementation details ==
>
> lib/lp/
>
> * The view already had a property "primary_
> obviously unused and returned a dictionary. I re-used it to return the
> primary_
> series.
>
> lib/lp/
>
> * The part that only checked for up/download links was expanded to
> check for the whole recommendation section. This way it can be tested
> for complete absence if no primary_
>
> * This test did reproducce the error because evolution is linked to a
> translatable source package in the sample data, so
> Product.
> templates in the product series have been disabled.
>
> * Disabling all the templates is a bit of noise but needed to
> reproduce the error.
>
> * Appended a test to show the notice when no translations are
> available.
>
> lib/lp/
>
> * Use view/primary_
>
> * Changed some ids and classes needed for testing.
>
> * Added notice for when no translations are available.
>
> * Changed conditions so that page is never empty.
>
>
> == Test ==
>
> bin/test -vvct product-
>
> == Demo/QA ==
>
> On launchpad.dev:
> 1. Disable all templates for evolution trunk.
> 2. Got to https:/
> 3. You should not get an oops but a notice that there are no
> translations for this project.
>
> To reproduce on staging you'll need a project that is linked to a
> source pacakage with translations.
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -89,28 +89,14 @@
>
> @cachedproperty
> def primary_
> - """Return a dictionary with the info for a primary translatable.
> -
> - If there is no primary translatable object, returns an empty
> - dictionary.
> -
> - The dictionary has the keys:
> - * 'title': The title of the translatable object.
> - * 'potemplates': a set of PO Templates for this object.
> - * 'base_url': The base URL to reach the base URL for this object.
...
| Henning Eggers (henninge) wrote : | # |
Am 15.01.2010 13:06, Guilherme Salgado schrieb:
> Review: Needs Fixing
> Hi Henning,
>
> I have just a few suggestions to improve this branch a bit.
Cool, thanks for doing the review.
>> === modified file 'lib/lp/
>> + if not isinstance(
>
> You can use zope.security.
> remove the security proxy.
Cool, I didn't know about this.
>
> Actually, you should use IProductSeries.
> would allow you to not import ProductSeries here, as that must not be
> done. I wonder why the import fascist doesn't emit a warning about this
> import...
Yes, you are right on both accounts. I changed it to use providedBy.
>> === modified file 'lib/lp/
>> +A series is not translatable if all templates are disabled. We need to jump
>> +through some hoops to create that situation.
>> +
>> + >>> login('<email address hidden>')
>> + >>> from zope.component import getUtility
>> + >>> from lp.registry.
>> + >>> evotrunk = getUtility(
>> + ... 'evolution'
>> + >>> from lp.translations
>> + >>> potemplates = getUtility(
>> + ... productseries=
>> + >>> for potemplate in potemplates:
>> + ... potemplate.
>> + >>> logout()
>> + >>> admin_browser.
>> + >>> print find_translatio
>> + None
>
> I think it'd be nice to show here that the product has a translatable
> source package and explain that is only in that case that we don't show
> recommendations. It's also important to do that because the test
> assumes there's a translatable source package associated to evolution
> (as you described in the cover letter), but the test itself doesn't make
> it clear nor does it assert that.
Ah, that is not quite right. We don't show the recommendation even if
there is source package because atm we cannot treat a source package
like a product series in this respect. That will have to be fixed in
another branch (bug 507534).
I added a test that shows that the series has translatable source
package. This situation is what triggered the oops that this branch is
fixing but the display of recommendations is independent of a
translatable source package.
>
>> +
>> +Instead a notice is displayed that the product has no translations.
>> +
>> + >>> notice = first_tag_
>> + >>> print extract_
>> + There are no translations for this project.
>>
>
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -14,7 +14,7 @@
>> </div>
>>
>> <div metal:fill-
>> - tal:define=

= Bug 488765 =
A product has an attribute primary_ translatable that returns the product series or source package that should be translated. Returning source packages here seems to be a newer feature that broke a product's +translations page if the primary_ translatable was a source package because the template assumed it's a product series.
== Proposed fx ==
I filed bug 507534 about that behaviour and fixed the page by filtering out source packages in the view so that only product series are displayed by the template.
I also discovered that bug 371632 can be fixed with this.
== Implementation details ==
lib/lp/ translations/ browser/ product. py
* The view already had a property "primary_ translatable" that was obviously unused and returned a dictionary. I re-used it to return the primary_ translatable of the context or None if it is not a product series.
lib/lp/ translations/ stories/ standalone/ xx-product- translations. txt
* The part that only checked for up/download links was expanded to check for the whole recommendation section. This way it can be tested for complete absence if no primary_ translatable is available.
* This test did reproducce the error because evolution is linked to a translatable source package in the sample data, so Product. primary_ translatable returns a source package when all templates in the product series have been disabled.
* Disabling all the templates is a bit of noise but needed to reproduce the error.
* Appended a test to show the notice when no translations are available.
lib/lp/ translations/ templates/ product- translations. pt
* Use view/primary_ translatable instead of context's.
* Changed some ids and classes needed for testing.
* Added notice for when no translations are available.
* Changed conditions so that page is never empty.
== Test ==
bin/test -vvct product- translations
== Demo/QA ==
On launchpad.dev: /translations. launchpad. dev/evolution
1. Disable all templates for evolution trunk.
2. Got to https:/
3. You should not get an oops but a notice that there are no translations for this project.
To reproduce on staging you'll need a project that is linked to a source pacakage with translations.
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: translations/ browser/ product. py translations/ stories/ standalone/ xx-product- translations. txt translations/ templates/ product- translations. pt
lib/lp/
lib/lp/
lib/lp/