Add platform admin setting for letter branding

Does two main things:
- defines what ‘brands’ we support, in terms of the ID that DVLA use
- adds a form to choose which branding a service uses (currently
  platform admin only, like email branding)

By doing this we will be able to (with some more work) preview and send
letters with a variety of different branding.

Story: https://www.pivotaltracker.com/story/show/143506905
This commit is contained in:
Chris Hill-Scott
2017-04-19 16:11:28 +01:00
parent 38fbc3c47d
commit 61470391bf
7 changed files with 149 additions and 11 deletions

View File

@@ -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 services letter have?',
validators=[
DataRequired()
]
)
class Whitelist(Form):
def populate(self, email_addresses, phone_numbers):

View File

@@ -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_id>/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'])