Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add work experience field. #34034

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def _get_extended_profile_fields():
platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME)
),
"profession": _("Profession"),
"specialty": _("Specialty")
"specialty": _("Specialty"),
"work_experience": _("Work experience")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be covered in tests. test_setting_views.py in test_context test

}

extended_profile_field_names = configuration_helpers.get_value('extended_profile_fields', [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration
from openedx.core.djangoapps.user_api.accounts.settings_views import account_settings_context, get_user_orders
from openedx.core.djangoapps.user_api.accounts.toggles import REDIRECT_TO_ACCOUNT_MICROFRONTEND
from openedx.core.djangoapps.user_api.tests.factories import UserPreferenceFactory
Expand Down Expand Up @@ -108,6 +109,21 @@ def test_context(self, mock_enterprise_customer_for_request):
expected_beta_language = {'code': 'lt-lt', 'name': settings.LANGUAGE_DICT.get('lt-lt')}
assert context['beta_language'] == expected_beta_language

@with_site_configuration(
configuration={
'extended_profile_fields': ['work_experience']
}
)
def test_context_extended_profile(self):
"""
Test that if the field is available in extended_profile configuration then the field
will be sent in response.
"""
context = account_settings_context(self.request)
extended_pofile_field = context['extended_profile_fields'][0]
assert extended_pofile_field['field_name'] == 'work_experience'
assert extended_pofile_field['field_label'] == 'Work experience'

@mock.patch('openedx.core.djangoapps.user_api.accounts.settings_views.enterprise_customer_for_request')
@mock.patch('openedx.features.enterprise_support.utils.third_party_auth.provider.Registry.get')
def test_context_for_enterprise_learner(
Expand Down
12 changes: 12 additions & 0 deletions openedx/core/djangoapps/user_authn/api/form_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,15 @@ def add_confirm_email_field(is_field_required=False):
'label': email_label,
'error_message': accounts.REQUIRED_FIELD_CONFIRM_EMAIL_TEXT_MSG if is_field_required else '',
}


def add_work_experience_field(is_field_required=False):
"""
Returns the user work experience field description
"""
# Translators: This label appears above a dropdown menu to select
# the user's work experience
work_experience_label = _("Work experience")
return _add_field_with_configurable_select_options(
'work_experience', work_experience_label, is_field_required,
)
Loading