Merge lp:~danilo/launchpad/bug-480652 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-480652
Merge into: lp:launchpad
Diff against target: 108 lines (+35/-4)
3 files modified
lib/lp/translations/browser/productseries.py (+2/-1)
lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt (+5/-1)
lib/lp/translations/stories/standalone/xx-productseries-translations.txt (+28/-2)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-480652
Reviewer Review Type Date Requested Status
Michael Nelson (community) code Approve
Review via email: mp+15931@code.launchpad.net

Commit message

Do not OOPS when trying to link to undefined branch for a series.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug 480652 =

Fix an OOPS in trying to link to a default series branch (translations are imported from) if it's not set, yet imports are requested. It OOPSes only if translations bzr export is set at the same time.

Some drive-by test cleanups as well.

= Tests =

bin/test -vvct productseries-translations.txt

= Demo & QA =

1. create a "Hosted" branch for "evolution" export: https://code.launchpad.dev/evolution/+addbranch
2. go to https://translations.launchpad.dev/evolution/trunk/+translations-settings and set export branch to the above created branch (use "~username/evolution/name" to set it)
3. go to https://code.launchpad.dev/evolution/trunk/+linkbranch and remove the branch reference
4. https://translations.launchpad.dev/evolution/trunk/ doesn't OOPS with the fix, OOPSes without

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/browser/productseries.py
  lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt
  lib/lp/translations/stories/standalone/xx-productseries-translations.txt

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks for cleaning up the doctest too Danilo!

I verified that the test fails without your change, but didn't do the demo.

Code looks clean... thanks!

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/browser/productseries.py'
--- lib/lp/translations/browser/productseries.py 2009-10-31 12:03:43 +0000
+++ lib/lp/translations/browser/productseries.py 2009-12-10 11:30:38 +0000
@@ -132,7 +132,8 @@
132 @property132 @property
133 def has_imports_enabled(self):133 def has_imports_enabled(self):
134 """Is imports enabled for the series?"""134 """Is imports enabled for the series?"""
135 return (self.context.translations_autoimport_mode !=135 return (self.context.branch is not None and
136 self.context.translations_autoimport_mode !=
136 TranslationsBranchImportMode.NO_IMPORT)137 TranslationsBranchImportMode.NO_IMPORT)
137138
138 @property139 @property
139140
=== modified file 'lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt'
--- lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt 2009-09-14 19:00:45 +0000
+++ lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt 2009-12-10 11:30:38 +0000
@@ -1,10 +1,12 @@
1= Changing the Bazaar import settings for a product series =1= Changing the Bazaar import settings for a product series =
2
2Product maintainers can request a one-time import of translation files3Product maintainers can request a one-time import of translation files
3from the Bazaar branch that is officially linked to the release series4from the Bazaar branch that is officially linked to the release series
4of a product. This function complements the general import settings5of a product. This function complements the general import settings
5found on the "Settings" page.6found on the "Settings" page.
67
7== Getting there ==8== Getting there ==
9
8The maintainer of a product sees a menu option called "Settings" that10The maintainer of a product sees a menu option called "Settings" that
9leads to the settings page.11leads to the settings page.
1012
@@ -17,6 +19,7 @@
17 http://translations.l...d.dev/evolution/trunk/+translations-settings19 http://translations.l...d.dev/evolution/trunk/+translations-settings
1820
19== The branch display ==21== The branch display ==
22
20An official Bazaar branch is linked to this product settings. It is23An official Bazaar branch is linked to this product settings. It is
21displayed on the page.24displayed on the page.
2225
@@ -45,6 +48,7 @@
45 http://launchpad.dev/evolution/trunk/+linkbranch48 http://launchpad.dev/evolution/trunk/+linkbranch
4649
47== Pointer to one-time import ==50== Pointer to one-time import ==
51
48The user is also reminded that a one-time import of translation files52The user is also reminded that a one-time import of translation files
49can be requested and a link to that page is provided.53can be requested and a link to that page is provided.
5054
@@ -60,6 +64,7 @@
60 http://translations.l...d.dev/evolution/trunk/+request-bzr-import64 http://translations.l...d.dev/evolution/trunk/+request-bzr-import
6165
62== Changing the setting ==66== Changing the setting ==
67
63The setting is changed by selecting the desired mode with the radio68The setting is changed by selecting the desired mode with the radio
64buttons in the form.69buttons in the form.
6570
@@ -82,4 +87,3 @@
82 ( ) None87 ( ) None
83 (*) Import template files88 (*) Import template files
84 ( ) Import template and translation files89 ( ) Import template and translation files
85
8690
=== modified file 'lib/lp/translations/stories/standalone/xx-productseries-translations.txt'
--- lib/lp/translations/stories/standalone/xx-productseries-translations.txt 2009-11-01 20:18:32 +0000
+++ lib/lp/translations/stories/standalone/xx-productseries-translations.txt 2009-12-10 11:30:38 +0000
@@ -1,4 +1,5 @@
1= ProductSeries translations =1ProductSeries translations
2==========================
23
3This page shows a list of available languages for user to translate to in4This page shows a list of available languages for user to translate to in
4a single product series, or instructions on how to set up a series for5a single product series, or instructions on how to set up a series for
@@ -113,7 +114,8 @@
113 >>> serbian_link['href']114 >>> serbian_link['href']
114 u'/frobnicator/trunk/+lang/sr'115 u'/frobnicator/trunk/+lang/sr'
115116
116== Upload page and Translations use ==117Upload page and Translations use
118--------------------------------
117119
118If the product a series belongs to is not configured to use Launchpad120If the product a series belongs to is not configured to use Launchpad
119for Translations, the distroseries translations upload page will say so.121for Translations, the distroseries translations upload page will say so.
@@ -212,3 +214,27 @@
212 ... jtv_browser.contents, 'not-translated-in-launchpad'))214 ... jtv_browser.contents, 'not-translated-in-launchpad'))
213 This project is not using Launchpad for translations.215 This project is not using Launchpad for translations.
214 (Getting started with translating your project in Launchpad)216 (Getting started with translating your project in Launchpad)
217
218
219Branch synchronization options
220------------------------------
221
222If automatic import and export are set, but import branch is unset, we only
223indicate that export is happening.
224
225 >>> login('foo.bar@canonical.com')
226 >>> from lp.translations.interfaces.translations import (
227 ... TranslationsBranchImportMode)
228 >>> branch = factory.makeBranch(product=frobnicator)
229 >>> branch_name = branch.name
230 >>> frobnicator_trunk.branch = None
231 >>> frobnicator_trunk.translations_autoimport_mode = (
232 ... TranslationsBranchImportMode.IMPORT_TEMPLATES)
233 >>> frobnicator_trunk.translations_branch = branch
234 >>> logout()
235
236 >>> browser.open(frobnicator_trunk_url)
237 >>> print extract_text(browser.contents)
238 Translations...
239 Translations are exported daily to branch
240 ...