mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Merge pull request #1843 from gov-cjwaszczuk/organisations-to-email-branding
Change organisations to email branding
This commit is contained in:
@@ -49,7 +49,7 @@ from app.notify_client.template_statistics_api_client import TemplateStatisticsA
|
||||
from app.notify_client.user_api_client import UserApiClient
|
||||
from app.notify_client.events_api_client import EventsApiClient
|
||||
from app.notify_client.provider_client import ProviderClient
|
||||
from app.notify_client.organisations_client import OrganisationsClient
|
||||
from app.notify_client.email_branding_client import EmailBrandingClient
|
||||
from app.notify_client.models import AnonymousUser
|
||||
from app.notify_client.letter_jobs_client import LetterJobsClient
|
||||
from app.notify_client.inbound_number_client import InboundNumberClient
|
||||
@@ -71,7 +71,7 @@ invite_api_client = InviteApiClient()
|
||||
template_statistics_client = TemplateStatisticsApiClient()
|
||||
events_api_client = EventsApiClient()
|
||||
provider_client = ProviderClient()
|
||||
organisations_client = OrganisationsClient()
|
||||
email_branding_client = EmailBrandingClient()
|
||||
asset_fingerprinter = AssetFingerprinter()
|
||||
statsd_client = StatsdClient()
|
||||
deskpro_client = DeskproClient()
|
||||
@@ -107,7 +107,7 @@ def create_app(application):
|
||||
template_statistics_client.init_app(application)
|
||||
events_api_client.init_app(application)
|
||||
provider_client.init_app(application)
|
||||
organisations_client.init_app(application)
|
||||
email_branding_client.init_app(application)
|
||||
letter_jobs_client.init_app(application)
|
||||
inbound_number_client.init_app(application)
|
||||
billing_api_client.init_app(application)
|
||||
|
||||
@@ -59,3 +59,14 @@
|
||||
padding-left: 5px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.textbox-colour-preview {
|
||||
@include media(desktop) {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
margin-left: 5px;
|
||||
border: 2px solid #0B0C0C;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ from app.main.views import ( # noqa
|
||||
providers,
|
||||
platform_admin,
|
||||
letter_jobs,
|
||||
organisations,
|
||||
email_branding,
|
||||
conversation,
|
||||
notifications,
|
||||
inbound_number
|
||||
|
||||
@@ -598,52 +598,70 @@ class ServiceSwitchLettersForm(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class ServiceBrandingOrg(StripWhitespaceForm):
|
||||
class ServiceSetBranding(StripWhitespaceForm):
|
||||
|
||||
def __init__(self, organisations=[], *args, **kwargs):
|
||||
self.organisation.choices = organisations
|
||||
super(ServiceBrandingOrg, self).__init__(*args, **kwargs)
|
||||
def __init__(self, email_branding=[], *args, **kwargs):
|
||||
self.branding_style.choices = email_branding
|
||||
super(ServiceSetBranding, self).__init__(*args, **kwargs)
|
||||
|
||||
branding_type = RadioField(
|
||||
'Branding',
|
||||
'Branding type',
|
||||
choices=[
|
||||
('govuk', 'GOV.UK only'),
|
||||
('both', 'GOV.UK and organisation'),
|
||||
('org', 'Organisation only'),
|
||||
('org_banner', 'Organisation banner')
|
||||
('both', 'GOV.UK and branding'),
|
||||
('org', 'Branding only'),
|
||||
('org_banner', 'Branding banner')
|
||||
],
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
organisation = RadioField(
|
||||
'Organisation',
|
||||
branding_style = RadioField(
|
||||
'Branding style',
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ServiceSelectOrg(StripWhitespaceForm):
|
||||
class ServiceSelectEmailBranding(StripWhitespaceForm):
|
||||
|
||||
def __init__(self, organisations=[], *args, **kwargs):
|
||||
self.organisation.choices = organisations
|
||||
super(ServiceSelectOrg, self).__init__(*args, **kwargs)
|
||||
def __init__(self, email_brandings=[], *args, **kwargs):
|
||||
self.email_branding.choices = email_brandings
|
||||
super(ServiceSelectEmailBranding, self).__init__(*args, **kwargs)
|
||||
|
||||
organisation = RadioField(
|
||||
'Organisation',
|
||||
email_branding = RadioField(
|
||||
'Email branding',
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ServiceManageOrg(StripWhitespaceForm):
|
||||
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name')
|
||||
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')
|
||||
]
|
||||
)
|
||||
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
||||
|
||||
colour = StringField('Colour', render_kw={'onkeyup': 'update_colour_span()', 'onblur': 'update_colour_span()'})
|
||||
|
||||
class ServiceCreateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name')
|
||||
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')
|
||||
]
|
||||
)
|
||||
file = FileField_wtf('Upload a PNG logo', validators=[FileAllowed(['png'], 'PNG Images only!')])
|
||||
|
||||
|
||||
|
||||
134
app/main/views/email_branding.py
Normal file
134
app/main/views/email_branding.py
Normal file
@@ -0,0 +1,134 @@
|
||||
from flask import current_app, redirect, render_template, session, url_for
|
||||
from flask_login import login_required
|
||||
|
||||
from app import email_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
ServiceSelectEmailBranding,
|
||||
ServiceUpdateEmailBranding,
|
||||
ServiceCreateEmailBranding
|
||||
)
|
||||
from app.utils import user_has_permissions, get_cdn_domain
|
||||
from app.main.s3_client import (
|
||||
TEMP_TAG,
|
||||
upload_logo,
|
||||
delete_temp_file,
|
||||
delete_temp_files_created_by,
|
||||
persist_logo
|
||||
)
|
||||
from app.main.views.service_settings import get_branding_as_value_and_label, get_branding_as_dict
|
||||
|
||||
|
||||
@main.route("/email-branding", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def email_branding():
|
||||
brandings = email_branding_client.get_all_email_branding()
|
||||
|
||||
form = ServiceSelectEmailBranding()
|
||||
form.email_branding.choices = get_branding_as_value_and_label(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))
|
||||
else:
|
||||
return redirect(url_for('.create_email_branding'))
|
||||
|
||||
return render_template(
|
||||
'views/email-branding/select-branding.html',
|
||||
form=form,
|
||||
branding_dict=get_branding_as_dict(brandings),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/email-branding/<branding_id>/edit", methods=['GET', 'POST'])
|
||||
@main.route("/email-branding/<branding_id>/edit/<logo>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def update_email_branding(branding_id, logo=None):
|
||||
email_branding = email_branding_client.get_email_branding(branding_id)['email_branding']
|
||||
|
||||
form = ServiceUpdateEmailBranding()
|
||||
|
||||
logo = logo if logo else email_branding.get('logo') if email_branding else None
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.file.data:
|
||||
upload_filename = upload_logo(
|
||||
form.file.data.filename,
|
||||
form.file.data,
|
||||
current_app.config['AWS_REGION'],
|
||||
user_id=session["user_id"]
|
||||
)
|
||||
|
||||
if logo and logo.startswith(TEMP_TAG.format(user_id=session['user_id'])):
|
||||
delete_temp_file(logo)
|
||||
|
||||
return redirect(url_for('.update_email_branding', branding_id=branding_id, logo=upload_filename))
|
||||
|
||||
if logo:
|
||||
logo = persist_logo(logo, session["user_id"])
|
||||
|
||||
delete_temp_files_created_by(session["user_id"])
|
||||
|
||||
email_branding_client.update_email_branding(
|
||||
branding_id=branding_id,
|
||||
logo=logo,
|
||||
name=form.name.data,
|
||||
colour=form.colour.data
|
||||
)
|
||||
|
||||
return redirect(url_for('.email_branding', branding_id=branding_id))
|
||||
|
||||
form.name.data = email_branding['name']
|
||||
form.colour.data = email_branding['colour']
|
||||
|
||||
return render_template(
|
||||
'views/email-branding/manage-branding.html',
|
||||
form=form,
|
||||
email_branding=email_branding,
|
||||
cdn_url=get_cdn_domain(),
|
||||
logo=logo
|
||||
)
|
||||
|
||||
|
||||
@main.route("/email-branding/create", methods=['GET', 'POST'])
|
||||
@main.route("/email-branding/create/<logo>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def create_email_branding(logo=None):
|
||||
form = ServiceCreateEmailBranding()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.file.data:
|
||||
upload_filename = upload_logo(
|
||||
form.file.data.filename,
|
||||
form.file.data,
|
||||
current_app.config['AWS_REGION'],
|
||||
user_id=session["user_id"]
|
||||
)
|
||||
|
||||
if logo and logo.startswith(TEMP_TAG.format(user_id=session['user_id'])):
|
||||
delete_temp_file(logo)
|
||||
|
||||
return redirect(url_for('.create_email_branding', logo=upload_filename))
|
||||
|
||||
if logo:
|
||||
logo = persist_logo(logo, session["user_id"])
|
||||
|
||||
delete_temp_files_created_by(session["user_id"])
|
||||
|
||||
email_branding_client.create_email_branding(
|
||||
logo=logo,
|
||||
name=form.name.data,
|
||||
colour=form.colour.data
|
||||
)
|
||||
|
||||
return redirect(url_for('.email_branding'))
|
||||
|
||||
return render_template(
|
||||
'views/email-branding/manage-branding.html',
|
||||
form=form,
|
||||
cdn_url=get_cdn_domain(),
|
||||
logo=logo
|
||||
)
|
||||
@@ -1,99 +0,0 @@
|
||||
from flask import current_app, redirect, render_template, session, url_for
|
||||
from flask_login import login_required
|
||||
|
||||
from app import organisations_client
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
ServiceSelectOrg,
|
||||
ServiceManageOrg)
|
||||
from app.utils import user_has_permissions, get_cdn_domain
|
||||
from app.main.s3_client import (
|
||||
TEMP_TAG,
|
||||
upload_logo,
|
||||
delete_temp_file,
|
||||
delete_temp_files_created_by,
|
||||
persist_logo
|
||||
)
|
||||
from app.main.views.service_settings import get_branding_as_value_and_label, get_branding_as_dict
|
||||
|
||||
|
||||
@main.route("/organisations", methods=['GET', 'POST'])
|
||||
@main.route("/organisations/<organisation_id>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def organisations(organisation_id=None):
|
||||
orgs = organisations_client.get_organisations()
|
||||
|
||||
form = ServiceSelectOrg()
|
||||
form.organisation.choices = get_branding_as_value_and_label(orgs) + [('None', 'Create a new organisation')]
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.organisation.data != 'None':
|
||||
session['organisation'] = [o for o in orgs if o['id'] == form.organisation.data][0]
|
||||
elif session.get('organisation'):
|
||||
del session['organisation']
|
||||
|
||||
return redirect(url_for('.manage_org'))
|
||||
|
||||
form.organisation.data = organisation_id if organisation_id in [o['id'] for o in orgs] else 'None'
|
||||
|
||||
return render_template(
|
||||
'views/organisations/select-org.html',
|
||||
form=form,
|
||||
branding_dict=get_branding_as_dict(orgs),
|
||||
organisation_id=organisation_id
|
||||
)
|
||||
|
||||
|
||||
@main.route("/organisations/manage", methods=['GET', 'POST'])
|
||||
@main.route("/organisations/manage/<logo>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def manage_org(logo=None):
|
||||
form = ServiceManageOrg()
|
||||
|
||||
org = session.get("organisation")
|
||||
|
||||
logo = logo if logo else org.get('logo') if org else None
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.file.data:
|
||||
upload_filename = upload_logo(
|
||||
form.file.data.filename,
|
||||
form.file.data,
|
||||
current_app.config['AWS_REGION'],
|
||||
user_id=session["user_id"]
|
||||
)
|
||||
|
||||
if logo and logo.startswith(TEMP_TAG.format(user_id=session['user_id'])):
|
||||
delete_temp_file(logo)
|
||||
|
||||
return redirect(
|
||||
url_for('.manage_org', logo=upload_filename))
|
||||
|
||||
if logo:
|
||||
logo = persist_logo(logo, session["user_id"])
|
||||
|
||||
delete_temp_files_created_by(session["user_id"])
|
||||
|
||||
if org:
|
||||
organisations_client.update_organisation(
|
||||
org_id=org['id'], logo=logo, name=form.name.data, colour=form.colour.data)
|
||||
org_id = org['id']
|
||||
else:
|
||||
resp = organisations_client.create_organisation(
|
||||
logo=logo, name=form.name.data, colour=form.colour.data)
|
||||
org_id = resp['data']['id']
|
||||
|
||||
return redirect(url_for('.organisations', organisation_id=org_id))
|
||||
if org:
|
||||
form.name.data = org['name']
|
||||
form.colour.data = org['colour']
|
||||
|
||||
return render_template(
|
||||
'views/organisations/manage-org.html',
|
||||
form=form,
|
||||
organisation=org,
|
||||
cdn_url=get_cdn_domain(),
|
||||
logo=logo
|
||||
)
|
||||
@@ -28,7 +28,7 @@ from app.main.forms import (
|
||||
ServiceInboundNumberForm,
|
||||
ServiceSmsSenderForm,
|
||||
ServiceLetterContactBlockForm,
|
||||
ServiceBrandingOrg,
|
||||
ServiceSetBranding,
|
||||
LetterBranding,
|
||||
InternationalSMSForm,
|
||||
OrganisationTypeForm,
|
||||
@@ -37,7 +37,7 @@ from app.main.forms import (
|
||||
SMSPrefixForm,
|
||||
ServiceSwitchLettersForm,
|
||||
)
|
||||
from app import user_api_client, current_service, organisations_client, inbound_number_client, billing_api_client
|
||||
from app import user_api_client, current_service, email_branding_client, inbound_number_client, billing_api_client
|
||||
from notifications_utils.formatters import formatted_list
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ from notifications_utils.formatters import formatted_list
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_settings(service_id):
|
||||
letter_branding_organisations = organisations_client.get_letter_organisations()
|
||||
if current_service['organisation']:
|
||||
organisation = organisations_client.get_organisation(current_service['organisation'])['organisation']
|
||||
letter_branding_organisations = email_branding_client.get_letter_email_branding()
|
||||
if current_service['email_branding']:
|
||||
email_branding = email_branding_client.get_email_branding(current_service['email_branding'])['email_branding']
|
||||
else:
|
||||
organisation = None
|
||||
email_branding = None
|
||||
|
||||
inbound_number = inbound_number_client.get_inbound_sms_number_for_service(service_id)
|
||||
disp_inbound_number = inbound_number['data'].get('number', '')
|
||||
@@ -73,7 +73,7 @@ def service_settings(service_id):
|
||||
|
||||
return render_template(
|
||||
'views/service-settings.html',
|
||||
organisation=organisation,
|
||||
email_branding=email_branding,
|
||||
letter_branding=letter_branding_organisations.get(
|
||||
current_service.get('dvla_organisation', '001')
|
||||
),
|
||||
@@ -711,32 +711,32 @@ def set_free_sms_allowance(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/set-branding-and-org", methods=['GET', 'POST'])
|
||||
@main.route("/services/<service_id>/service-settings/set-email-branding", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def service_set_branding_and_org(service_id):
|
||||
organisations = organisations_client.get_organisations()
|
||||
def service_set_email_branding(service_id):
|
||||
email_branding = email_branding_client.get_all_email_branding()
|
||||
|
||||
form = ServiceBrandingOrg(branding_type=current_service.get('branding'))
|
||||
form = ServiceSetBranding(branding_type=current_service.get('branding'))
|
||||
|
||||
# dynamically create org choices, including the null option
|
||||
form.organisation.choices = [('None', 'None')] + get_branding_as_value_and_label(organisations)
|
||||
form.branding_style.choices = [('None', 'None')] + get_branding_as_value_and_label(email_branding)
|
||||
|
||||
if form.validate_on_submit():
|
||||
organisation = None if form.organisation.data == 'None' else form.organisation.data
|
||||
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,
|
||||
organisation=organisation
|
||||
email_branding=branding_style
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
form.organisation.data = current_service['organisation'] or 'None'
|
||||
form.branding_style.data = current_service['email_branding'] or 'None'
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/set-branding-and-org.html',
|
||||
'views/service-settings/set-email-branding.html',
|
||||
form=form,
|
||||
branding_dict=get_branding_as_dict(organisations)
|
||||
branding_dict=get_branding_as_dict(email_branding)
|
||||
)
|
||||
|
||||
|
||||
@@ -745,7 +745,7 @@ def service_set_branding_and_org(service_id):
|
||||
@user_has_permissions(admin_override=True)
|
||||
def set_letter_branding(service_id):
|
||||
|
||||
form = LetterBranding(choices=organisations_client.get_letter_organisations().items())
|
||||
form = LetterBranding(choices=email_branding_client.get_letter_email_branding().items())
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service(
|
||||
@@ -762,17 +762,17 @@ def set_letter_branding(service_id):
|
||||
)
|
||||
|
||||
|
||||
def get_branding_as_value_and_label(organisations):
|
||||
def get_branding_as_value_and_label(email_branding):
|
||||
return [
|
||||
(organisation['id'], organisation['name'])
|
||||
for organisation in organisations
|
||||
(branding['id'], branding['name'])
|
||||
for branding in email_branding
|
||||
]
|
||||
|
||||
|
||||
def get_branding_as_dict(organisations):
|
||||
def get_branding_as_dict(email_branding):
|
||||
return {
|
||||
organisation['id']: {
|
||||
'logo': 'https://{}/{}'.format(get_cdn_domain(), organisation['logo']),
|
||||
'colour': organisation['colour']
|
||||
} for organisation in organisations
|
||||
branding['id']: {
|
||||
'logo': 'https://{}/{}'.format(get_cdn_domain(), branding['logo']),
|
||||
'colour': branding['colour']
|
||||
} for branding in email_branding
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class OrganisationsClient(NotifyAdminAPIClient):
|
||||
class EmailBrandingClient(NotifyAdminAPIClient):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
@@ -11,27 +11,27 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||
|
||||
def get_organisation(self, id):
|
||||
return self.get(url='/organisation/{}'.format(id))
|
||||
def get_email_branding(self, branding_id):
|
||||
return self.get(url='/email-branding/{}'.format(branding_id))
|
||||
|
||||
def get_organisations(self):
|
||||
return self.get(url='/organisation')['organisations']
|
||||
def get_all_email_branding(self):
|
||||
return self.get(url='/email-branding')['email_branding']
|
||||
|
||||
def get_letter_organisations(self):
|
||||
def get_letter_email_branding(self):
|
||||
return self.get(url='/dvla_organisations')
|
||||
|
||||
def create_organisation(self, logo, name, colour):
|
||||
def create_email_branding(self, logo, name, colour):
|
||||
data = {
|
||||
"logo": logo,
|
||||
"name": name,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post(url="/organisation", data=data)
|
||||
return self.post(url="/email-branding", data=data)
|
||||
|
||||
def update_organisation(self, org_id, logo, name, colour):
|
||||
def update_email_branding(self, branding_id, logo, name, colour):
|
||||
data = {
|
||||
"logo": logo,
|
||||
"name": name,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post(url="/organisation/{}".format(org_id), data=data)
|
||||
return self.post(url="/email-branding/{}".format(branding_id), data=data)
|
||||
@@ -99,7 +99,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
'sms_sender',
|
||||
'created_by',
|
||||
'branding',
|
||||
'organisation',
|
||||
'email_branding',
|
||||
'letter_contact_block',
|
||||
'dvla_organisation',
|
||||
'permissions',
|
||||
|
||||
@@ -57,3 +57,29 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro colour_textbox(
|
||||
field,
|
||||
width='2-3',
|
||||
colour='#FFFFFF'
|
||||
) %}
|
||||
<div class="form-group{% if field.errors %} form-group-error{% endif %}">
|
||||
<label class="form-label" for="{{ field.name }}">
|
||||
{{ field.label.text }}
|
||||
{% if field.errors %}
|
||||
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
||||
{{ field.errors[0] }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</label>
|
||||
{% set field_class = 'form-control-{} {}'.format(width, 'textbox-right-aligned' if suffix else '') %}
|
||||
{% set field_class = 'form-control ' + field_class + (' form-control-error' if field.errors else '') %}
|
||||
{{ field(
|
||||
class=field_class,
|
||||
data_module='',
|
||||
rows='1',
|
||||
**kwargs
|
||||
) }}
|
||||
<span class="textbox-colour-preview" style="background:{{ colour }}"></span>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
45
app/templates/views/email-branding/manage-branding.html
Normal file
45
app/templates/views/email-branding/manage-branding.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{% extends "views/platform-admin/_base_template.html" %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/textbox.html" import textbox, colour_textbox %}
|
||||
|
||||
{% block service_page_title %}
|
||||
{{ '{} email branding'.format('Update' if email_branding else 'Create')}}
|
||||
{% endblock %}
|
||||
|
||||
{% block platform_admin_content %}
|
||||
|
||||
<h1 class="heading-large">{{ '{} email branding'.format('Update' if email_branding else 'Create')}}</h1>
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
|
||||
{% if logo %}
|
||||
<div id="logo-img">
|
||||
<img src="https://{{ cdn_url }}/{{ logo }}"/>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ file_upload(form.file, button_text='{} logo'.format('Update' if email_branding else 'Upload')) }}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<div style='margin-top:15px;'>{{textbox(form.name)}}</div>
|
||||
{{colour_textbox(form.colour, width='1-4', colour=email_branding.colour if email_branding)}}
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
back_link=url_for('.email_branding'),
|
||||
back_link_text='Back to email branding selection',
|
||||
) }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function update_colour(element){
|
||||
colour_preview = document.getElementsByClassName("textbox-colour-preview")[0];
|
||||
if (element.value.match(/^#[0-9A-F]{6}$/i)) {
|
||||
colour_preview.style.background = element.value;
|
||||
} else {
|
||||
colour_preview.style.background = '#FFFFFF';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -3,19 +3,19 @@
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Select organisation
|
||||
Select email branding
|
||||
{% endblock %}
|
||||
|
||||
{% block platform_admin_content %}
|
||||
|
||||
<h1 class="heading-large">
|
||||
<div>Select an organisation to update</div>
|
||||
<div>or create a new organisation</div>
|
||||
<div>Select an email branding to update</div>
|
||||
<div>or create a new email branding</div>
|
||||
</h1>
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<form method="post">
|
||||
{{ branding_radios(form.organisation, branding_dict=branding_dict, show_header=False) }}
|
||||
{{ branding_radios(form.email_branding, branding_dict=branding_dict, show_header=False) }}
|
||||
{{ page_footer(
|
||||
'Next'
|
||||
) }}
|
||||
@@ -1,54 +0,0 @@
|
||||
{% extends "views/platform-admin/_base_template.html" %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
|
||||
{% block service_page_title %}
|
||||
{{ '{} an organisations logo'.format('Update' if organisation else 'Create')}}
|
||||
{% endblock %}
|
||||
|
||||
{% block platform_admin_content %}
|
||||
|
||||
<h1 class="heading-large">{{ '{} an organisations logo'.format('Update' if organisation else 'Create')}}</h1>
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
|
||||
{% if logo %}
|
||||
<div id="logo-img">
|
||||
<img src="https://{{ cdn_url }}/{{ logo }}"/>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{
|
||||
file_upload(
|
||||
form.file,
|
||||
button_text='{} logo'.format('Update' if organisation else 'Upload')
|
||||
) }}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<div style='margin-top:15px;'>{{textbox(form.name)}}</div>
|
||||
<div>{{textbox(form.colour, width='1-4')}}
|
||||
<span id='colour_span' style="background: {{ organisation.colour }}; {% if not organisation.colour %}visibility:hidden; {% endif %}border:1px black solid; width: 3px; height: 25px;position:absolute;margin-top:138px;margin-left:135px;display:block;"></span>
|
||||
</div>
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
back_link=url_for('.organisations', organisation_id=organisation.id if organisation else 'None'),
|
||||
back_link_text='Back to organisation selection',
|
||||
) }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function update_colour_span() {
|
||||
document.getElementById('colour_span').style.background = '';
|
||||
if (document.getElementById('colour').value) {
|
||||
document.getElementById('colour_span').style.visibility = 'visible';
|
||||
document.getElementById('colour_span').style.background = document.getElementById('colour').value;
|
||||
}
|
||||
else {
|
||||
document.getElementById('colour_span').style.visibility = 'hidden';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -16,7 +16,7 @@
|
||||
('Live services', url_for('main.live_services')),
|
||||
('Trial mode services', url_for('main.trial_services')),
|
||||
('Providers', url_for('main.view_providers')),
|
||||
('Organisations', url_for('main.organisations')),
|
||||
('Email branding', url_for('main.email_branding')),
|
||||
('Letter jobs', url_for('main.letter_jobs')),
|
||||
('Inbound SMS numbers', url_for('main.inbound_sms_admin'))
|
||||
] %}
|
||||
|
||||
@@ -211,14 +211,14 @@
|
||||
{% if current_service.branding == 'govuk' %}
|
||||
GOV.UK
|
||||
{% elif current_service.branding == 'both' %}
|
||||
GOV.UK and {{ organisation.name if organisation else None }}
|
||||
GOV.UK and {{ email_branding.name if email_branding else None }}
|
||||
{% elif current_service.branding == 'org' %}
|
||||
Only {{ organisation.name if organisation else None }}
|
||||
Only {{ email_branding.name if email_branding else None }}
|
||||
{% elif current_service.branding == 'org_banner' %}
|
||||
Only {{ organisation.name if organisation else None }} banner
|
||||
Only {{ email_branding.name if email_branding else None }} banner
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{{ edit_field('Change', url_for('.service_set_branding_and_org', service_id=current_service.id)) }}
|
||||
{{ edit_field('Change', url_for('.service_set_email_branding', service_id=current_service.id)) }}
|
||||
{% endcall %}
|
||||
{% call row() %}
|
||||
{{ text_field('Letter branding')}}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Set branding and organisation
|
||||
Set email branding
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="column-three-quarters">
|
||||
<form method="post">
|
||||
{{ radios(form.branding_type) }}
|
||||
{{ branding_radios(form.organisation, branding_dict=branding_dict) }}
|
||||
{{ branding_radios(form.branding_style, branding_dict=branding_dict) }}
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
back_link=url_for('.service_settings', service_id=current_service.id),
|
||||
Reference in New Issue
Block a user