mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-16 02:02:13 -05:00
On the downgrade method of the db script the assumption that all users with manage_api_keys had the access_developer_docs permission.
29 lines
888 B
Python
29 lines
888 B
Python
from app.models import (
|
|
MANAGE_USERS,
|
|
MANAGE_TEMPLATES,
|
|
MANAGE_SETTINGS,
|
|
SEND_TEXTS,
|
|
SEND_EMAILS,
|
|
SEND_LETTERS,
|
|
MANAGE_API_KEYS,
|
|
VIEW_ACTIVITY
|
|
)
|
|
|
|
from app.schemas import permission_schema
|
|
|
|
|
|
permissions_groups = {'send_messages': [SEND_TEXTS, SEND_EMAILS, SEND_LETTERS],
|
|
'manage_service': [MANAGE_USERS, MANAGE_SETTINGS, MANAGE_TEMPLATES],
|
|
'manage_api_keys': [MANAGE_API_KEYS],
|
|
VIEW_ACTIVITY: [VIEW_ACTIVITY]}
|
|
|
|
|
|
def get_permissions_by_group(permission_groups):
|
|
requested_permissions = []
|
|
for group in permission_groups:
|
|
permissions = permissions_groups[group]
|
|
for permission in permissions:
|
|
requested_permissions.append({'permission': permission})
|
|
permissions, errors = permission_schema.load(requested_permissions, many=True)
|
|
return permissions
|