mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 18:38:26 -04:00
Split up email branding form into separate pages
We were showing the form to request email branding with a button which submits your choice immediately. Now, we only submit the form immediately if "Something else" is the only branding option available to you. If you select any other radio button (or select "Something else" when it's not the only option) we take you to another page which either contains more information or a textbox to fill in the details for the branding you want. There is currently some duplication between the new pages and their tests, but these will be changed in future versions of the work so will start to differ more.
This commit is contained in:
@@ -65,6 +65,7 @@ from app.main.forms import (
|
||||
SetEmailBranding,
|
||||
SetLetterBranding,
|
||||
SMSPrefixForm,
|
||||
SomethingElseBrandingForm,
|
||||
)
|
||||
from app.utils import DELIVERED_STATUSES, FAILURE_STATUSES, SENDING_STATUSES
|
||||
from app.utils.user import (
|
||||
@@ -1130,34 +1131,58 @@ def link_service_to_organisation(service_id):
|
||||
)
|
||||
|
||||
|
||||
def create_email_branding_zendesk_ticket(form_option_selected, detail=None):
|
||||
form = BrandingOptions(current_service)
|
||||
|
||||
ticket_message = render_template(
|
||||
'support-tickets/branding-request.txt',
|
||||
current_branding=current_service.email_branding_name,
|
||||
branding_requested=dict(form.options.choices)[form_option_selected],
|
||||
detail=detail,
|
||||
)
|
||||
ticket = NotifySupportTicket(
|
||||
subject=f'Email branding request - {current_service.name}',
|
||||
message=ticket_message,
|
||||
ticket_type=NotifySupportTicket.TYPE_QUESTION,
|
||||
user_name=current_user.name,
|
||||
user_email=current_user.email_address,
|
||||
org_id=current_service.organisation_id,
|
||||
org_type=current_service.organisation_type,
|
||||
service_id=current_service.id
|
||||
)
|
||||
zendesk_client.send_ticket_to_zendesk(ticket)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/branding-request/email", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def email_branding_request(service_id):
|
||||
form = BrandingOptions(current_service, branding_type='email')
|
||||
branding_name = current_service.email_branding_name
|
||||
if form.validate_on_submit():
|
||||
ticket_message = render_template(
|
||||
'support-tickets/branding-request.txt',
|
||||
current_branding=branding_name,
|
||||
branding_requested=dict(form.options.choices)[form.options.data],
|
||||
detail=form.something_else.data,
|
||||
)
|
||||
ticket = NotifySupportTicket(
|
||||
subject=f'Email branding request - {current_service.name}',
|
||||
message=ticket_message,
|
||||
ticket_type=NotifySupportTicket.TYPE_QUESTION,
|
||||
user_name=current_user.name,
|
||||
user_email=current_user.email_address,
|
||||
org_id=current_service.organisation_id,
|
||||
org_type=current_service.organisation_type,
|
||||
service_id=current_service.id
|
||||
)
|
||||
zendesk_client.send_ticket_to_zendesk(ticket)
|
||||
flash((
|
||||
'Thanks for your branding request. We’ll get back to you '
|
||||
'within one working day.'
|
||||
), 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
if form.something_else_is_only_option:
|
||||
create_email_branding_zendesk_ticket(
|
||||
form_option_selected=form.options.data,
|
||||
detail=form.something_else.data,
|
||||
)
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
else:
|
||||
endpoint = {
|
||||
'govuk': '.email_branding_govuk',
|
||||
'govuk_and_org': '.email_branding_govuk',
|
||||
'nhs': '.email_branding_nhs',
|
||||
'organisation': '.email_branding_organisation',
|
||||
'something_else': '.email_branding_something_else',
|
||||
}[form.options.data]
|
||||
|
||||
return redirect(
|
||||
url_for(
|
||||
endpoint,
|
||||
service_id=current_service.id,
|
||||
with_org=(True if form.options.data == 'govuk_and_org' else None),
|
||||
)
|
||||
)
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/branding/email-branding-options.html',
|
||||
@@ -1166,6 +1191,58 @@ def email_branding_request(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/email-branding/govuk", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def email_branding_govuk(service_id):
|
||||
with_org = request.args.get('with_org')
|
||||
|
||||
if request.method == 'POST':
|
||||
create_email_branding_zendesk_ticket(request.form['branding_choice'])
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
|
||||
return render_template('views/service-settings/branding/email-branding-govuk.html', with_org=with_org)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/email-branding/nhs", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def email_branding_nhs(service_id):
|
||||
if request.method == 'POST':
|
||||
create_email_branding_zendesk_ticket('nhs')
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
|
||||
return render_template('views/service-settings/branding/email-branding-nhs.html')
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/email-branding/organisation", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def email_branding_organisation(service_id):
|
||||
if request.method == 'POST':
|
||||
create_email_branding_zendesk_ticket('organisation')
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
|
||||
return render_template('views/service-settings/branding/email-branding-organisation.html')
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/email-branding/something-else", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def email_branding_something_else(service_id):
|
||||
form = SomethingElseBrandingForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
create_email_branding_zendesk_ticket('something_else', detail=form.something_else.data)
|
||||
|
||||
flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=current_service.id))
|
||||
|
||||
return render_template('views/service-settings/branding/email-branding-something-else.html', form=form)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/branding-request/letter", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def letter_branding_request(service_id):
|
||||
|
||||
Reference in New Issue
Block a user