Fix the EmailBranding

This commit is contained in:
Rebecca Law
2018-08-23 17:44:34 +01:00
parent 34d938ce18
commit f7f202b670
7 changed files with 51 additions and 99 deletions

View File

@@ -728,17 +728,6 @@ class ServiceSelectEmailBranding(StripWhitespaceForm):
class ServiceUpdateEmailBranding(StripWhitespaceForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.brand_type.choices = filter(None, [
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and branding'),
('org', 'Branding only'),
('org_banner', 'Branding banner'),
])
name = StringField('Name of brand')
text = StringField('Text')
domain = StringField('Domain')
@@ -750,7 +739,13 @@ class ServiceUpdateEmailBranding(StripWhitespaceForm):
)
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
brand_type = RadioField(
"Brand type"
"Brand type",
choices=[
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and branding'),
('org', 'Branding only'),
('org_banner', 'Branding banner'),
]
)

View File

@@ -30,7 +30,6 @@ def email_branding():
form = ServiceSelectEmailBranding()
email_brandings = get_branding_as_value_and_label(brandings)
form.email_branding.choices = email_brandings + [('None', 'Create a new email branding')]
if form.validate_on_submit():
if form.email_branding.data != 'None':
return redirect(url_for('.update_email_branding', branding_id=form.email_branding.data))
@@ -107,7 +106,6 @@ def update_email_branding(branding_id, logo=None):
@user_is_platform_admin
def create_email_branding(logo=None):
form = ServiceUpdateEmailBranding()
if form.validate_on_submit():
if form.file.data:
upload_filename = upload_logo(

View File

@@ -78,13 +78,6 @@ def design_content():
return render_template('views/design-patterns-content-guidance.html')
def _set_colour(branding_style, email_branding):
if branding_style in ['both', 'org']:
return email_branding['single_id_colour'] or email_branding['colour']
elif branding_style == 'org_banner':
return email_branding['banner_colour'] or email_branding['colour']
@main.route('/_email')
def email_template():
branding_type = request.args.get('branding_type', 'govuk')
@@ -98,7 +91,7 @@ def email_template():
brand_banner = False
else:
email_branding = email_branding_client.get_email_branding(branding_style)['email_branding']
colour = _set_colour(branding_type, email_branding)
colour = email_branding['colour']
brand_name = email_branding['text']
brand_colour = colour
brand_logo = 'https://{}/{}'.format(get_cdn_domain(), email_branding['logo'])