From a7d6d85d8bd977ad7f569240397fb79ea609bb4a Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 4 Feb 2016 14:02:16 +0000 Subject: [PATCH] =?UTF-8?q?Make=20first=20page=20of=20=E2=80=98send=20text?= =?UTF-8?q?s=E2=80=99=20use=20links=20not=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn’t need to be a form—it’s not changing any data. And having the primary action on the page as ‘Use this template’ it makes it clear what the page is for. --- .../stylesheets/components/sms-message.scss | 7 ++++++- app/main/views/sms.py | 7 +------ app/templates/views/choose-sms-template.html | 17 ++++++++++------- tests/app/main/views/test_sms.py | 18 ------------------ tests/app/main/views/test_templates.py | 3 ++- 5 files changed, 19 insertions(+), 33 deletions(-) diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index 268225eac..d019a2b60 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -24,7 +24,7 @@ .sms-message-name { @include bold-19; - margin: 30px 0 10px 0; + margin: 20px 0 10px 0; } .sms-message-picker { @@ -61,3 +61,8 @@ label.sms-message-option { } } + +.sms-message-use-link { + margin-top: 70px; + @include bold-19; +} diff --git a/app/main/views/sms.py b/app/main/views/sms.py index cf82770ac..07aefbff5 100644 --- a/app/main/views/sms.py +++ b/app/main/views/sms.py @@ -32,13 +32,8 @@ from app.main.utils import ( ) -@main.route("/services//sms/send", methods=['GET', 'POST']) +@main.route("/services//sms/send", methods=['GET']) def choose_sms_template(service_id): - if request.method == 'POST': - return redirect(url_for('.send_sms', - service_id=service_id, - template_id=request.form.get('template'))) - try: templates = templates_dao.get_service_templates(service_id)['data'] except HTTPError as e: diff --git a/app/templates/views/choose-sms-template.html b/app/templates/views/choose-sms-template.html index 3c00892d9..9478c45ab 100644 --- a/app/templates/views/choose-sms-template.html +++ b/app/templates/views/choose-sms-template.html @@ -14,15 +14,18 @@
{% if templates %} -
+
{% for template in templates %} - {{ sms_message( - template.content, name=template.name, input_name='template', input_index=template.id - ) }} +
+ {{ sms_message(template.content, name=template.name) }} +
+ {% endfor %} -
- - {{ page_footer("Continue") }} + {% else %} {{ banner( 'Add a text message template to start sending messages'.format( diff --git a/tests/app/main/views/test_sms.py b/tests/app/main/views/test_sms.py index fd79dcf08..b42e6d3af 100644 --- a/tests/app/main/views/test_sms.py +++ b/tests/app/main/views/test_sms.py @@ -23,24 +23,6 @@ def test_choose_sms_template(app_, assert 'template two content' in content -def test_choose_sms_template_redirects(app_, - api_user_active, - mock_get_user, - mock_get_service_templates, - mock_check_verify_code, - mock_get_service_template): - with app_.test_request_context(): - with app_.test_client() as client: - client.login(api_user_active) - response = client.post( - url_for('main.choose_sms_template', service_id=12345), - data={'template': '54321'} - ) - - assert response.status_code == 302 - assert response.location == url_for('main.send_sms', service_id=12345, template_id=54321, _external=True) - - def test_upload_empty_csvfile_returns_to_upload_page(app_, api_user_active, mock_get_user, diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 525c3bcb4..fb2548a65 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -9,7 +9,8 @@ def test_should_return_list_of_all_templates(app_, mock_get_service_templates, mock_get_user, mock_get_user_by_email, - mock_login): + mock_login, + mock_get_jobs): with app_.test_request_context(): with app_.test_client() as client: client.login(api_user_active)