From 9ac08ac59dd619c495f2d74d1dd6c4675e518b7e Mon Sep 17 00:00:00 2001 From: muzaffaryousaf Date: Tue, 14 Apr 2015 17:49:56 +0500 Subject: [PATCH] Moving the country field to the required section of account setting page. TNL-1856 --- .../tests/lms/test_account_settings.py | 6 +++--- .../account_settings_factory_spec.js | 16 ++++++++++------ .../views/account_settings_factory.js | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/common/test/acceptance/tests/lms/test_account_settings.py b/common/test/acceptance/tests/lms/test_account_settings.py index d2f1d7265c..0198088675 100644 --- a/common/test/acceptance/tests/lms/test_account_settings.py +++ b/common/test/acceptance/tests/lms/test_account_settings.py @@ -101,6 +101,7 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest): 'Email Address', 'Password', 'Language', + 'Country or Region' ] }, { @@ -109,7 +110,6 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest): 'Education Completed', 'Gender', 'Year of Birth', - 'Country or Region', 'Preferred Language', ] }, @@ -286,8 +286,8 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest): self._test_dropdown_field( u'country', u'Country or Region', - u'', - [u'Pakistan', u''], + u'Afghanistan', + [u'Pakistan', u'Palau'], ) def test_preferred_language_field(self): diff --git a/lms/static/js/spec/student_account/account_settings_factory_spec.js b/lms/static/js/spec/student_account/account_settings_factory_spec.js index 92fab45b05..113a44e814 100644 --- a/lms/static/js/spec/student_account/account_settings_factory_spec.js +++ b/lms/static/js/spec/student_account/account_settings_factory_spec.js @@ -148,7 +148,7 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j var sectionsData = accountSettingsView.options.sectionsData; - expect(sectionsData[0].fields.length).toBe(5); + expect(sectionsData[0].fields.length).toBe(6); var textFields = [sectionsData[0].fields[1], sectionsData[0].fields[2]]; for (var i = 0; i < textFields.length ; i++) { @@ -165,10 +165,14 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j }, requests); } - expect(sectionsData[1].fields.length).toBe(5); - for (var i = 0; i < 4; i++) { - - var view = sectionsData[1].fields[i].view; + expect(sectionsData[1].fields.length).toBe(4); + var dropdownFields = [ + sectionsData[1].fields[0], + sectionsData[1].fields[1], + sectionsData[1].fields[2] + ]; + _.each(dropdownFields, function(field) { + var view = field.view; FieldViewsSpecHelpers.verifyDropDownField(view, { title: view.options.title, valueAttribute: view.options.valueAttribute, @@ -178,7 +182,7 @@ define(['backbone', 'jquery', 'underscore', 'js/common_helpers/ajax_helpers', 'j invalidValue2: Helpers.FIELD_OPTIONS[3][0], validationError: "Nope, this will not do!" }, requests); - } + }); var section2Fields = sectionsData[2].fields; expect(section2Fields.length).toBe(2); diff --git a/lms/static/js/student_account/views/account_settings_factory.js b/lms/static/js/student_account/views/account_settings_factory.js index 309032dbe8..c9a1610d3d 100644 --- a/lms/static/js/student_account/views/account_settings_factory.js +++ b/lms/static/js/student_account/views/account_settings_factory.js @@ -81,6 +81,15 @@ ), options: fieldsData.language.options }) + }, + { + view: new FieldViews.DropdownFieldView({ + model: userAccountModel, + required: true, + title: gettext('Country or Region'), + valueAttribute: 'country', + options: fieldsData['country']['options'] + }) } ] }, @@ -108,15 +117,7 @@ model: userAccountModel, title: gettext('Year of Birth'), valueAttribute: 'year_of_birth', - options: fieldsData.year_of_birth.options - }) - }, - { - view: new FieldViews.DropdownFieldView({ - model: userAccountModel, - title: gettext('Country or Region'), - valueAttribute: 'country', - options: fieldsData.country.options + options: fieldsData['year_of_birth']['options'] }) }, {