mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Created a method to decide which colour to pass into the notifications-utils method to preview the template.
Removed the ServiceCreateEmailBranding form - it is identical to the other form.
This commit is contained in:
@@ -756,35 +756,6 @@ class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
||||
|
||||
|
||||
class ServiceCreateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name of brand')
|
||||
text = StringField('Text')
|
||||
domain = StringField('Domain')
|
||||
colour = StringField(
|
||||
'Colour',
|
||||
render_kw={'onchange': 'update_colour(this)'},
|
||||
validators=[
|
||||
Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code')
|
||||
]
|
||||
)
|
||||
banner_colour = StringField(
|
||||
'Banner colour',
|
||||
render_kw={'onchange': 'update_colour(this)'},
|
||||
validators=[
|
||||
Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code')
|
||||
]
|
||||
)
|
||||
single_id_colour = StringField(
|
||||
'Single identity colour',
|
||||
render_kw={'onchange': 'update_colour(this)'},
|
||||
validators=[
|
||||
Regexp(regex="^$|^#(?:[0-9a-fA-F]{3}){1,2}$", message='Must be a valid color hex code')
|
||||
]
|
||||
)
|
||||
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
||||
|
||||
|
||||
class CreateOrUpdateOrganisation(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name', validators=[DataRequired()])
|
||||
|
||||
@@ -4,7 +4,6 @@ from flask_login import login_required
|
||||
from app import email_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
ServiceCreateEmailBranding,
|
||||
ServiceSelectEmailBranding,
|
||||
ServiceUpdateEmailBranding,
|
||||
)
|
||||
@@ -109,7 +108,7 @@ def update_email_branding(branding_id, logo=None):
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def create_email_branding(logo=None):
|
||||
form = ServiceCreateEmailBranding()
|
||||
form = ServiceUpdateEmailBranding()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.file.data:
|
||||
|
||||
@@ -78,6 +78,13 @@ 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')
|
||||
@@ -91,8 +98,9 @@ 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)
|
||||
brand_name = email_branding['text']
|
||||
brand_colour = email_branding['colour']
|
||||
brand_colour = colour
|
||||
brand_logo = 'https://{}/{}'.format(get_cdn_domain(), email_branding['logo'])
|
||||
govuk_banner = branding_type in ['govuk', 'both']
|
||||
brand_banner = branding_type == 'org_banner'
|
||||
|
||||
Reference in New Issue
Block a user