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

fix(redwood): handle missing name in readonly enterprise account fields #692

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
6 changes: 4 additions & 2 deletions openedx/features/enterprise_support/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,11 @@ def test_update_account_settings_context_for_enterprise(self, mock_get_fields):
mock_get_fields.assert_called_once_with(user)
assert expected_context == context

@ddt.data(settings.ENTERPRISE_READONLY_ACCOUNT_FIELDS, ['username', 'email', 'country'])
@mock.patch('openedx.features.enterprise_support.utils.get_current_request')
@mock.patch('openedx.features.enterprise_support.api.enterprise_customer_for_request')
def test_get_enterprise_readonly_account_fields_no_sync_learner_profile_data(
self, mock_customer_for_request, mock_get_current_request,
self, readonly_fields, mock_customer_for_request, mock_get_current_request,
):
mock_get_current_request.return_value = mock.Mock(
GET={'enterprise_customer': 'some-uuid'},
Expand All @@ -284,7 +285,8 @@ def test_get_enterprise_readonly_account_fields_no_sync_learner_profile_data(
}
user = mock.Mock()

actual_fields = get_enterprise_readonly_account_fields(user)
with override_settings(ENTERPRISE_READONLY_ACCOUNT_FIELDS=readonly_fields):
actual_fields = get_enterprise_readonly_account_fields(user)
assert set() == actual_fields
mock_customer_for_request.assert_called_once_with(mock_get_current_request.return_value)
mock_get_current_request.assert_called_once_with()
Expand Down
2 changes: 1 addition & 1 deletion openedx/features/enterprise_support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def get_enterprise_readonly_account_fields(user):
# if user has no `UserSocialAuth` record then allow to edit `fullname`
# whether the `sync_learner_profile_data` is enabled or disabled
user_social_auth_record = _user_has_social_auth_record(user, enterprise_customer)
if not user_social_auth_record:
if not user_social_auth_record and 'name' in enterprise_readonly_account_fields:
enterprise_readonly_account_fields.remove('name')

sync_learner_profile_data = _get_sync_learner_profile_data(enterprise_customer)
Expand Down
Loading