diff --git a/app/config.py b/app/config.py index 53eb1e8ac..5899d6880 100644 --- a/app/config.py +++ b/app/config.py @@ -83,6 +83,11 @@ class Config(object): r"assembly\.wales", ] + LETTER_BRANDING = [ + ('001', 'HM Government'), + ('500', 'Land Registry'), + ] + class Development(Config): DEBUG = True diff --git a/app/main/forms.py b/app/main/forms.py index d303b3673..60ee4df05 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -538,6 +538,20 @@ class ServiceBrandingOrg(Form): ) +class LetterBranding(Form): + + def __init__(self, choices=[], *args, **kwargs): + super().__init__(*args, **kwargs) + self.dvla_org_id.choices = choices + + dvla_org_id = RadioField( + 'Which logo should this service’s letter have?', + validators=[ + DataRequired() + ] + ) + + class Whitelist(Form): def populate(self, email_addresses, phone_numbers): diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index abc6dd620..3441c3c66 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -26,7 +26,8 @@ from app.main.forms import ( ServiceReplyToEmailFrom, ServiceSmsSender, ServiceLetterContactBlock, - ServiceBrandingOrg + ServiceBrandingOrg, + LetterBranding, ) from app import user_api_client, current_service, organisations_client @@ -41,7 +42,10 @@ def service_settings(service_id): organisation = None return render_template( 'views/service-settings.html', - organisation=organisation + organisation=organisation, + letter_branding=dict( + current_app.config['LETTER_BRANDING'] + ).get(current_service.get('dvla_org_id', '001')) ) @@ -314,6 +318,28 @@ def service_set_branding_and_org(service_id): ) +@main.route("/services//service-settings/set-letter-branding", methods=['GET', 'POST']) +@login_required +@user_has_permissions(admin_override=True) +def set_letter_branding(service_id): + + form = LetterBranding(choices=current_app.config['LETTER_BRANDING']) + + if form.validate_on_submit(): + service_api_client.update_service( + service_id, + dvla_organisation=form.dvla_org_id.data + ) + return redirect(url_for('.service_settings', service_id=service_id)) + + form.dvla_org_id.data = current_service.get('dvla_organisation', '001') + + return render_template( + 'views/service-settings/set-letter-branding.html', + form=form, + ) + + def get_branding_as_value_and_label(organisations): return [ (organisation['id'], organisation['name']) diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 72d489a2d..d172176cd 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -91,7 +91,8 @@ class ServiceAPIClient(NotifyAdminAPIClient): 'created_by', 'branding', 'organisation', - 'letter_contact_block' + 'letter_contact_block', + 'dvla_org_id', } if disallowed_attributes: raise TypeError('Not allowed to update service attributes: {}'.format( diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index b25b93875..78f0db7a1 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -103,6 +103,11 @@ {% endcall %} {{ edit_field('Change', url_for('.service_set_branding_and_org', service_id=current_service.id)) }} {% endcall %} + {% call row() %} + {{ text_field('Letter branding')}} + {{ text_field(letter_branding) }} + {{ edit_field('Change', url_for('.set_letter_branding', service_id=current_service.id)) }} + {% endcall %} {% endcall %}