mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-15 23:01:00 -04:00
added manage_templates to enum
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -190,7 +190,7 @@ def send_messages(service_id, template_id):
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/send/<uuid:template_id>.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 (
|
||||
|
||||
@@ -16,7 +16,7 @@ Dashboard
|
||||
<div class="dashboard margin-top-0 margin-bottom-2">
|
||||
|
||||
<h1 class="usa-sr-only">Dashboard</h1>
|
||||
{% 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 %}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<p class="hint">
|
||||
This template was deleted {{ template._template.updated_at|format_datetime_relative }}.
|
||||
</p>
|
||||
{% 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 %}
|
||||
<p class="top-gutter-1-3 {% if template.template_type != 'sms' %}bottom-gutter{% endif %}">
|
||||
If you need to send this
|
||||
{{ 1|message_count_label(template.template_type, suffix='') }}
|
||||
@@ -22,7 +22,7 @@
|
||||
Use this template
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if current_user.has_permissions('manage_templates') %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
<a href="{{ url_for(".edit_service_template", service_id=current_service.id, template_id=template.id) }}" class="usa-button usa-button--outline usa-pill-separate-item">
|
||||
Edit this template
|
||||
</a>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<nav id="template-list" aria-label="Template list">
|
||||
{% set checkboxes_data = [] %}
|
||||
|
||||
{% if not current_user.has_permissions('manage_templates') %}
|
||||
{% if not current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
<ul>
|
||||
{% endif %}
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
} %}
|
||||
{% set _ = checkboxes_data.append(checkbox_config) %}
|
||||
|
||||
{% if not current_user.has_permissions('manage_templates') %}
|
||||
{% if not current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
<li
|
||||
class="template-list-item {%- if item.ancestors %} template-list-item-hidden-by-default {%- else %} template-list-item-without-ancestors{%- endif %}">
|
||||
{{ item_link_content }}
|
||||
@@ -105,11 +105,11 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if not current_user.has_permissions('manage_templates') %}
|
||||
{% if not current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if current_user.has_permissions('manage_templates') %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
{{ templates_and_folders_form.templates_and_folders(param_extensions={
|
||||
"items": checkboxes_data,
|
||||
"formGroup": False
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
{% if not templates_and_folders.templates_to_show %}
|
||||
|
||||
{% if current_user.has_permissions('manage_templates') %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
<p class="bottom-gutter">
|
||||
You need a template before you can send text messages.
|
||||
</p>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<p>
|
||||
Every message starts with a template. You can change it later.
|
||||
|
||||
{% if current_user.has_permissions('manage_templates') %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %}
|
||||
You need a template before you can
|
||||
{% else %}
|
||||
You need to ask your service manager to add templates before you can
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<div class="grid-row flex-column">
|
||||
<h1 class="font-body-2xl line-height-sans-2 margin-bottom-1 margin-top-0" id="page-title">{{page_title}}</h1>
|
||||
<div class="{% if current_user.has_permissions('manage_templates') %} grid-col-10 {% else %} grid-col-12 {% endif %}">
|
||||
<div class="{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) %} grid-col-10 {% else %} grid-col-12 {% endif %}">
|
||||
<p class="margin-top-0 margin-bottom-4" id="page-description">
|
||||
Every message starts with a template. To send, choose or create a template.
|
||||
</p>
|
||||
@@ -44,7 +44,7 @@
|
||||
current_user=current_user
|
||||
) }}
|
||||
</div>
|
||||
{% if current_user.has_permissions('manage_templates') and current_template_folder_id and user_has_template_folder_permission %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) and current_template_folder_id and user_has_template_folder_permission %}
|
||||
<div class="grid-col-2">
|
||||
<a href="{{ url_for('.manage_template_folder', service_id=current_service.id, template_folder_id=current_template_folder_id) }}" class="usa-link folder-heading-manage-link">Manage this folder<span class="usa-sr-only">Manage this folder</span></a>
|
||||
</div>
|
||||
@@ -63,7 +63,7 @@
|
||||
<p class="usa-body margin-top-2">No templates found</p>
|
||||
</div>
|
||||
|
||||
{% if current_user.has_permissions('manage_templates') and user_has_template_folder_permission %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) and user_has_template_folder_permission %}
|
||||
{% call form_wrapper(
|
||||
class='sticky-scroll-area',
|
||||
module='template-folder-form',
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
href="{{ url_for('.view_template_versions', service_id=current_service.id, template_id=template.id) }}">See previous versions</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if current_user.has_permissions('manage_templates') and user_has_template_permission %}
|
||||
{% if current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES) and user_has_template_permission %}
|
||||
<h2 class="margin-bottom-1 font-body-lg">More actions</h2>
|
||||
<ul class="usa-list usa-list--unstyled">
|
||||
{% if not template._template.archived %}
|
||||
|
||||
@@ -74,7 +74,7 @@ def unicode_truncate(s, length):
|
||||
def should_skip_template_page(db_template):
|
||||
return (
|
||||
current_user.has_permissions(ServicePermission.SEND_MESSAGES)
|
||||
and not current_user.has_permissions("manage_templates", "manage_api_keys")
|
||||
and not current_user.has_permissions(ServicePermission.MANAGE_TEMPLATES, "manage_api_keys")
|
||||
and not db_template["archived"]
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from app.enums import ServicePermission
|
||||
permission_mappings = {
|
||||
# TODO: consider turning off email-sending permissions during SMS pilot
|
||||
ServicePermission.SEND_MESSAGES: ["send_texts", "send_emails"],
|
||||
"manage_templates": ["manage_templates"],
|
||||
ServicePermission.MANAGE_TEMPLATES: [ServicePermission.MANAGE_TEMPLATES],
|
||||
ServicePermission.MANAGE_SERVICE: ["manage_users", "manage_settings"],
|
||||
"manage_api_keys": ["manage_api_keys"],
|
||||
"view_activity": ["view_activity"],
|
||||
@@ -17,7 +17,7 @@ all_db_permissions = set(chain(*permission_mappings.values()))
|
||||
permission_options = (
|
||||
("view_activity", "See dashboard"),
|
||||
(ServicePermission.SEND_MESSAGES, "Send messages"),
|
||||
("manage_templates", "Add and edit templates"),
|
||||
(ServicePermission.MANAGE_TEMPLATES, "Add and edit templates"),
|
||||
(ServicePermission.MANAGE_SERVICE, "Manage settings, team and usage"),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user