Refactor live services check

Changes the check to say ‘does the user have any live services’ rather
than ‘are all their services in trial mode’. The former is closer to
meaning the thing we care about.

Also has the opportunity to short-circuit without having to go through
the full list.
This commit is contained in:
Chris Hill-Scott
2018-12-13 10:37:44 +00:00
parent 688bdd1d7a
commit f44ff0bfc9

View File

@@ -220,8 +220,8 @@ class UserApiClient(NotifyAdminAPIClient):
return sorted(all_services, key=lambda service: service['name'])
def user_has_live_services(self, user):
return not all(
service['restricted'] for service in self.get_services_for_user(user)
return any(
not service['restricted'] for service in self.get_services_for_user(user)
)
def get_service_ids_for_user(self, user):