From e7f0a414cee0f4da52bb6852697f7ee0db1abffe Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Tue, 16 Oct 2018 14:50:10 +0100 Subject: [PATCH] Update service schema to add letter_logo_filename Added the filename of a service's letter logo to the service schema. We want this in the schema so that it is possible to call `current_service.letter_logo_filename` from notifications-admin and to pass this value through to template-preview. --- app/schemas.py | 4 ++++ tests/app/service/test_rest.py | 1 + 2 files changed, 5 insertions(+) diff --git a/app/schemas.py b/app/schemas.py index 5692b78f8..f4730afa5 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -205,12 +205,16 @@ class ServiceSchema(BaseSchema): created_by = field_for(models.Service, 'created_by', required=True) organisation_type = field_for(models.Service, 'organisation_type') dvla_organisation = field_for(models.Service, 'dvla_organisation') + letter_logo_filename = fields.Method(method_name='get_letter_logo_filename') permissions = fields.Method("service_permissions") email_branding = field_for(models.Service, 'email_branding') organisation = field_for(models.Service, 'organisation') override_flag = False letter_contact_block = fields.Method(method_name="get_letter_contact") + def get_letter_logo_filename(self, service): + return service.dvla_organisation.filename + def service_permissions(self, service): return [p.permission for p in service.permissions] diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index ed2b273d0..7dfaad89a 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -139,6 +139,7 @@ def test_get_service_by_id(admin_request, sample_service): assert json_resp['data']['dvla_organisation'] == '001' assert json_resp['data']['prefix_sms'] is True assert json_resp['data']['postage'] == 'second' + assert json_resp['data']['letter_logo_filename'] == 'hm-government' @pytest.mark.parametrize('detailed', [True, False])