diff --git a/lms/envs/common.py b/lms/envs/common.py index 2693d652ec856da691751c4c83d5fe3b5706e998..84a15b8a29dbbb01f389ca2c94f04d367d465418 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -3968,6 +3968,7 @@ ACCOUNT_VISIBILITY_CONFIGURATION["admin_fields"] = ( "year_of_birth", "phone_number", "activation_key", + "is_verified_name_enabled", ] ) diff --git a/openedx/core/djangoapps/user_api/accounts/serializers.py b/openedx/core/djangoapps/user_api/accounts/serializers.py index 1569fcfaab34059a6edb893f422507e38c2a0fa1..c6198ef51ce342565883aca636dfe43eb81b4441 100644 --- a/openedx/core/djangoapps/user_api/accounts/serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/serializers.py @@ -13,6 +13,8 @@ from django.core.exceptions import ObjectDoesNotExist from django.urls import reverse from rest_framework import serializers +from edx_name_affirmation.toggles import is_verified_name_enabled + from common.djangoapps.student.models import UserPasswordToggleHistory from lms.djangoapps.badges.utils import badges_enabled from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers @@ -161,6 +163,7 @@ class UserReadOnlySerializer(serializers.Serializer): # lint-amnesty, pylint: d "social_links": None, "extended_profile_fields": None, "phone_number": None, + "is_verified_name_enabled": is_verified_name_enabled(), } if user_profile: diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py index 8fc00a19c82ed8b615ca20bec4465527593d6d98..496641040ae615aa5fcd79c7e2a7f51ad688d866 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_api.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_api.py @@ -554,7 +554,8 @@ class AccountSettingsOnCreationTest(CreateAccountMixin, TestCase): 'secondary_email_enabled': None, 'time_zone': None, 'course_certificates': None, - 'phone_number': None + 'phone_number': None, + 'is_verified_name_enabled': False, } def test_normalize_password(self): diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py index 6d9b4c473785ae0dd0005896119c30474c6924eb..15c69de3d493303ce664da69e1622e77a48a2967 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_views.py @@ -276,7 +276,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): Verify that all account fields are returned (even those that are not shareable). """ data = response.data - assert 28 == len(data) + assert 29 == len(data) # public fields (3) expected_account_privacy = ( @@ -417,7 +417,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): """ self.different_client.login(username=self.different_user.username, password=TEST_PASSWORD) self.create_mock_profile(self.user) - with self.assertNumQueries(25): + with self.assertNumQueries(26): response = self.send_get(self.different_client) self._verify_full_shareable_account_response(response, account_privacy=ALL_USERS_VISIBILITY) @@ -432,7 +432,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): """ self.different_client.login(username=self.different_user.username, password=TEST_PASSWORD) self.create_mock_profile(self.user) - with self.assertNumQueries(25): + with self.assertNumQueries(26): response = self.send_get(self.different_client) self._verify_private_account_response(response) @@ -556,7 +556,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): with self.assertNumQueries(queries): response = self.send_get(self.client) data = response.data - assert 28 == len(data) + assert 29 == len(data) assert self.user.username == data['username'] assert ((self.user.first_name + ' ') + self.user.last_name) == data['name'] for empty_field in ("year_of_birth", "level_of_education", "mailing_address", "bio"): @@ -579,7 +579,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): assert data['accomplishments_shared'] is False self.client.login(username=self.user.username, password=TEST_PASSWORD) - verify_get_own_information(23) + verify_get_own_information(24) # Now make sure that the user can get the same information, even if not active self.user.is_active = False @@ -599,7 +599,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): legacy_profile.save() self.client.login(username=self.user.username, password=TEST_PASSWORD) - with self.assertNumQueries(23): + with self.assertNumQueries(24): response = self.send_get(self.client) for empty_field in ("level_of_education", "gender", "country", "state", "bio",): assert response.data[empty_field] is None @@ -955,7 +955,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase): response = self.send_get(client) if has_full_access: data = response.data - assert 28 == len(data) + assert 29 == len(data) assert self.user.username == data['username'] assert ((self.user.first_name + ' ') + self.user.last_name) == data['name'] assert self.user.email == data['email'] diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index 0befff9b3c2389daccb4c376c9319410033786d0..2ae2d1f780e4907167ac1f827c9a1cde7499037c 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -246,6 +246,9 @@ class AccountViewSet(ViewSet): * phone_number: The phone number for the user. String of numbers with an optional `+` sign at the start. + * is_verified_name_enabled: Temporary flag to control verified name field - see + https://github.com/edx/edx-name-affirmation/blob/main/edx_name_affirmation/toggles.py + For all text fields, plain text instead of HTML is supported. The data is stored exactly as specified. Clients must HTML escape rendered values to avoid script injections.