Refactor filtering out accepted invites to client

None of our model or view layer code should need to know about accepted
invites. We don’t use them anywhere because once an invite is accepted
that person is now a user.

Putting this logic in the client means that:
- none of the code calling the client needs to care about accepted
  invites
- it’s easier to (if we want) update the API code to not return accepted
  invites
This commit is contained in:
Chris Hill-Scott
2018-11-30 17:39:39 +00:00
parent 29830da5e6
commit 538a06c0bf
4 changed files with 20 additions and 26 deletions

View File

@@ -19,10 +19,10 @@ from app.utils import user_has_permissions
@user_has_permissions()
def manage_users(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'
],
(
user_api_client.get_users_for_service(service_id=service_id) +
invite_api_client.get_invites_for_service(service_id=service_id)
),
key=lambda user: user.email_address,
)