diff --git a/app/enums.py b/app/enums.py index 67b055b7c..3c83fccda 100644 --- a/app/enums.py +++ b/app/enums.py @@ -72,6 +72,7 @@ class JobStatus(StrEnum): class ServicePermission(StrEnum): SEND_MESSAGES = "send_messages" MANAGE_SERVICE = "manage_service" + MANAGE_TEMPLATES = "manage_templates" class InvitedUserStatus(StrEnum): diff --git a/app/main/views/send.py b/app/main/views/send.py index 2d2620683..2b350bc68 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -190,7 +190,7 @@ def send_messages(service_id, template_id): @main.route("/services//send/.csv", methods=["GET"]) -@user_has_permissions(ServicePermission.SEND_MESSAGES, "manage_templates") +@user_has_permissions(ServicePermission.SEND_MESSAGES, ServicePermission.MANAGE_TEMPLATES) def get_example_csv(service_id, template_id): template = get_template( service_api_client.get_service_template(service_id, template_id)["data"], @@ -845,7 +845,7 @@ def get_skip_link(step_index, template): and template.template_type in ("sms", "email") and not (template.template_type == "sms" and current_user.mobile_number is None) and current_user.has_permissions( - "manage_templates", ServicePermission.MANAGE_SERVICE + ServicePermission.MANAGE_TEMPLATES, ServicePermission.MANAGE_SERVICE ) ): return ( diff --git a/app/templates/views/dashboard/dashboard.html b/app/templates/views/dashboard/dashboard.html index 3720c9218..e6db77bbd 100644 --- a/app/templates/views/dashboard/dashboard.html +++ b/app/templates/views/dashboard/dashboard.html @@ -16,7 +16,7 @@ Dashboard

Dashboard

- {% if current_user.has_permissions('manage_templates') and not current_service.all_templates %} + {% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) and not current_service.all_templates %} {% include 'views/dashboard/write-first-messages.html' %} {% endif %} diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 1faddd5c1..a36c4d99c 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -8,7 +8,7 @@

This template was deleted {{ template._template.updated_at|format_datetime_relative }}.

- {% elif not current_user.has_permissions(ServicePermission.SEND_MESSAGES, 'manage_api_keys', 'manage_templates', ServicePermission.MANAGE_SERVICE) or not user_has_template_permission %} + {% elif not current_user.has_permissions(ServicePermission.SEND_MESSAGES, 'manage_api_keys', ServicePermission.MANAGE_TEMPLATES, ServicePermission.MANAGE_SERVICE) or not user_has_template_permission %}

If you need to send this {{ 1|message_count_label(template.template_type, suffix='') }} @@ -22,7 +22,7 @@ Use this template {% endif %} - {% if current_user.has_permissions('manage_templates') %} + {% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %} Edit this template diff --git a/app/templates/views/templates/_template_list.html b/app/templates/views/templates/_template_list.html index c80a5c5a2..db8255d4a 100644 --- a/app/templates/views/templates/_template_list.html +++ b/app/templates/views/templates/_template_list.html @@ -24,7 +24,7 @@