Commit bff8c082 by Troy Sankey

Avoid a django breaking change: set_language response code

In Django 1.10+, the set_language view (/i18n/setlang) will respond to
Ajax requests which do not contain a "next" parameter with status 204 No
Content instead of 304.  This commit adds the "next" parameter to the
request in order to ensure that upgrading to Django 1.10+ will not cause
the set_language view to change behavior.

PLAT-1353
parent 68890dab
......@@ -142,8 +142,13 @@ define(['backbone',
requests,
'POST',
'/i18n/setlang/',
'language=' + data[fieldData.valueAttribute]
$.param({
language: data[fieldData.valueAttribute],
next: window.location.href
})
);
// Django will actually respond with a 302 redirect, but that would cause a page load during these
// unittests. 204 should work fine for testing.
AjaxHelpers.respondWithNoContent(requests);
FieldViewsSpecHelpers.expectMessageContains(view, 'Your changes have been saved.');
......@@ -157,7 +162,10 @@ define(['backbone',
requests,
'POST',
'/i18n/setlang/',
'language=' + data[fieldData.valueAttribute]
$.param({
language: data[fieldData.valueAttribute],
next: window.location.href
})
);
AjaxHelpers.respondWithError(requests, 500);
FieldViewsSpecHelpers.expectMessageContains(
......
......@@ -52,7 +52,8 @@
fieldTemplate: field_dropdown_account_template,
saveSucceeded: function() {
var data = {
language: this.modelValue()
language: this.modelValue(),
next: window.location.href
};
var view = this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment