Merge pull request #2262 from alphagov/remove_branding_type_from_set_email_branding_page

Remove branding type from set email branding page
This commit is contained in:
Tom Byers
2018-08-31 13:56:44 +01:00
committed by GitHub
9 changed files with 123 additions and 110 deletions

View File

@@ -682,23 +682,6 @@ class ServiceSwitchLettersForm(StripWhitespaceForm):
class ServiceSetBranding(StripWhitespaceForm):
def __init__(self, email_branding=[], *args, **kwargs):
self.branding_style.choices = email_branding
super(ServiceSetBranding, self).__init__(*args, **kwargs)
branding_type = RadioField(
'Branding type',
choices=[
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and branding'),
('org', 'Branding only'),
('org_banner', 'Branding banner')
],
validators=[
DataRequired()
]
)
branding_style = RadioField(
'Branding style',
validators=[
@@ -709,7 +692,6 @@ class ServiceSetBranding(StripWhitespaceForm):
class ServicePreviewBranding(StripWhitespaceForm):
branding_type = HiddenField('branding_type')
branding_style = HiddenField('branding_style')

View File

@@ -91,17 +91,20 @@ def design_content():
@main.route('/_email')
def email_template():
branding_type = request.args.get('branding_type', 'govuk')
branding_type = 'govuk'
branding_style = request.args.get('branding_style', 'None')
if branding_type == 'govuk' or branding_style == 'None':
if branding_style != 'None':
email_branding = email_branding_client.get_email_branding(branding_style)['email_branding']
branding_type = email_branding['brand_type']
if branding_type == 'govuk':
brand_name = None
brand_colour = None
brand_logo = None
govuk_banner = True
brand_banner = False
else:
email_branding = email_branding_client.get_email_branding(branding_style)['email_branding']
colour = email_branding['colour']
brand_name = email_branding['text']
brand_colour = colour

View File

@@ -874,19 +874,18 @@ def set_free_sms_allowance(service_id):
@user_is_platform_admin
def service_set_email_branding(service_id):
email_branding = email_branding_client.get_all_email_branding()
branding_type = current_service.get('branding')
form = ServiceSetBranding(branding_type=branding_type)
form = ServiceSetBranding()
# dynamically create org choices, including the null option
email_brandings = sorted(get_branding_as_value_and_label(email_branding),
key=lambda tup: tup[1].lower())
form.branding_style.choices = [('None', 'None')] + email_brandings
form.branding_style.choices = [('None', 'GOV.UK')] + email_brandings
if form.validate_on_submit():
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data
return redirect(url_for('.service_preview_email_branding', service_id=service_id,
branding_type=form.branding_type.data, branding_style=branding_style))
branding_style=branding_style))
form.branding_style.data = current_service['email_branding'] or 'None'
@@ -903,16 +902,14 @@ def service_set_email_branding(service_id):
@login_required
@user_is_platform_admin
def service_preview_email_branding(service_id):
branding_type = request.args.get('branding_type', None)
branding_style = request.args.get('branding_style', None)
form = ServicePreviewBranding(branding_type=branding_type, branding_style=branding_style)
form = ServicePreviewBranding(branding_style=branding_style)
if form.validate_on_submit():
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data
service_api_client.update_service(
service_id,
branding=form.branding_type.data,
email_branding=branding_style
)
return redirect(url_for('.service_settings', service_id=service_id))
@@ -992,8 +989,15 @@ def link_service_to_organisation(service_id):
@user_has_permissions('manage_service')
def branding_request(service_id):
branding_type = 'govuk'
if current_service.email_branding:
email_branding = email_branding_client.get_email_branding(
current_service.email_branding)['email_branding']
branding_type = email_branding['brand_type']
form = BrandingOptionsEmail(
options=current_service.branding
options=branding_type
)
if form.validate_on_submit():