Replace send_messages and manage_service strings across application with ServicePermission.SEND_MESSAGES and ServicePermission.MANAGE_SERVICE types

This commit is contained in:
Beverly Nguyen
2025-07-15 23:56:58 -07:00
parent 591231c084
commit 1bf55e7fa3
26 changed files with 127 additions and 116 deletions

View File

@@ -27,7 +27,7 @@
'messages',
) }}
{% if current_user.has_permissions('send_messages') %}
{% if current_user.has_permissions(ServicePermission.SEND_MESSAGES) %}
<p class="sms-message-reply-link">
<a class="usa-link" href="{{ url_for('.conversation_reply', service_id=current_service.id, notification_id=notification_id) }}">Send a text message to this phone number</a>
</p>

View File

@@ -43,7 +43,7 @@ Dashboard
<div id="totalMessageTable" class="margin-0"></div>
{% include 'views/dashboard/activity-table.html' %}
{% if current_user.has_permissions('manage_service') %}{% endif %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}{% endif %}
{% include 'views/dashboard/most-used-templates.html' %}

View File

@@ -19,7 +19,7 @@
<h1 class="font-body-2xl margin-0">
Team members
</h1>
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
{{ usaButton({
"element": "a",
"text": "Invite a team member",
@@ -108,7 +108,7 @@
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
{% if user.status == 'pending' or user.status == 'expired' %}
<a class="user-list-edit-link usa-link padding-x-2" href="{{ url_for('.cancel_invited_user', service_id=current_service.id, invited_user_id=user.id) }}">
Cancel invitation<span class="usa-sr-only"> for {{ user.email_address }}</span>

View File

@@ -50,7 +50,7 @@
{{ ajax_block(partials, updates_url, 'status', finished=finished) }}
{% endif %}
{% if current_user.has_permissions('send_messages') and current_user.has_permissions('view_activity') and template.template_type == 'sms' and can_receive_inbound %}
{% if current_user.has_permissions(ServicePermission.SEND_MESSAGES) and current_user.has_permissions('view_activity') and template.template_type == 'sms' and can_receive_inbound %}
<p>
<a class="usa-link" href="{{ url_for('.conversation', service_id=current_service.id, notification_id=notification_id, _anchor='n{}'.format(notification_id)) }}">See all text messages sent to this phone number</a>
</p>

View File

@@ -30,7 +30,7 @@
{{ edit_field(
'Change',
url_for('.service_name_change', service_id=current_service.id),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='service name',
)
}}
@@ -46,7 +46,7 @@
service_id=current_service.id,
channel='sms'
),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='your settings for sending text messages',
)}} #}
{% endcall %}
@@ -65,7 +65,7 @@
{{ edit_field(
'Manage',
url_for('.service_sms_senders', service_id=current_service.id),
permissions=['manage_service','manage_api_keys'],
permissions=[ServicePermission.MANAGE_SERVICE,'manage_api_keys'],
suffix='text message senders',
)
}}
@@ -78,7 +78,7 @@
{{ edit_field(
'Change',
url_for('.service_set_sms_prefix', service_id=current_service.id),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='your settings for starting text messages with service name',
)
}}
@@ -91,7 +91,7 @@
{{ edit_field(
'Change',
url_for('.service_set_international_sms', service_id=current_service.id),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='your settings for sending international text messages',
)
}}
@@ -104,7 +104,7 @@
{{ edit_field(
'Change',
url_for('.service_set_inbound_sms', service_id=current_service.id),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='your settings for receiving text messages',
)
}}
@@ -128,7 +128,7 @@
channel='email',
service_id=current_service.id
),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='your settings for sending emails',
)}}
{% endcall %}
@@ -146,7 +146,7 @@
{{ edit_field(
'Manage',
url_for('.service_email_reply_to', service_id=current_service.id),
permissions=['manage_service','manage_api_keys'],
permissions=[ServicePermission.MANAGE_SERVICE,'manage_api_keys'],
suffix='reply-to email addresses',
)
}}
@@ -158,7 +158,7 @@
{{ edit_field(
'Manage',
url_for('.send_files_by_email_contact_details', service_id=current_service.id),
permissions=['manage_service'],
permissions=[ServicePermission.MANAGE_SERVICE],
suffix='sending files by email',
)}}
{% endcall %}
@@ -178,7 +178,7 @@
</ul>
<p>
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
To remove these restrictions, you can send us a
<a class="usa-link" href="mailto:notify-support@gsa.gov">request to go live</a>.
{% else %}

View File

@@ -36,7 +36,7 @@
</h2>
</div>
<div class="grid-col-3">
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
<a class="usa-link user-list-edit-link" href="{{ url_for('.service_edit_email_reply_to', service_id =current_service.id, reply_to_email_id = item.id) }}">
Change<span class="usa-sr-only"> {{ item.email_address }}</span>
</a>
@@ -55,7 +55,7 @@
</div>
<div class="grid-row">
<div class="grid-col-12">
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
<div class="js-stick-at-bottom-when-scrolling">
{{ usaButton({
"element": "a",

View File

@@ -38,7 +38,7 @@
</h2>
</div>
<div class="grid-col">
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
<a class="usa-link user-list-edit-link" href="{{ url_for('.service_edit_sms_sender', service_id=current_service.id, sms_sender_id = item.id) }}">
Change<span class="usa-sr-only"> {{ item.sms_sender }}</span>
</a>
@@ -52,7 +52,7 @@
{% endfor %}
</div>
{% if current_user.has_permissions('manage_service') %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) %}
<div class="grid-row bottom-gutter">
<div class="grid-col-12">
{{ usaButton({

View File

@@ -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('send_messages', 'manage_api_keys', 'manage_templates', 'manage_service') or not user_has_template_permission %}
{% elif not current_user.has_permissions(ServicePermission.SEND_MESSAGES, 'manage_api_keys', '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='') }}
@@ -17,7 +17,7 @@
{% else %}
<div class="grid-row margin-bottom-5">
<div class="usa-button-group">
{% if current_user.has_permissions('send_messages', restrict_admin_usage=True) %}
{% if current_user.has_permissions(ServicePermission.SEND_MESSAGES, restrict_admin_usage=True) %}
<a href="{{ url_for(".set_sender", service_id=current_service.id, template_id=template.id) }}" class="usa-button usa-pill-separate-item">
Use this template
</a>

View File

@@ -25,7 +25,7 @@
{{ form.name(param_extensions={
"classes": ""
}) }}
{% if current_user.has_permissions("manage_service") and form.users_with_permission.all_service_users %}
{% if current_user.has_permissions(ServicePermission.MANAGE_SERVICE) and form.users_with_permission.all_service_users %}
{{ form.users_with_permission }}
{% endif %}