Move the ‘estimated usage’ questions

We get a bunch of requests to go live where people have told us they're
going to send email but there is no email reply-to address present.

These come from 2 scenarios:

1. when there are email templates, and no reply to address – but they
   ignore the checklist
2. when there are no email templates (yet) but they provide anticipated
   volumes for email

At the moment we only auto-check for a reply to address when they have
email templates. And because the question about anticipated volumes
follows the checklist, you'll get a checklist that passes (reply
addresses not required as no templates present) - but your future intent
that differs (reply address IS required because you have anticipated
volumes).

So let’s bring the request for anticipated volumes into the checklist,
that way we can dynamically add the requirement for a reply to address
if they say they will send email but don't have templates yet.

We should begin storing it in the database against the service to stop
people having to re-enter it each time they try to complete the go live
screens.

This also means moving the ‘consent to research question’ along with
the questions about volume, because
- we want people to answer both before going live
- we don’t want to clutter up the summary page by asking questions there
  too
This commit is contained in:
Chris Hill-Scott
2019-02-15 11:03:19 +00:00
parent cc16ab652a
commit 8791134c60
9 changed files with 282 additions and 118 deletions

View File

@@ -593,7 +593,7 @@ class Triage(StripWhitespaceForm):
)
class RequestToGoLiveForm(StripWhitespaceForm):
class EstimateUsageForm(StripWhitespaceForm):
volume_email = StringField(
'How many emails do you expect to send in the next year?',
validators=[DataRequired(message='Cant be empty')]
@@ -606,7 +606,7 @@ class RequestToGoLiveForm(StripWhitespaceForm):
'How many letters do you expect to send in the next year?',
validators=[DataRequired(message='Cant be empty')]
)
research_consent = RadioField(
consent_to_research = RadioField(
'Can we contact you when were doing user research?',
choices=[
('yes', 'Yes'),

View File

@@ -30,12 +30,12 @@ from app.main import main
from app.main.forms import (
BrandingOptionsEmail,
ConfirmPasswordForm,
EstimateUsageForm,
FreeSMSAllowance,
InternationalSMSForm,
LinkOrganisationsForm,
OrganisationTypeForm,
RenameServiceForm,
RequestToGoLiveForm,
SearchByNameForm,
ServiceContactDetailsForm,
ServiceDataRetentionEditForm,
@@ -142,7 +142,37 @@ def service_name_change_confirm(service_id):
form=form)
@main.route("/services/<service_id>/service-settings/request-to-go-live")
@main.route("/services/<service_id>/service-settings/request-to-go-live/estimate-usage", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_service')
def estimate_usage(service_id):
form = EstimateUsageForm(
volume_email=current_service.volume_email,
volume_sms=current_service.volume_sms,
volume_letter=current_service.volume_letter,
consent_to_research='yes' if current_service.consent_to_research else 'no',
)
if form.validate_on_submit():
current_service.update(
volume_email=form.volume_email.data,
volume_sms=form.volume_sms.data,
volume_letter=form.volume_letter.data,
consent_to_research=(form.consent_to_research.data == 'yes'),
)
return redirect(url_for(
'main.request_to_go_live',
service_id=service_id,
))
return render_template(
'views/service-settings/estimate-usage.html',
form=form,
)
@main.route("/services/<service_id>/service-settings/request-to-go-live", methods=['GET'])
@login_required
@user_has_permissions('manage_service')
def request_to_go_live(service_id):
@@ -156,72 +186,64 @@ def request_to_go_live(service_id):
)
@main.route("/services/<service_id>/service-settings/submit-request-to-go-live", methods=['GET', 'POST'])
@main.route("/services/<service_id>/service-settings/request-to-go-live", methods=['POST'])
@login_required
@user_has_permissions('manage_service')
@user_is_gov_user
def submit_request_to_go_live(service_id):
form = RequestToGoLiveForm()
if form.validate_on_submit():
zendesk_client.create_ticket(
subject='Request to go live - {}'.format(current_service.name),
message=(
'Service: {service_name}\n'
'{service_dashboard}\n'
'\n---'
'\nOrganisation type: {organisation_type}'
'\nAgreement signed: {agreement}'
'\nChecklist completed: {checklist}'
'\nEmails in next year: {volume_email}'
'\nText messages in next year: {volume_sms}'
'\nLetters in next year: {volume_letter}'
'\nConsent to research: {research_consent}'
'\nOther live services: {existing_live}'
'\n'
'\n---'
'\n'
'{service_id}, '
'{organisation}, '
'{service_name}, '
'{user_name}, '
'{user_email}, '
'-, '
'{date}, '
'{volume_sms_normalised}, '
'{volume_email_normalised}, '
'{volume_letter_normalised}'
).format(
service_name=current_service.name,
service_dashboard=url_for('main.service_dashboard', service_id=current_service.id, _external=True),
organisation_type=str(current_service.organisation_type).title(),
agreement=AgreementInfo.from_current_user().as_human_readable,
checklist=current_service.go_live_checklist_completed_as_yes_no,
volume_email=form.volume_email.data,
volume_email_normalised=form.volume_email.data.replace(',', ''),
volume_sms=form.volume_sms.data,
volume_sms_normalised=form.volume_sms.data.replace(',', ''),
volume_letter=form.volume_letter.data,
volume_letter_normalised=form.volume_letter.data.replace(',', ''),
research_consent=form.research_consent.data.title(),
existing_live='Yes' if user_api_client.user_has_live_services(current_user) else 'No',
service_id=current_service.id,
organisation=AgreementInfo.from_current_user().owner,
user_name=current_user.name,
user_email=current_user.email_address,
date=datetime.now(tz=pytz.timezone('Europe/London')).strftime('%d/%m/%Y'),
),
ticket_type=zendesk_client.TYPE_QUESTION,
user_email=current_user.email_address,
zendesk_client.create_ticket(
subject='Request to go live - {}'.format(current_service.name),
message=(
'Service: {service_name}\n'
'{service_dashboard}\n'
'\n---'
'\nOrganisation type: {organisation_type}'
'\nAgreement signed: {agreement}'
'\nChecklist completed: {checklist}'
'\nEmails in next year: {volume_email:,.0f}'
'\nText messages in next year: {volume_sms:,.0f}'
'\nLetters in next year: {volume_letter:,.0f}'
'\nConsent to research: {research_consent}'
'\nOther live services: {existing_live}'
'\n'
'\n---'
'\n'
'{service_id}, '
'{organisation}, '
'{service_name}, '
'{user_name}, '
'{user_email}, '
'-, '
'{date}, '
'{volume_sms}, '
'{volume_email}, '
'{volume_letter}'
).format(
service_name=current_service.name,
service_dashboard=url_for('main.service_dashboard', service_id=current_service.id, _external=True),
organisation_type=str(current_service.organisation_type).title(),
agreement=AgreementInfo.from_current_user().as_human_readable,
checklist=current_service.go_live_checklist_completed_as_yes_no,
volume_email=current_service.volume_email,
volume_sms=current_service.volume_sms,
volume_letter=current_service.volume_letter,
research_consent='Yes' if current_service.consent_to_research else 'No',
existing_live='Yes' if user_api_client.user_has_live_services(current_user) else 'No',
service_id=current_service.id,
organisation=AgreementInfo.from_current_user().owner,
user_name=current_user.name,
tags=get_request_to_go_live_tags(current_service, current_user),
)
user_email=current_user.email_address,
date=datetime.now(tz=pytz.timezone('Europe/London')).strftime('%d/%m/%Y'),
),
ticket_type=zendesk_client.TYPE_QUESTION,
user_email=current_user.email_address,
user_name=current_user.name,
tags=get_request_to_go_live_tags(current_service, current_user),
)
flash('Thanks for your request to go live. Well get back to you within one working day.', 'default')
return redirect(url_for('.service_settings', service_id=service_id))
return render_template('views/service-settings/submit-request-to-go-live.html', form=form)
flash('Thanks for your request to go live. Well get back to you within one working day.', 'default')
return redirect(url_for('.service_settings', service_id=service_id))
@main.route("/services/<service_id>/service-settings/switch-live", methods=["GET", "POST"])