Make logo CDN domain into simple config

Having this as a function which does string parsing and manipulation
surprised me a bit when I was trying to figure out why something wasn’t
working.

It’s more in line with the way we do other config like this (for example
`ASSET_PATH`) to make it a simple config variable, rather than trying to
be clever and guess things based on other config variables.

It’s also less code, and is explicit enough that it doesn’t need tests.
This commit is contained in:
Chris Hill-Scott
2022-01-26 14:44:33 +00:00
parent 2224eacf6b
commit 4f672cb5dc
8 changed files with 19 additions and 40 deletions

View File

@@ -11,7 +11,6 @@ from app.s3_client.s3_logo_client import (
persist_logo,
upload_email_logo,
)
from app.utils import get_logo_cdn_domain
from app.utils.user import user_is_platform_admin
@@ -78,7 +77,7 @@ def update_email_branding(branding_id, logo=None):
'views/email-branding/manage-branding.html',
form=form,
email_branding=email_branding,
cdn_url=get_logo_cdn_domain(),
cdn_url=current_app.config['LOGO_CDN_DOMAIN'],
logo=logo
)
@@ -123,6 +122,6 @@ def create_email_branding(logo=None):
return render_template(
'views/email-branding/manage-branding.html',
form=form,
cdn_url=get_logo_cdn_domain(),
cdn_url=current_app.config['LOGO_CDN_DOMAIN'],
logo=logo
)

View File

@@ -1,5 +1,6 @@
from flask import (
abort,
current_app,
make_response,
redirect,
render_template,
@@ -16,7 +17,7 @@ from app.main.views.sub_navigation_dictionaries import (
features_nav,
using_notify_nav,
)
from app.utils import get_logo_cdn_domain, hide_from_search_engines
from app.utils import hide_from_search_engines
@main.route('/')
@@ -87,7 +88,7 @@ def email_template():
colour = email_branding['colour']
brand_text = email_branding['text']
brand_colour = colour
brand_logo = ('https://{}/{}'.format(get_logo_cdn_domain(), email_branding['logo'])
brand_logo = (f"https://{current_app.config['LOGO_CDN_DOMAIN']}/{email_branding['logo']}"
if email_branding['logo'] else None)
govuk_banner = branding_type in ['govuk', 'both']
brand_banner = branding_type == 'org_banner'

View File

@@ -25,7 +25,6 @@ from app.s3_client.s3_logo_client import (
persist_logo,
upload_letter_temp_logo,
)
from app.utils import get_logo_cdn_domain
from app.utils.user import user_is_platform_admin
@@ -113,7 +112,7 @@ def update_letter_branding(branding_id, logo=None):
'views/letter-branding/manage-letter-branding.html',
file_upload_form=file_upload_form,
letter_branding_details_form=letter_branding_details_form,
cdn_url=get_logo_cdn_domain(),
cdn_url=current_app.config['LOGO_CDN_DOMAIN'],
logo=logo,
is_update=True
)
@@ -169,7 +168,7 @@ def create_letter_branding(logo=None):
'views/letter-branding/manage-letter-branding.html',
file_upload_form=file_upload_form,
letter_branding_details_form=letter_branding_details_form,
cdn_url=get_logo_cdn_domain(),
cdn_url=current_app.config['LOGO_CDN_DOMAIN'],
logo=logo
)