feat: pass verified name flag into user api

This commit is contained in:
Bianca Severino
2021-07-20 16:58:39 -04:00
parent cf4a3760cd
commit 14c85d9465
5 changed files with 16 additions and 8 deletions

View File

@@ -3968,6 +3968,7 @@ ACCOUNT_VISIBILITY_CONFIGURATION["admin_fields"] = (
"year_of_birth",
"phone_number",
"activation_key",
"is_verified_name_enabled",
]
)

View File

@@ -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:

View File

@@ -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):

View File

@@ -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']

View File

@@ -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.