From ed9444b43668d50d8031df8b0dad6efddc072785 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 10 Jul 2018 17:18:50 +0100 Subject: [PATCH] Fix org info in branding requests with known orgs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This wasn’t looking quite right in the case where an organisation is in our list of domains. --- app/main/views/service_settings.py | 2 +- app/utils.py | 4 ++++ tests/app/test_utils.py | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index a758181d1..efe41b6dc 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -986,7 +986,7 @@ def branding_request(service_id): '\n---' '\nBranding requested: {}' ).format( - AgreementInfo.from_current_user().as_human_readable, + AgreementInfo.from_current_user().as_info_for_branding_request, current_service['name'], url_for('main.service_dashboard', service_id=current_service['id'], _external=True), branding_options_dict[form.options.data], diff --git a/app/utils.py b/app/utils.py index fbbbc3553..4cb3a1d2a 100644 --- a/app/utils.py +++ b/app/utils.py @@ -473,6 +473,10 @@ class AgreementInfo: else: return 'Can’t tell (domain is {})'.format(self._domain) + @property + def as_info_for_branding_request(self): + return self.owner or 'Can’t tell (domain is {})'.format(self._domain) + @property def as_jinja_template(self): if self.crown_status is None: diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py index 0edcd5781..2e2594f8d 100644 --- a/tests/app/test_utils.py +++ b/tests/app/test_utils.py @@ -454,6 +454,16 @@ def test_get_valid_government_domain_gets_most_specific_first(): ) +def test_get_domain_info_for_branding_request(): + + assert AgreementInfo("gov.uk").as_info_for_branding_request == ( + 'Can’t tell (domain is gov.uk)' + ) + assert AgreementInfo("dacorum.gov.uk").as_info_for_branding_request == ( + 'Dacorum Borough Council' + ) + + def test_validate_government_domain_data(): for domain in AgreementInfo.domains.keys():