From e44d9895ce8bf62ec26330a9279d049af46fa7bd Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 20 Jun 2016 13:33:29 +0100 Subject: [PATCH] =?UTF-8?q?Tidy=20up=20=E2=80=98change=20service=20name?= =?UTF-8?q?=E2=80=99=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Make service name repopulate in textbox - More spacing between sections of the page --- app/main/forms.py | 2 +- app/main/views/service_settings.py | 3 +++ app/templates/views/service-settings/name.html | 13 +++++++------ tests/app/main/views/test_service_settings.py | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 38c72b1c2..aa99a450e 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -168,7 +168,7 @@ class ServiceNameForm(Form): super(ServiceNameForm, self).__init__(*args, **kwargs) name = StringField( - u'New name', + u'Service name', validators=[ DataRequired(message='Can’t be empty') ]) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 023515b9a..b234f923c 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -42,6 +42,9 @@ def service_settings(service_id): def service_name_change(service_id): form = ServiceNameForm(service_api_client.find_all_service_email_from) + if request.method == 'GET': + form.name.data = current_service.get('name') + if form.validate_on_submit(): session['service_name_change'] = form.name.data return redirect(url_for('.service_name_change_confirm', service_id=service_id)) diff --git a/app/templates/views/service-settings/name.html b/app/templates/views/service-settings/name.html index a488b05bc..5420b3936 100644 --- a/app/templates/views/service-settings/name.html +++ b/app/templates/views/service-settings/name.html @@ -13,12 +13,13 @@
-

Users will see your service name:

- -
    -
  • at the start of every text message, eg ‘Vehicle tax: we received your payment, thank you’
  • -
  • as your email sender name
  • -
+
+

Users will see your service name:

+
    +
  • at the start of every text message, eg ‘Vehicle tax: we received your payment, thank you’
  • +
  • as your email sender name
  • +
+
{{ textbox(form.name) }} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 0c832d015..9965e2922 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -34,8 +34,9 @@ def test_should_show_service_name(app_, response = client.get(url_for( 'main.service_name_change', service_id=service_one['id'])) assert response.status_code == 200 - resp_data = response.get_data(as_text=True) - assert 'Change your service name' in resp_data + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.find('h1').text == 'Change your service name' + assert page.find('input', attrs={"type": "text"})['value'] == 'service one' app.service_api_client.get_service.assert_called_with(service_one['id'])