mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge pull request #2908 from alphagov/allow-invited-users-to-count
Let inviting a user complete the go live checklist
This commit is contained in:
@@ -112,8 +112,12 @@ class Service(JSONModel):
|
||||
|
||||
@cached_property
|
||||
def has_team_members(self):
|
||||
return user_api_client.get_count_of_users_with_permission(
|
||||
self.id, 'manage_service'
|
||||
return (
|
||||
user_api_client.get_count_of_users_with_permission(
|
||||
self.id, 'manage_service'
|
||||
) + invite_api_client.get_count_of_invites_with_permission(
|
||||
self.id, 'manage_service'
|
||||
)
|
||||
) > 1
|
||||
|
||||
def cancel_invite(self, invited_user_id):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from app.models.user import (
|
||||
InvitedUser,
|
||||
roles,
|
||||
translate_permissions_from_admin_roles_to_db,
|
||||
)
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
@@ -44,6 +45,14 @@ class InviteApiClient(NotifyAdminAPIClient):
|
||||
'/service/{}/invite'.format(service_id)
|
||||
)['data']
|
||||
|
||||
def get_count_of_invites_with_permission(self, service_id, permission):
|
||||
if permission not in roles.keys():
|
||||
raise TypeError('{} is not a valid permission'.format(permission))
|
||||
return len([
|
||||
invited_user for invited_user in self.get_invites_for_service(service_id)
|
||||
if invited_user.has_permission_for_service(service_id, permission)
|
||||
])
|
||||
|
||||
def check_token(self, token):
|
||||
resp = self.get(url='/invite/service/{}'.format(token))
|
||||
return InvitedUser(**resp['data'])
|
||||
|
||||
Reference in New Issue
Block a user