diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 9b3126ec0..f7e6a7e45 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -1,25 +1,51 @@ -
- {{ template|string }} -
-
+
{% if template._template.archived %}
This template was deleted
{{ template._template.updated_at|format_date_normal }} -
+

{% else %} -
- {% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %} - +
+
+ {% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %} + + + {% endif %} + {% if + current_user.has_permissions(permissions=['manage_templates'], admin_override=True) and + template.template_type != 'letter' + %} + + {% endif %} +
+
+ {% if current_user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']) %} +

+ Upload recipients - - Send yourself a test - +   + + Send yourself a test + +

+ {% endif %} + {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %} + Edit {% endif %} - {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %} - Edit template - {% endif %} - API info -
{% endif %}
+
+ {{ template|string }} +
diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 316cfa95a..13aee7319 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -33,6 +33,57 @@ def test_should_show_page_for_one_template( mock_get_service_template.assert_called_with(service_one['id'], template_id) +@pytest.mark.parametrize('permissions, links_to_be_shown', [ + ( + ['view_activity'], + [] + ), + ( + ['manage_templates'], + ['.edit_service_template'] + ), + ( + ['send_texts', 'send_emails', 'send_letters'], + ['.send_messages', '.send_test'] + ), + ( + ['send_texts', 'send_emails', 'send_letters', 'manage_templates'], + ['.send_messages', '.send_test', '.edit_service_template'] + ), +]) +def test_should_be_able_to_view_a_template_with_links( + client, + mock_get_service_template, + active_user_with_permissions, + mocker, + service_one, + fake_uuid, + permissions, + links_to_be_shown, +): + active_user_with_permissions._permissions[service_one['id']] = permissions + client.login(active_user_with_permissions, mocker, service_one) + + response = client.get(url_for( + '.view_template', + service_id=service_one['id'], + template_id=fake_uuid + )) + + assert response.status_code == 200 + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + links_in_page = page.select('.pill-separate-item') + + assert len(links_in_page) == len(links_to_be_shown) + + for index, link_to_be_shown in enumerate(links_to_be_shown): + assert links_in_page[index]['href'] == url_for( + link_to_be_shown, + service_id=service_one['id'], + template_id=fake_uuid, + ) + + def test_should_show_sms_template_with_downgraded_unicode_characters( logged_in_client, mocker,