From 58b2a8a825f090aefabddd7670e2f8748d0fab7a Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 24 Aug 2016 09:34:14 +0100 Subject: [PATCH] Make email branding settings a table So that it matches the other settings on this page --- app/main/views/service_settings.py | 9 +- app/notify_client/organisations_client.py | 3 + app/templates/views/service-settings.html | 26 ++- tests/app/main/views/test_service_settings.py | 150 ++++++++++-------- tests/conftest.py | 17 ++ 5 files changed, 133 insertions(+), 72 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 301aafd61..3f90d2bdf 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -34,7 +34,14 @@ from app import user_api_client, current_service, organisations_client @login_required @user_has_permissions('manage_settings', admin_override=True) def service_settings(service_id): - return render_template('views/service-settings.html') + if current_service['organisation']: + organisation = organisations_client.get_organisation(current_service['organisation'])['organisation'] + else: + organisation = None + return render_template( + 'views/service-settings.html', + organisation=organisation + ) @main.route("/services//service-settings/name", methods=['GET', 'POST']) diff --git a/app/notify_client/organisations_client.py b/app/notify_client/organisations_client.py index 3d39decf7..21a4ae36e 100644 --- a/app/notify_client/organisations_client.py +++ b/app/notify_client/organisations_client.py @@ -15,5 +15,8 @@ class OrganisationsClient(BaseAPIClient): self.client_id = app.config['ADMIN_CLIENT_USER_NAME'] self.secret = app.config['ADMIN_CLIENT_SECRET'] + def get_organisation(self, id): + return self.get(url='/organisation/{}'.format(id)) + def get_organisations(self): return self.get(url='/organisation')['organisations'] diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 9f4afcfab..053e950f5 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -60,12 +60,26 @@

Platform admin settings

- {{ browse_list([ - { - 'title': 'Email branding', - 'link': url_for('.service_set_branding_and_org', service_id=current_service.id) - } - ]) }} + {% call mapping_table( + caption='Settings', + field_headings=['Label', 'Value', 'Action'], + field_headings_visible=False, + caption_visible=False + ) %} + {% call row() %} + {{ text_field('Email branding' )}} + {% call field() %} + {% if current_service.branding == 'govuk' %} + GOV.UK + {% elif current_service.branding == 'both' %} + GOV.UK and {{ organisation.name if organisation else None }} + {% elif current_service.branding == 'org' %} + Only {{ organisation.name if organisation else None }} + {% endif %} + {% endcall %} + {{ edit_field('Change', url_for('.service_set_branding_and_org', service_id=current_service.id)) }} + {% endcall %} + {% endcall %}