Only show relevant user permissions for broadcast services

For services with the broadcast permission this hides:
- the ‘View dashboard’ permission (and defaults it to _checked_) because
  all users of broadcast services will need to see the dashboard
- the ‘Manage API keys’ permission (and defaults it to _not checked_)
  because we don’t offer an API integration for broadcast services yet
  – if we do we won’t want existing users to automatically get the
  permission

It relabels:
- the ‘Send’ permission to ‘Prepare and approve’ to match the current,
  slightly clunky language on the templates page
- the ‘Manage settings’ label to not refer to ‘usage’ because broadcast
  services won’t incur cost
This commit is contained in:
Chris Hill-Scott
2020-07-13 11:10:34 +01:00
parent 494636937b
commit 72c1b3d8a1
4 changed files with 215 additions and 7 deletions

View File

@@ -18,6 +18,8 @@ from app.event_handlers import (
)
from app.main import main
from app.main.forms import (
BroadcastInviteUserForm,
BroadcastPermissionsForm,
ChangeEmailForm,
ChangeMobileNumberForm,
ChangeNonGovEmailForm,
@@ -47,7 +49,12 @@ def manage_users(service_id):
@user_has_permissions('manage_service')
def invite_user(service_id):
form = InviteUserForm(
if current_service.has_permission('broadcast'):
form_class = BroadcastInviteUserForm
else:
form_class = InviteUserForm
form = form_class(
invalid_email_address=current_user.email_address,
all_template_folders=current_service.all_template_folders,
folder_permissions=[f['id'] for f in current_service.all_template_folders]
@@ -89,7 +96,12 @@ def edit_user_permissions(service_id, user_id):
if user.mobile_number:
mobile_number = redact_mobile_number(user.mobile_number, " ")
form = PermissionsForm.from_user(
if current_service.has_permission('broadcast'):
form_class = BroadcastPermissionsForm
else:
form_class = PermissionsForm
form = form_class.from_user(
user,
service_id,
folder_permissions=None if user.platform_admin else [