From 5ad0e35547ce263c879882a726365b3243b9c272 Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Fri, 25 Nov 2022 15:14:37 -0500 Subject: [PATCH 1/2] feat: Allow to include translations for extended profile fields (cherry picked from commit 5d03359b2b503ab1e15f67f90eb9df6ae47d4ccc) --- .../core/djangoapps/user_api/accounts/settings_views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index 002695d4e33f..6b957c2e4a1b 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -28,6 +28,7 @@ from openedx.core.djangoapps.lang_pref.api import all_languages, released_languages from openedx.core.djangoapps.programs.models import ProgramsApiConfig from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers +from openedx.core.djangoapps.theming import helpers as theming_helpers from openedx.core.djangoapps.user_api.accounts.toggles import ( should_redirect_to_account_microfrontend, should_redirect_to_order_history_microfrontend @@ -270,6 +271,13 @@ def _get_extended_profile_fields(): "profession": _("Profession"), "specialty": _("Specialty") } + request = theming_helpers.get_current_request() + extended_profile_fields_translations = configuration_helpers.get_value( + 'extended_profile_fields_translations', + {}, + ) + translations = extended_profile_fields_translations.get(request.LANGUAGE_CODE, {}) + field_labels_map.update(translations) extended_profile_field_names = configuration_helpers.get_value('extended_profile_fields', []) for field_to_exclude in fields_already_showing: From 4d24257f741672b6936d6774061ea7aa4ffa0071 Mon Sep 17 00:00:00 2001 From: Johan Seto K <51926076+johanseto@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:04:39 -0500 Subject: [PATCH 2/2] fix: test with pr suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andrey CaƱon --- .../djangoapps/user_api/accounts/settings_views.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openedx/core/djangoapps/user_api/accounts/settings_views.py b/openedx/core/djangoapps/user_api/accounts/settings_views.py index 6b957c2e4a1b..acf83d0c0363 100644 --- a/openedx/core/djangoapps/user_api/accounts/settings_views.py +++ b/openedx/core/djangoapps/user_api/accounts/settings_views.py @@ -272,12 +272,14 @@ def _get_extended_profile_fields(): "specialty": _("Specialty") } request = theming_helpers.get_current_request() - extended_profile_fields_translations = configuration_helpers.get_value( - 'extended_profile_fields_translations', - {}, - ) - translations = extended_profile_fields_translations.get(request.LANGUAGE_CODE, {}) - field_labels_map.update(translations) + + if request: + extended_profile_fields_translations = configuration_helpers.get_value( + 'extended_profile_fields_translations', + {}, + ) + translations = extended_profile_fields_translations.get(request.LANGUAGE_CODE, {}) + field_labels_map.update(translations) extended_profile_field_names = configuration_helpers.get_value('extended_profile_fields', []) for field_to_exclude in fields_already_showing: