Skip to content

Commit

Permalink
update: account APIs with the arabic_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-Salman29 committed Jul 8, 2024
1 parent 8b3ae9f commit 31394d3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ def do_create_account(form, custom_form=None):
profile_fields = [
"name", "level_of_education", "gender", "mailing_address", "city", "country", "goals",
"year_of_birth", "national_id", "phone_number", "date_of_birth", "region", "address_line",
"english_language_level", "employment_status", "work_experience_level", "job_title", "terms_and_conditions"
"english_language_level", "employment_status", "work_experience_level", "job_title", "terms_and_conditions",
"arabic_name",
]
profile = UserProfile(
user=user,
Expand Down
2 changes: 1 addition & 1 deletion lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4152,7 +4152,7 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
'employment_status',
'work_experience_level',
'job_title',

'arabic_name',
# Not an actual field, but used to signal whether badges should be public.
'accomplishments_shared',
]
Expand Down
4 changes: 3 additions & 1 deletion openedx/core/djangoapps/user_api/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def to_representation(self, user): # lint-amnesty, pylint: disable=arguments-di
"employment_status": None,
"work_experience_level": None,
"job_title": None,
"arabic_name": None,
}

if user_profile:
Expand Down Expand Up @@ -218,6 +219,7 @@ def to_representation(self, user): # lint-amnesty, pylint: disable=arguments-di
"employment_status": AccountLegacyProfileSerializer.convert_empty_to_None(user_profile.employment_status),
"work_experience_level": AccountLegacyProfileSerializer.convert_empty_to_None(user_profile.work_experience_level),
"job_title": AccountLegacyProfileSerializer.convert_empty_to_None(user_profile.job_title),
"arabic_name": AccountLegacyProfileSerializer.convert_empty_to_None(user_profile.arabic_name),
}
)

Expand Down Expand Up @@ -308,7 +310,7 @@ class Meta:
"name", "gender", "goals", "year_of_birth", "level_of_education", "country", "state", "social_links",
"mailing_address", "bio", "profile_image", "requires_parental_consent", "language_proficiencies",
"phone_number", "city", "date_of_birth", "region", "city", "address_line", "english_language_level",
"employment_status", "work_experience_level", "job_title"
"employment_status", "work_experience_level", "job_title", "arabic_name",
)
# Currently no read-only field, but keep this so view code doesn't need to know.
read_only_fields = ()
Expand Down
1 change: 1 addition & 0 deletions openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def create_account_with_params(request, params): # pylint: disable=too-many-sta
extra_fields["work_experience_level"] = "required"
extra_fields["job_title"] = "required"
extra_fields["terms_and_conditions"] = "required"
extra_fields["arabic_name"] = "required"

if is_registration_api_v1(request):
if 'confirm_email' in extra_fields:
Expand Down
26 changes: 26 additions & 0 deletions openedx/core/djangoapps/user_authn/views/registration_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def __init__(self):
"employment_status",
"work_experience_level",
"job_title",
"arabic_name",
]

if settings.ENABLE_COPPA_COMPLIANCE and 'year_of_birth' in self.EXTRA_FIELDS:
Expand Down Expand Up @@ -1354,6 +1355,31 @@ def _add_terms_of_service_field(self, form_desc, required=True):
},
)

def _add_arabic_name_field(self, form_desc, required=True):
"""Add a arabic name field to a form description.
Arguments:
form_desc: A form description
Keyword Arguments:
required (bool): Whether this field is required; defaults to True
"""
# Translators: This label appears above a field on the registration form
# meant to hold the user's arabic name.
name_label = _("Arabic Name")

# Translators: These instructions appear on the registration form, immediately
# below a field meant to hold the user's arabic name.
name_instructions = _("This name will be used on any certificates that you earn.")

form_desc.add_field(
"arabic_name",
label=name_label,
instructions=name_instructions,
restrictions={
"max_length": accounts.NAME_MAX_LENGTH,
},
required=required
)

def _apply_third_party_auth_overrides(self, request, form_desc):
"""Modify the registration form if the user has authenticated with a third-party provider.
If a user has successfully authenticated with a third-party provider,
Expand Down

0 comments on commit 31394d3

Please sign in to comment.