From f44ff0bfc94c8d8b2911e8c8a40df86ab3a1593a Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 13 Dec 2018 10:37:44 +0000 Subject: [PATCH] Refactor live services check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/notify_client/user_api_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/notify_client/user_api_client.py b/app/notify_client/user_api_client.py index 6b53378ac..dfc3af797 100644 --- a/app/notify_client/user_api_client.py +++ b/app/notify_client/user_api_client.py @@ -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):