From 667f7c35507786e0815286b44956eb181030fbdf Mon Sep 17 00:00:00 2001 From: Jhony Avella Date: Tue, 24 Oct 2017 16:10:31 -0500 Subject: [PATCH] customizing student account options and settings --- common/djangoapps/student/models.py | 2 +- .../account_settings_factory_spec.js | 11 ++++---- .../views/account_settings_factory.js | 27 ++++++++++--------- .../views/account_settings_view.js | 16 +++++------ .../user_api/accounts/settings_views.py | 6 ++--- .../user_authn/views/tests/test_register.py | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index b243083f793..cb584836ece 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -530,7 +530,7 @@ class Meta: # Optional demographic data we started capturing from Fall 2012 this_year = datetime.now(UTC).year - VALID_YEARS = list(range(this_year, this_year - 120, -1)) + VALID_YEARS = range(this_year - 16, this_year - 120, -1) year_of_birth = models.IntegerField(blank=True, null=True, db_index=True) GENDER_CHOICES = ( ('m', gettext_noop('Male')), 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 3495af8e053..727da88b294 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 @@ -112,7 +112,7 @@ define(['backbone', var sectionsData = accountSettingsView.options.tabSections.aboutTabSections; - expect(sectionsData[0].fields.length).toBe(7); + expect(sectionsData[0].fields.length).toBe(6); var textFields = [sectionsData[0].fields[1], sectionsData[0].fields[2]]; for (i = 0; i < textFields.length; i++) { @@ -185,10 +185,9 @@ define(['backbone', USERNAME: 0, FULL_NAME: 1, EMAIL_ADDRESS: 2, - PASSWORD: 3, - LANGUAGE: 4, - COUNTRY: 5, - TIMEZONE: 6 + LANGUAGE: 3, + COUNTRY: 4, + TIMEZONE: 5 }; var additionalInfoFields = { EDUCATION: 0, @@ -276,7 +275,7 @@ define(['backbone', sectionsData = accountSettingsView.options.tabSections.aboutTabSections; - expect(sectionsData[accountInfoTab.BASIC_ACCOUNT_INFORMATION].fields.length).toBe(7); + expect(sectionsData[accountInfoTab.BASIC_ACCOUNT_INFORMATION].fields.length).toBe(6); // Verify that username, name and email fields are readonly textFields = [ 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 882f3f693d7..b5c8e8d35a1 100644 --- a/lms/static/js/student_account/views/account_settings_factory.js +++ b/lms/static/js/student_account/views/account_settings_factory.js @@ -162,19 +162,20 @@ }, fullnameFieldView, emailFieldView, - { - view: new AccountSettingsFieldViews.PasswordFieldView({ - model: userAccountModel, - title: gettext('Password'), - screenReaderTitle: gettext('Reset Your Password'), - valueAttribute: 'password', - emailAttribute: 'email', - passwordResetSupportUrl: passwordResetSupportUrl, - linkTitle: gettext('Reset Your Password'), - linkHref: fieldsData.password.url, - helpMessage: gettext('Check your email account for instructions to reset your password.') // eslint-disable-line max-len - }) - }, + // { + // view: new AccountSettingsFieldViews.PasswordFieldView({ + // model: userAccountModel, + // title: gettext('Password'), + // screenReaderTitle: gettext('Reset Your Password'), + // valueAttribute: 'password', + // emailAttribute: 'email', + // passwordResetSupportUrl: passwordResetSupportUrl, + // linkTitle: gettext('Reset Your Password'), + // linkHref: fieldsData.password.url, + // eslint-disable-next-line max-len + // helpMessage: gettext('Check your email account for instructions to reset your password.') + // }) + // }, { view: new AccountSettingsFieldViews.LanguagePreferenceFieldView({ model: userPreferencesModel, diff --git a/lms/static/js/student_account/views/account_settings_view.js b/lms/static/js/student_account/views/account_settings_view.js index fa50a031678..22ab624a696 100644 --- a/lms/static/js/student_account/views/account_settings_view.js +++ b/lms/static/js/student_account/views/account_settings_view.js @@ -37,14 +37,14 @@ selected: true, expanded: true }, - { - name: 'accountsTabSections', - id: 'accounts-tab', - label: gettext('Linked Accounts'), - tabindex: -1, - selected: false, - expanded: false - } + // { + // name: 'accountsTabSections', + // id: 'accounts-tab', + // label: gettext('Linked Accounts'), + // tabindex: -1, + // selected: false, + // expanded: false + // } ]; if (!view.options.disableOrderHistoryTab) { accountSettingsTabs.push({ diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index 4f835fbd38c..92b9aa44ec3 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -111,11 +111,11 @@ def account_settings_context(request): 'nav_hidden': True, 'fields': { 'country': { - 'options': list(countries), + 'options': [(u'UY', u'Uruguay')], # For all options use list(countries) }, 'gender': { 'options': [(choice[0], _(choice[1])) for choice in UserProfile.GENDER_CHOICES], # lint-amnesty, pylint: disable=translation-of-non-string }, 'language': { - 'options': released_languages(), + 'options': [(u'es-419', u'Español (Latinoamérica)')], # For all options use released_languages(), }, 'level_of_education': { 'options': [(choice[0], _(choice[1])) for choice in UserProfile.LEVEL_OF_EDUCATION_CHOICES], # lint-amnesty, pylint: disable=translation-of-non-string }, 'password': { @@ -123,7 +123,7 @@ def account_settings_context(request): }, 'year_of_birth': { 'options': year_of_birth_options, }, 'preferred_language': { - 'options': all_languages(), + 'options': [(u'es-419', u'Español (Latinoamérica)')], # For all options use all_languages() }, 'time_zone': { 'options': TIME_ZONE_CHOICES, } diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index 19b3dc51dc2..4368d8ec623 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -951,7 +951,7 @@ def test_register_form_year_of_birth(self): "name": str(year), "default": False } - for year in range(this_year, this_year - 120, -1) + for year in range(this_year - 16, this_year - 120, -1) ] ) self._assert_reg_field(