Return all required org and services info for user

The admin app now needs to know a few extra things about orgs and
services in order to list them. At the moment it does this by making
multiple API calls.

This commit adds extra fields to the existing response. Once the admin
app is using this fields we’ll be able to remove:
- `reponse['services_without_organisations']`
- `reponse['organisations']['services']`
This commit is contained in:
Chris Hill-Scott
2019-06-12 10:34:15 +01:00
parent d19dbe5b61
commit b6fdb269e4
2 changed files with 145 additions and 69 deletions

View File

@@ -515,7 +515,11 @@ def get_orgs_and_services(user):
}
for service in org.services
if service.active and service in user.services
]
],
'count_of_live_services': len([
service for service in org.services
if service.active and not service.restricted
]),
}
for org in user.organisations if org.active
],
@@ -534,5 +538,14 @@ def get_orgs_and_services(user):
service.organisation not in user.organisations
)
)
],
'services': [
{
'id': service.id,
'name': service.name,
'restricted': service.restricted,
'organisation': service.organisation.id if service.organisation else None,
}
for service in user.services if service.active
]
}