mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 08:31:00 -04:00
Fix count of users on request to go live
We were counting users who had the `manage_settings` permission. This is the old name for it, therefore there would never be any users with this permission, so the tick would never go green. The new name for the permission is `manage_service`. This commit fixes the error, and adds an extra safeguard against something like this happening again.
This commit is contained in:
@@ -3,6 +3,7 @@ from notifications_python_client.errors import HTTPError
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
from app.notify_client.models import (
|
||||
User,
|
||||
roles,
|
||||
translate_permissions_from_admin_roles_to_db,
|
||||
)
|
||||
|
||||
@@ -134,6 +135,8 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
return [User(data) for data in resp['data']]
|
||||
|
||||
def get_count_of_users_with_permission(self, service_id, permission):
|
||||
if permission not in roles.keys():
|
||||
raise TypeError('{} is not a valid permission'.format(permission))
|
||||
return len([
|
||||
user for user in self.get_users_for_service(service_id)
|
||||
if user.has_permission_for_service(service_id, permission)
|
||||
|
||||
Reference in New Issue
Block a user