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
1=== modified file 'lib/lp/translations/browser/productseries.py'
2--- lib/lp/translations/browser/productseries.py 2009-10-31 12:03:43 +0000
3+++ lib/lp/translations/browser/productseries.py 2009-12-10 11:30:38 +0000
4@@ -132,7 +132,8 @@
5 @property
6 def has_imports_enabled(self):
7 """Is imports enabled for the series?"""
8- return (self.context.translations_autoimport_mode !=
9+ return (self.context.branch is not None and
10+ self.context.translations_autoimport_mode !=
11 TranslationsBranchImportMode.NO_IMPORT)
12
13 @property
14
15=== modified file 'lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt'
16--- lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt 2009-09-14 19:00:45 +0000
17+++ lib/lp/translations/stories/productseries/xx-productseries-translations-settings.txt 2009-12-10 11:30:38 +0000
18@@ -1,10 +1,12 @@
19 = Changing the Bazaar import settings for a product series =
20+
21 Product maintainers can request a one-time import of translation files
22 from the Bazaar branch that is officially linked to the release series
23 of a product. This function complements the general import settings
24 found on the "Settings" page.
25
26 == Getting there ==
27+
28 The maintainer of a product sees a menu option called "Settings" that
29 leads to the settings page.
30
31@@ -17,6 +19,7 @@
32 http://translations.l...d.dev/evolution/trunk/+translations-settings
33
34 == The branch display ==
35+
36 An official Bazaar branch is linked to this product settings. It is
37 displayed on the page.
38
39@@ -45,6 +48,7 @@
40 http://launchpad.dev/evolution/trunk/+linkbranch
41
42 == Pointer to one-time import ==
43+
44 The user is also reminded that a one-time import of translation files
45 can be requested and a link to that page is provided.
46
47@@ -60,6 +64,7 @@
48 http://translations.l...d.dev/evolution/trunk/+request-bzr-import
49
50 == Changing the setting ==
51+
52 The setting is changed by selecting the desired mode with the radio
53 buttons in the form.
54
55@@ -82,4 +87,3 @@
56 ( ) None
57 (*) Import template files
58 ( ) Import template and translation files
59-
60
61=== modified file 'lib/lp/translations/stories/standalone/xx-productseries-translations.txt'
62--- lib/lp/translations/stories/standalone/xx-productseries-translations.txt 2009-11-01 20:18:32 +0000
63+++ lib/lp/translations/stories/standalone/xx-productseries-translations.txt 2009-12-10 11:30:38 +0000
64@@ -1,4 +1,5 @@
65-= ProductSeries translations =
66+ProductSeries translations
67+==========================
68
69 This page shows a list of available languages for user to translate to in
70 a single product series, or instructions on how to set up a series for
71@@ -113,7 +114,8 @@
72 >>> serbian_link['href']
73 u'/frobnicator/trunk/+lang/sr'
74
75-== Upload page and Translations use ==
76+Upload page and Translations use
77+--------------------------------
78
79 If the product a series belongs to is not configured to use Launchpad
80 for Translations, the distroseries translations upload page will say so.
81@@ -212,3 +214,27 @@
82 ... jtv_browser.contents, 'not-translated-in-launchpad'))
83 This project is not using Launchpad for translations.
84 (Getting started with translating your project in Launchpad)
85+
86+
87+Branch synchronization options
88+------------------------------
89+
90+If automatic import and export are set, but import branch is unset, we only
91+indicate that export is happening.
92+
93+ >>> login('foo.bar@canonical.com')
94+ >>> from lp.translations.interfaces.translations import (
95+ ... TranslationsBranchImportMode)
96+ >>> branch = factory.makeBranch(product=frobnicator)
97+ >>> branch_name = branch.name
98+ >>> frobnicator_trunk.branch = None
99+ >>> frobnicator_trunk.translations_autoimport_mode = (
100+ ... TranslationsBranchImportMode.IMPORT_TEMPLATES)
101+ >>> frobnicator_trunk.translations_branch = branch
102+ >>> logout()
103+
104+ >>> browser.open(frobnicator_trunk_url)
105+ >>> print extract_text(browser.contents)
106+ Translations...
107+ Translations are exported daily to branch
108+ ...