Sort users by email address

Some teams have a lot of users now (I think the record is 172). So we
should make it easier for teams to manage large numbers of users.

This is the same change we made for templates (from most recent to
alphabetical) when the number of templates was getting unmanageable.

Sorted on email address because invited users don’t have a name (and
not sorted on both, because a lot of departments have a
`lastname.firstname` scheme for email addresses, but people generally
enter their names as `Firstname Lastname`).
This commit is contained in:
Chris Hill-Scott
2018-01-26 17:16:07 +00:00
parent c20884003f
commit 959490ea85
2 changed files with 5 additions and 5 deletions

View File

@@ -28,12 +28,12 @@ from app.utils import user_has_permissions
@login_required
@user_has_permissions('view_activity', admin_override=True)
def manage_users(service_id):
users = (
user_api_client.get_users_for_service(service_id=service_id) +
[
users = sorted(
user_api_client.get_users_for_service(service_id=service_id) + [
invite for invite in invite_api_client.get_invites_for_service(service_id=service_id)
if invite.status != 'accepted'
]
],
key=lambda user: user.email_address,
)
return render_template(

View File

@@ -461,7 +461,7 @@ def test_manage_users_shows_invited_user(
page = client_request.get('main.manage_users', service_id=SERVICE_ONE_ID)
assert page.h1.string.strip() == 'Team members'
assert normalize_spaces(page.select('.user-list-item')[1].text) == (
assert normalize_spaces(page.select('.user-list-item')[0].text) == (
'invited_user@test.gov.uk (invited) '
'Cant Send messages Cant Add and edit templates Cant Manage service Can Access API keys '
'Cancel invitation'