mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-22 18:20:57 -04:00
Allow editing of pending users
At the moment if a user is pending we don’t show the ‘change’ link. This is unhelpful because: - there’s no way to remove this user - there’s no way to change their phone number, if the reason that they are still pending is because they’ve been unable to receive the two factor code at the number they first provided
This commit is contained in:
@@ -447,7 +447,7 @@ class User(JSONModel, UserMixin):
|
||||
def is_editable_by(self, other_user):
|
||||
if other_user == self:
|
||||
return False
|
||||
if self.is_active:
|
||||
if self.is_active or self.is_pending:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -151,6 +151,45 @@ def test_should_show_overview_page(
|
||||
mock_get_users.assert_called_once_with(SERVICE_ONE_ID)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('state', (
|
||||
'active', 'pending',
|
||||
))
|
||||
def test_should_show_change_details_link(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_template_folders,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
active_caseworking_user,
|
||||
state,
|
||||
):
|
||||
current_user = active_user_with_permissions
|
||||
|
||||
other_user = active_caseworking_user
|
||||
other_user['id'] = uuid.uuid4()
|
||||
other_user['email_address'] = 'zzzzzzz@example.gov.uk'
|
||||
other_user['state'] = state
|
||||
|
||||
mocker.patch('app.user_api_client.get_user', return_value=current_user)
|
||||
mocker.patch('app.models.user.Users.client_method', return_value=[
|
||||
current_user,
|
||||
other_user,
|
||||
])
|
||||
|
||||
page = client_request.get('main.manage_users', service_id=SERVICE_ONE_ID)
|
||||
link = page.select('.user-list-item')[-1].select_one('a')
|
||||
|
||||
assert normalize_spaces(link.text) == (
|
||||
'Change details for Test User zzzzzzz@example.gov.uk'
|
||||
)
|
||||
assert link['href'] == url_for(
|
||||
'.edit_user_permissions',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
user_id=other_user['id'],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('number_of_users', (
|
||||
pytest.param(7, marks=pytest.mark.xfail),
|
||||
pytest.param(8),
|
||||
|
||||
Reference in New Issue
Block a user