mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 03:03:13 -04:00
improve range of params email page can take
Can now deal with no query params and has a default format of the GOV.UK branding.
This commit is contained in:
@@ -1,15 +1,22 @@
|
|||||||
from flask import abort, redirect, render_template, request, url_for
|
from flask import (
|
||||||
|
abort,
|
||||||
|
make_response,
|
||||||
|
redirect,
|
||||||
|
render_template,
|
||||||
|
request,
|
||||||
|
url_for,
|
||||||
|
)
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from notifications_utils.international_billing_rates import (
|
from notifications_utils.international_billing_rates import (
|
||||||
INTERNATIONAL_BILLING_RATES,
|
INTERNATIONAL_BILLING_RATES,
|
||||||
)
|
)
|
||||||
from notifications_utils.template import HTMLEmailTemplate
|
from notifications_utils.template import HTMLEmailTemplate
|
||||||
|
|
||||||
from app import convert_to_boolean
|
from app import email_branding_client
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.main.forms import SearchTemplatesForm
|
from app.main.forms import SearchTemplatesForm
|
||||||
from app.main.views.sub_navigation_dictionaries import features_nav
|
from app.main.views.sub_navigation_dictionaries import features_nav
|
||||||
from app.utils import AgreementInfo
|
from app.utils import AgreementInfo, get_cdn_domain
|
||||||
|
|
||||||
|
|
||||||
@main.route('/')
|
@main.route('/')
|
||||||
@@ -73,45 +80,79 @@ def design_content():
|
|||||||
|
|
||||||
@main.route('/_email')
|
@main.route('/_email')
|
||||||
def email_template():
|
def email_template():
|
||||||
return str(HTMLEmailTemplate({'subject': 'foo', 'content': (
|
branding_type = request.args.get('branding_type', 'govuk')
|
||||||
'Lorem Ipsum is simply dummy text of the printing and typesetting '
|
branding_style = request.args.get('branding_style', 'None')
|
||||||
'industry.\n\nLorem Ipsum has been the industry’s standard dummy '
|
|
||||||
'text ever since the 1500s, when an unknown printer took a galley '
|
if branding_type == 'govuk' or branding_style == 'None':
|
||||||
'of type and scrambled it to make a type specimen book. '
|
brand_name = None
|
||||||
'\n\n'
|
brand_colour = None
|
||||||
'# History'
|
brand_logo = None
|
||||||
'\n\n'
|
govuk_banner = True
|
||||||
'It has '
|
brand_banner = False
|
||||||
'survived not only'
|
else:
|
||||||
'\n\n'
|
email_branding = email_branding_client.get_email_branding(branding_style)['email_branding']
|
||||||
'* five centuries'
|
brand_name = email_branding['name']
|
||||||
'\n'
|
brand_colour = email_branding['colour']
|
||||||
'* but also the leap into electronic typesetting'
|
brand_logo = 'https://{}/{}'.format(get_cdn_domain(), email_branding['logo'])
|
||||||
'\n\n'
|
govuk_banner = branding_type in ['govuk', 'both']
|
||||||
'It was '
|
brand_banner = branding_type == 'org_banner'
|
||||||
'popularised in the 1960s with the release of Letraset sheets '
|
|
||||||
'containing Lorem Ipsum passages, and more recently with desktop '
|
template = {
|
||||||
'publishing software like Aldus PageMaker including versions of '
|
'subject': 'foo',
|
||||||
'Lorem Ipsum.'
|
'content': (
|
||||||
'\n\n'
|
'Lorem Ipsum is simply dummy text of the printing and typesetting '
|
||||||
'^ It is a long established fact that a reader will be distracted '
|
'industry.\n\nLorem Ipsum has been the industry’s standard dummy '
|
||||||
'by the readable content of a page when looking at its layout.'
|
'text ever since the 1500s, when an unknown printer took a galley '
|
||||||
'\n\n'
|
'of type and scrambled it to make a type specimen book. '
|
||||||
'The point of using Lorem Ipsum is that it has a more-or-less '
|
'\n\n'
|
||||||
'normal distribution of letters, as opposed to using ‘Content '
|
'# History'
|
||||||
'here, content here’, making it look like readable English.'
|
'\n\n'
|
||||||
'\n\n\n'
|
'It has '
|
||||||
'1. One'
|
'survived not only'
|
||||||
'\n'
|
'\n\n'
|
||||||
'2. Two'
|
'* five centuries'
|
||||||
'\n'
|
'\n'
|
||||||
'10. Three'
|
'* but also the leap into electronic typesetting'
|
||||||
'\n\n'
|
'\n\n'
|
||||||
'This is an example of an email sent using GOV.UK Notify.'
|
'It was '
|
||||||
'\n\n'
|
'popularised in the 1960s with the release of Letraset sheets '
|
||||||
'https://www.notifications.service.gov.uk'
|
'containing Lorem Ipsum passages, and more recently with desktop '
|
||||||
)}, govuk_banner=convert_to_boolean(request.args.get('govuk_banner', True))
|
'publishing software like Aldus PageMaker including versions of '
|
||||||
))
|
'Lorem Ipsum.'
|
||||||
|
'\n\n'
|
||||||
|
'^ It is a long established fact that a reader will be distracted '
|
||||||
|
'by the readable content of a page when looking at its layout.'
|
||||||
|
'\n\n'
|
||||||
|
'The point of using Lorem Ipsum is that it has a more-or-less '
|
||||||
|
'normal distribution of letters, as opposed to using ‘Content '
|
||||||
|
'here, content here’, making it look like readable English.'
|
||||||
|
'\n\n\n'
|
||||||
|
'1. One'
|
||||||
|
'\n'
|
||||||
|
'2. Two'
|
||||||
|
'\n'
|
||||||
|
'10. Three'
|
||||||
|
'\n\n'
|
||||||
|
'This is an example of an email sent using GOV.UK Notify.'
|
||||||
|
'\n\n'
|
||||||
|
'https://www.notifications.service.gov.uk'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if not bool(request.args):
|
||||||
|
resp = make_response(str(HTMLEmailTemplate(template)))
|
||||||
|
else:
|
||||||
|
resp = make_response(str(HTMLEmailTemplate(
|
||||||
|
template,
|
||||||
|
govuk_banner=govuk_banner,
|
||||||
|
brand_name=brand_name,
|
||||||
|
brand_colour=brand_colour,
|
||||||
|
brand_logo=brand_logo,
|
||||||
|
brand_banner=brand_banner,
|
||||||
|
)))
|
||||||
|
|
||||||
|
resp.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
@main.route('/documentation')
|
@main.route('/documentation')
|
||||||
|
|||||||
Reference in New Issue
Block a user