mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 03:14:58 -04:00
Replace send_messages and manage_service strings across application with ServicePermission.SEND_MESSAGES and ServicePermission.MANAGE_SERVICE types
This commit is contained in:
@@ -7,7 +7,7 @@ from ordered_set import OrderedSet
|
||||
from werkzeug.datastructures import MultiDict
|
||||
from werkzeug.routing import RequestRedirect
|
||||
|
||||
from app.enums import NotificationStatus
|
||||
from app.enums import NotificationStatus, ServicePermission
|
||||
from notifications_utils.field import Field
|
||||
|
||||
SENDING_STATUSES = [
|
||||
@@ -83,7 +83,7 @@ def unicode_truncate(s, length):
|
||||
|
||||
def should_skip_template_page(db_template):
|
||||
return (
|
||||
current_user.has_permissions("send_messages")
|
||||
current_user.has_permissions(ServicePermission.SEND_MESSAGES)
|
||||
and not current_user.has_permissions("manage_templates", "manage_api_keys")
|
||||
and not db_template["archived"]
|
||||
)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from itertools import chain
|
||||
|
||||
from app.enums import ServicePermission
|
||||
|
||||
permission_mappings = {
|
||||
# TODO: consider turning off email-sending permissions during SMS pilot
|
||||
"send_messages": ["send_texts", "send_emails"],
|
||||
ServicePermission.SEND_MESSAGES: ["send_texts", "send_emails"],
|
||||
"manage_templates": ["manage_templates"],
|
||||
"manage_service": ["manage_users", "manage_settings"],
|
||||
ServicePermission.MANAGE_SERVICE: ["manage_users", "manage_settings"],
|
||||
"manage_api_keys": ["manage_api_keys"],
|
||||
"view_activity": ["view_activity"],
|
||||
}
|
||||
@@ -14,9 +16,9 @@ all_db_permissions = set(chain(*permission_mappings.values()))
|
||||
|
||||
permission_options = (
|
||||
("view_activity", "See dashboard"),
|
||||
("send_messages", "Send messages"),
|
||||
(ServicePermission.SEND_MESSAGES, "Send messages"),
|
||||
("manage_templates", "Add and edit templates"),
|
||||
("manage_service", "Manage settings, team and usage"),
|
||||
(ServicePermission.MANAGE_SERVICE, "Manage settings, team and usage"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user