← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/fix-branch-precondition2 into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/fix-branch-precondition2 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #758919 in Launchpad itself: "412 Precondition failed error using the selecting upstream source branch in translations sharing page"
  https://bugs.launchpad.net/launchpad/+bug/758919

For more details, see:
https://code.launchpad.net/~abentley/launchpad/fix-branch-precondition2/+merge/57945

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

== Proposed fix ==
Reload the productseries after setting the branch.

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==
None

== Demo and Q/A ==
Go to the +sharing-details page for a sourcepackage.  Select a branch.  Then select another branch.  The second time should not give a 412 precondition failed error.


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/javascript/sourcepackage_sharing_details.js
-- 
https://code.launchpad.net/~abentley/launchpad/fix-branch-precondition2/+merge/57945
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/fix-branch-precondition2 into lp:launchpad.
=== modified file 'lib/lp/translations/javascript/sourcepackage_sharing_details.js'
--- lib/lp/translations/javascript/sourcepackage_sharing_details.js	2011-04-13 17:39:32 +0000
+++ lib/lp/translations/javascript/sourcepackage_sharing_details.js	2011-04-15 19:49:26 +0000
@@ -381,6 +381,7 @@
         var that = this;
         var lp_client = new Y.lp.client.Launchpad();
         var branch_check = that.get('tsconfig').get('branch');
+        var productseries = that.get('productseries');
 
         /* Here begin a series of methods which each represent a step in
          * setting the branch.  They each take a config to use in an lp_client
@@ -391,21 +392,24 @@
          * closure, such as "that" and "branch_summary".
          */
         function save_branch(config) {
-            var productseries = that.get('productseries');
             productseries.set('branch_link', branch_summary.api_uri);
             productseries.lp_save(config);
         }
         function get_branch(config){
             lp_client.get(branch_summary.api_uri, config);
         }
-        function set_link(branch){
+        function set_link(config, branch){
             that.set_branch(branch);
+            lp_client.get(productseries.get('self_link'), config);
+        }
+        function finish(new_productseries){
+            that.replace_productseries(new_productseries);
             that.update();
             that.flash_check_green(branch_check);
         }
         css_selector = that.visible_check_selector(branch_check);
         var io_handler = new IOHandler(css_selector);
-        save_branch(io_handler.chain_config(get_branch, set_link));
+        save_branch(io_handler.chain_config(get_branch, set_link, finish));
     },
     /**
      * Update the display of all checklist items.