use new letter branding instead of dvla organisation id

new code is copied stylistically from the email branding patterns.
Instead of `service.dvla_organisation`, there's now
`service.letter_branding` and `service.letter_branding_id`. However,
unlike email branding we're not currently showing a preview of the
logo. That can come later when we work out how we want to do it.
This commit is contained in:
Leo Hemsted
2019-02-01 16:34:54 +00:00
parent 0e20ca44a3
commit a1caf77b0e
7 changed files with 49 additions and 19 deletions

View File

@@ -807,6 +807,11 @@ class ServiceSetEmailBranding(StripWhitespaceForm):
)
class ServiceSetLetterBranding(ServiceSetEmailBranding):
# form is the same, but instead of GOV.UK we have None as a valid option
DEFAULT = (FieldWithNoneOption.NONE_OPTION_VALUE, 'None')
class ServicePreviewBranding(StripWhitespaceForm):
branding_style = HiddenFieldWithNoneOption('branding_style')

View File

@@ -46,6 +46,7 @@ from app.main.forms import (
ServicePreviewBranding,
ServiceReplyToEmailForm,
ServiceSetEmailBranding,
ServiceSetLetterBranding,
ServiceSmsSenderForm,
ServiceSwitchChannelForm,
SMSPrefixForm,
@@ -805,16 +806,17 @@ def service_preview_email_branding(service_id):
@main.route("/services/<service_id>/service-settings/set-letter-branding", methods=['GET', 'POST'])
@login_required
@user_is_platform_admin
def set_letter_branding(service_id):
def service_set_letter_branding(service_id):
letter_branding = letter_branding_client.get_all_letter_branding()
form = LetterBranding(
choices=letter_branding_client.get_letter_branding().items(),
dvla_org_id=current_service.dvla_organisation,
form = ServiceSetLetterBranding(
all_branding_options=get_branding_as_value_and_label(letter_branding),
current_branding=current_service.letter_branding_id,
)
if form.validate_on_submit():
current_service.update(
dvla_organisation=form.dvla_org_id.data
letter_branding=form.branding_style.data
)
return redirect(url_for('.service_settings', service_id=service_id))
@@ -822,6 +824,7 @@ def set_letter_branding(service_id):
'views/service-settings/set-letter-branding.html',
form=form,
search_form=SearchTemplatesForm(),
show_search_box=(len(letter_branding) > 6)
)