Merge lp:~abentley/launchpad/fix-branch-precondition into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 12838
Proposed branch: lp:~abentley/launchpad/fix-branch-precondition
Merge into: lp:launchpad
Diff against target: 35 lines (+15/-2)
1 file modified
lib/lp/translations/javascript/sourcepackage_sharing_details.js (+15/-2)
To merge this branch: bzr merge lp:~abentley/launchpad/fix-branch-precondition
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+57550@code.launchpad.net

Commit message

Fix 412 Precodition failed setting branch.

Description of the change

= Summary =
Fix bug #758919: Precondition failed error using the selecting upstream source branch in translations sharing page.

== Proposed fix ==
Reload the productseries after submitting usage form.

== Pre-implementation notes ==
None

== Implementation details ==
The error occurred if the translation usage was changed before the branch was changed. It's not clear why changing the product changes the ETAG of the productseries, but it apparently does. Reloading the productseries refrehes the ETAG, which allows the branch to be set. This solution adds latency, but is simple and correct.

== Tests ==
None

== Demo and Q/A ==
Go to https://translations.qastaging.launchpad.net/ubuntu/natty/+source/gnuhello/+sharing-details and change the usage settings. Then change the branch. The branch should change, and you should not get 412 Precondition failed.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/javascript/sourcepackage_sharing_details.js

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/javascript/sourcepackage_sharing_details.js'
2--- lib/lp/translations/javascript/sourcepackage_sharing_details.js 2011-04-07 15:44:38 +0000
3+++ lib/lp/translations/javascript/sourcepackage_sharing_details.js 2011-04-13 17:47:29 +0000
4@@ -542,8 +542,19 @@
5 usage_overlay.set('form_submit_callback', function(form_data) {
6 usage_overlay.hide();
7 var product = sharing_controller.get('product');
8+ function reload_entry(config, entry) {
9+ lp_client.get(entry.get('self_link'), config);
10+ }
11+ function get_productseries(config) {
12+ var productseries = sharing_controller.get('productseries');
13+ reload_entry(config, productseries);
14+ }
15+ function replace_productseries(config, new_productseries) {
16+ sharing_controller.replace_productseries(new_productseries);
17+ config.on.success();
18+ }
19 function get_product(config) {
20- lp_client.get(product.get('self_link'), config);
21+ reload_entry(config, product);
22 }
23 function replace_product(new_product) {
24 sharing_controller.replace_product(new_product);
25@@ -553,7 +564,9 @@
26 css_selector = sharing_controller.visible_check_selector(usage);
27 var io_handler = new IOHandler(
28 css_selector, new Y.lp.client.FormErrorHandler());
29- var config = io_handler.chain_config(get_product, replace_product);
30+ var config = io_handler.chain_config(
31+ get_productseries, replace_productseries, get_product,
32+ replace_product);
33 submit_form(
34 config, form_data, product, '+configure-translations', 'change');
35 });