Sort services alphabetically when copying template

If you have a lot of services it’s hard to find the one you’re looking
for if the sort order is a mixture of `created_by` and which ones belong
to an organisation.

Since the templates within the services are sorted alphabetically it
makes sense to also sort the services alphabetically.
This commit is contained in:
Chris Hill-Scott
2018-08-09 13:33:08 +01:00
parent 2dde1ad36f
commit 55d051d95a
2 changed files with 17 additions and 16 deletions

View File

@@ -214,9 +214,10 @@ class UserApiClient(NotifyAdminAPIClient):
def get_services_for_user(self, user):
orgs_and_services_for_user = self.get_organisations_and_services_for_user(user)
return orgs_and_services_for_user['services_without_organisations'] + next(chain(
all_services = orgs_and_services_for_user['services_without_organisations'] + next(chain(
org['services'] for org in orgs_and_services_for_user['organisations']
), [])
return sorted(all_services, key=lambda service: service['name'])
def get_service_ids_for_user(self, user):
return {