Removed links to add_template_by_type_endpoint

The endpoint was removed, but was still linked to in a couple of
places. Some old links were no longer needed, so have been removed.

We do still need a link to `add_template_by_type` on the 'Choose reply'
page - this page is used to allow to let someone pick a template to
reply to inbound SMS with. Since the link only appears if they have no
SMS templates, we now link to `.choose_template` with the templates and
folders form already opened at the option to add a template.
This commit is contained in:
Katie Smith
2019-02-14 16:27:13 +00:00
parent 6a66ee0a4f
commit 862d077f66
5 changed files with 45 additions and 15 deletions

View File

@@ -135,6 +135,10 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
if 'templates_and_folders' in templates_and_folders_form.errors:
flash('Select at least one template or folder')
initial_state = request.args.get('initial_state')
if request.method == 'GET' and initial_state:
templates_and_folders_form.op = initial_state
return render_template(
'views/templates/choose.html',
current_template_folder_id=template_folder_id,

View File

@@ -19,7 +19,7 @@
<p class="bottom-gutter">
You need a template before you can send text messages.
</p>
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id) }}" class="button">Add a new template</a>
<a href="{{ url_for('.choose_template', service_id=current_service.id, initial_state='add-new-template') }}" class="button">Add a new template</a>
{% else %}
<p>
You need to ask your service manager to add templates before you

View File

@@ -57,17 +57,10 @@
show_fallback_page_title=not current_service.all_template_folders
) }}
</div>
{% if current_user.has_permissions('manage_templates') %}
{% if not current_user.has_permissions('manage_templates') %}
<div class="column-one-third">
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id, template_folder_id=current_template_folder_id) }}" class="button align-with-heading">Add new template</a>
</div>
{% endif %}
{% if current_user.has_permissions('manage_templates') and current_template_folder_id %}
<div class="column-one-sixth">
<a href="{{ url_for('.manage_template_folder', service_id=current_service.id, template_folder_id=current_template_folder_id) }}" class="folder-heading-manage-link">Manage</a>
</div>
{% endif %}
{% if current_user.has_permissions('manage_templates') and current_template_folder_id %}
<div class="column-one-sixth">
<a href="{{ url_for('.manage_template_folder', service_id=current_service.id, template_folder_id=current_template_folder_id) }}" class="folder-heading-manage-link">Manage</a>
</div>
{% endif %}
</div>
{% endif %}
@@ -90,9 +83,6 @@
{% else %}
{% include 'views/templates/_template_list.html' %}
{% if (not current_service.all_templates) and (not current_service.all_template_folders) and current_user.has_permissions('manage_templates') %}
<a href="{{ url_for('.add_template_by_type', service_id=current_service.id) }}" class="button">Add a new template</a>
{% endif %}
{% endif %}

View File

@@ -251,6 +251,27 @@ def test_conversation_links_to_reply(
)
def test_conversation_reply_shows_link_to_add_templates_if_service_has_no_templates(
client_request,
fake_uuid,
mock_get_service_templates_when_no_templates_exist,
):
page = client_request.get(
'main.conversation_reply',
service_id=SERVICE_ONE_ID,
notification_id=fake_uuid,
)
page_text = page.find('p', class_='bottom-gutter').text
link = page.find('a', text='Add a new template')['href']
assert normalize_spaces(page_text) == 'You need a template before you can send text messages.'
assert link == url_for(
'main.choose_template',
service_id=SERVICE_ONE_ID,
initial_state='add-new-template'
)
def test_conversation_reply_shows_templates(
client_request,
fake_uuid,

View File

@@ -196,6 +196,21 @@ def test_should_show_page_for_choosing_a_template(
mock_get_template_folders.assert_called_once_with(SERVICE_ONE_ID)
def test_choose_template_can_pass_through_an_initial_state_to_templates_and_folders_selection_form(
client_request,
mock_get_template_folders,
mock_get_service_templates,
):
page = client_request.get(
'main.choose_template',
service_id=SERVICE_ONE_ID,
initial_state='add-new-template'
)
templates_and_folders_form = page.find('form')
assert templates_and_folders_form['data-prev-state'] == 'add-new-template'
def test_should_not_show_template_nav_if_only_one_type_of_template(
client_request,
mock_get_template_folders,