mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 13:29:48 -04:00
Merge pull request #2268 from alphagov/request-to-go-live-better-data
Make the data we get from the go live requests more useful
This commit is contained in:
@@ -85,7 +85,6 @@ class Development(Config):
|
|||||||
API_HOST_NAME = 'http://localhost:6011'
|
API_HOST_NAME = 'http://localhost:6011'
|
||||||
DANGEROUS_SALT = 'dev-notify-salt'
|
DANGEROUS_SALT = 'dev-notify-salt'
|
||||||
SECRET_KEY = 'dev-notify-secret-key'
|
SECRET_KEY = 'dev-notify-secret-key'
|
||||||
ZENDESK_API_KEY = "some-key"
|
|
||||||
|
|
||||||
|
|
||||||
class Test(Development):
|
class Test(Development):
|
||||||
|
|||||||
@@ -569,24 +569,26 @@ class Triage(StripWhitespaceForm):
|
|||||||
|
|
||||||
|
|
||||||
class RequestToGoLiveForm(StripWhitespaceForm):
|
class RequestToGoLiveForm(StripWhitespaceForm):
|
||||||
channel_email = BooleanField('Emails')
|
volume_email = StringField(
|
||||||
channel_sms = BooleanField('Text messages')
|
'How many emails do you expect to send in the next year?',
|
||||||
channel_letter = BooleanField('Letters')
|
|
||||||
start_date = StringField(
|
|
||||||
'When will you be ready to start sending messages?',
|
|
||||||
validators=[DataRequired(message='Can’t be empty')]
|
validators=[DataRequired(message='Can’t be empty')]
|
||||||
)
|
)
|
||||||
start_volume = StringField(
|
volume_sms = StringField(
|
||||||
'How many messages do you expect to send to start with?',
|
'How many text messages do you expect to send in the next year?',
|
||||||
validators=[DataRequired(message='Can’t be empty')]
|
validators=[DataRequired(message='Can’t be empty')]
|
||||||
)
|
)
|
||||||
peak_volume = StringField(
|
volume_letter = StringField(
|
||||||
'Will the number of messages increase and when will that start?',
|
'How many letters do you expect to send in the next year?',
|
||||||
validators=[DataRequired(message='Can’t be empty')]
|
validators=[DataRequired(message='Can’t be empty')]
|
||||||
)
|
)
|
||||||
method_one_off = BooleanField('One at a time')
|
research_consent = RadioField(
|
||||||
method_upload = BooleanField('Upload a spreadsheet of recipients')
|
'Can we contact you when we’re doing user research?',
|
||||||
method_api = BooleanField('Integrate with the GOV.UK Notify API')
|
choices=[
|
||||||
|
('yes', 'Yes'),
|
||||||
|
('no', 'No'),
|
||||||
|
],
|
||||||
|
validators=[DataRequired()]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProviderForm(StripWhitespaceForm):
|
class ProviderForm(StripWhitespaceForm):
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import pytz
|
||||||
from flask import (
|
from flask import (
|
||||||
abort,
|
abort,
|
||||||
current_app,
|
current_app,
|
||||||
@@ -11,7 +14,6 @@ from flask import (
|
|||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
from notifications_utils.field import Field
|
from notifications_utils.field import Field
|
||||||
from notifications_utils.formatters import formatted_list
|
|
||||||
|
|
||||||
from app import (
|
from app import (
|
||||||
billing_api_client,
|
billing_api_client,
|
||||||
@@ -214,32 +216,42 @@ def submit_request_to_go_live(service_id):
|
|||||||
zendesk_client.create_ticket(
|
zendesk_client.create_ticket(
|
||||||
subject='Request to go live - {}'.format(current_service.name),
|
subject='Request to go live - {}'.format(current_service.name),
|
||||||
message=(
|
message=(
|
||||||
'Service: {}\n'
|
'Service: {service_name}\n'
|
||||||
'{}\n'
|
'{service_dashboard}\n'
|
||||||
'\n---'
|
'\n---'
|
||||||
'\nOrganisation type: {}'
|
'\nOrganisation type: {organisation_type}'
|
||||||
'\nAgreement signed: {}'
|
'\nAgreement signed: {agreement}'
|
||||||
'\nChannel: {}\nStart date: {}\nStart volume: {}'
|
'\nEmails in next year: {volume_email}'
|
||||||
'\nPeak volume: {}'
|
'\nText messages in next year: {volume_sms}'
|
||||||
'\nFeatures: {}'
|
'\nLetters in next year: {volume_letter}'
|
||||||
|
'\nConsent to research: {research_consent}'
|
||||||
|
'\n'
|
||||||
|
'\n---'
|
||||||
|
'\n'
|
||||||
|
'{service_id}, '
|
||||||
|
'{organisation}, '
|
||||||
|
'{service_name}, '
|
||||||
|
'{user_name}, '
|
||||||
|
'{user_email}, '
|
||||||
|
'-, '
|
||||||
|
'{date}, '
|
||||||
|
'{volume_sms}, '
|
||||||
|
'{volume_email}, '
|
||||||
|
'{volume_letter}'
|
||||||
).format(
|
).format(
|
||||||
current_service.name,
|
service_name=current_service.name,
|
||||||
url_for('main.service_dashboard', service_id=current_service.id, _external=True),
|
service_dashboard=url_for('main.service_dashboard', service_id=current_service.id, _external=True),
|
||||||
current_service.organisation_type,
|
organisation_type=str(current_service.organisation_type).title(),
|
||||||
AgreementInfo.from_current_user().as_human_readable,
|
agreement=AgreementInfo.from_current_user().as_human_readable,
|
||||||
formatted_list(filter(None, (
|
volume_email=form.volume_email.data,
|
||||||
'email' if form.channel_email.data else None,
|
volume_sms=form.volume_sms.data,
|
||||||
'text messages' if form.channel_sms.data else None,
|
volume_letter=form.volume_letter.data,
|
||||||
'letters' if form.channel_letter.data else None,
|
research_consent=form.research_consent.data.title(),
|
||||||
)), before_each='', after_each=''),
|
service_id=current_service.id,
|
||||||
form.start_date.data,
|
organisation=AgreementInfo.from_current_user().owner,
|
||||||
form.start_volume.data,
|
user_name=current_user.name,
|
||||||
form.peak_volume.data,
|
user_email=current_user.email_address,
|
||||||
formatted_list(filter(None, (
|
date=datetime.now(tz=pytz.timezone('Europe/London')).strftime('%d/%m/%Y'),
|
||||||
'one off' if form.method_one_off.data else None,
|
|
||||||
'file upload' if form.method_upload.data else None,
|
|
||||||
'API' if form.method_api.data else None,
|
|
||||||
)), before_each='', after_each='')
|
|
||||||
),
|
),
|
||||||
ticket_type=zendesk_client.TYPE_QUESTION,
|
ticket_type=zendesk_client.TYPE_QUESTION,
|
||||||
user_email=current_user.email_address,
|
user_email=current_user.email_address,
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
{% if hide_legend %}<span class="visually-hidden">{% endif %}
|
{% if hide_legend %}<span class="visually-hidden">{% endif %}
|
||||||
{{ field.label.text|safe }}
|
{{ field.label.text|safe }}
|
||||||
{% if hide_legend %}</span>{% endif %}
|
{% if hide_legend %}</span>{% endif %}
|
||||||
|
{% if hint %}
|
||||||
|
<span class="form-hint">
|
||||||
|
{{ hint }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
||||||
{{ field.errors[0] }}
|
{{ field.errors[0] }}
|
||||||
|
|||||||
@@ -13,32 +13,22 @@
|
|||||||
|
|
||||||
<h1 class="heading-large">Request to go live</h1>
|
<h1 class="heading-large">Request to go live</h1>
|
||||||
|
|
||||||
<p class="bottom-gutter">
|
<form method="post">
|
||||||
Tell us how you plan to use Notify. When we receive your request we’ll make your service live within one working day.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<form method="post" class="top-gutter">
|
|
||||||
{{ checkbox_group('What kind of messages will you be sending?', [
|
|
||||||
form.channel_email,
|
|
||||||
form.channel_sms,
|
|
||||||
form.channel_letter
|
|
||||||
]) }}
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ textbox(form.start_date, width='1-1') }}
|
{{ textbox(form.volume_email, width='1-2', hint='For example, 1,000,000') }}
|
||||||
{{ textbox(form.start_volume, width='1-1', hint='For example, ‘1,000 per month’.') }}
|
{{ textbox(form.volume_sms, width='1-2', hint='For example, 500,000') }}
|
||||||
{{ textbox(form.peak_volume, width='1-1', hint='For example, ‘Messages will increase to 20,000 per month in January’.') }}
|
{{ textbox(form.volume_letter, width='1-2', hint='For example, 5,000') }}
|
||||||
</div>
|
</div>
|
||||||
{{ checkbox_group('How are you going to send messages?', [
|
{{ radios(form.research_consent, hint='You don’t have to take part and you can unsubscribe at any time') }}
|
||||||
form.method_one_off,
|
<p>
|
||||||
form.method_upload,
|
When we receive your request we’ll get back to you within one working day.
|
||||||
form.method_api
|
</p>
|
||||||
]) }}
|
|
||||||
|
|
||||||
<p class="bottom-gutter">
|
<p class="bottom-gutter">
|
||||||
By requesting to go live you’re agreeing to our <a href="{{ url_for('.terms') }}">terms of use</a>.
|
By requesting to go live you’re agreeing to our <a href="{{ url_for('.terms') }}">terms of use</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{ page_footer('Request to go live') }}
|
{{ page_footer('Request to go live') }}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -691,23 +691,25 @@ def test_should_show_request_to_go_live(
|
|||||||
)
|
)
|
||||||
assert page.h1.text == 'Request to go live'
|
assert page.h1.text == 'Request to go live'
|
||||||
for channel, label in (
|
for channel, label in (
|
||||||
('email', 'Emails'),
|
(
|
||||||
('sms', 'Text messages'),
|
'email',
|
||||||
('letter', 'Letters'),
|
'How many emails do you expect to send in the next year? For example, 1,000,000'
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'sms',
|
||||||
|
'How many text messages do you expect to send in the next year? For example, 500,000'
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'letter',
|
||||||
|
'How many letters do you expect to send in the next year? For example, 5,000'
|
||||||
|
),
|
||||||
):
|
):
|
||||||
assert normalize_spaces(
|
assert normalize_spaces(
|
||||||
page.select_one('label[for=channel_{}]'.format(channel)).text
|
page.select_one('label[for=volume_{}]'.format(channel)).text
|
||||||
) == label
|
|
||||||
for feature, label in (
|
|
||||||
('one_off', 'One at a time'),
|
|
||||||
('upload', 'Upload a spreadsheet of recipients'),
|
|
||||||
('api', 'Integrate with the GOV.UK Notify API'),
|
|
||||||
):
|
|
||||||
assert normalize_spaces(
|
|
||||||
page.select_one('label[for=method_{}]'.format(feature)).text
|
|
||||||
) == label
|
) == label
|
||||||
|
|
||||||
|
|
||||||
|
@freeze_time("2012-12-21")
|
||||||
def test_should_redirect_after_request_to_go_live(
|
def test_should_redirect_after_request_to_go_live(
|
||||||
client_request,
|
client_request,
|
||||||
mocker,
|
mocker,
|
||||||
@@ -723,14 +725,10 @@ def test_should_redirect_after_request_to_go_live(
|
|||||||
'main.submit_request_to_go_live',
|
'main.submit_request_to_go_live',
|
||||||
service_id=SERVICE_ONE_ID,
|
service_id=SERVICE_ONE_ID,
|
||||||
_data={
|
_data={
|
||||||
'channel_email': 'y',
|
'volume_email': '111',
|
||||||
'channel_sms': 'y',
|
'volume_sms': '222',
|
||||||
'start_date': '01/01/2017',
|
'volume_letter': '333',
|
||||||
'start_volume': '100,000',
|
'research_consent': 'yes',
|
||||||
'peak_volume': '2,000,000',
|
|
||||||
'method_one_off': 'y',
|
|
||||||
'method_upload': 'y',
|
|
||||||
'method_api': 'y',
|
|
||||||
},
|
},
|
||||||
_follow_redirects=True
|
_follow_redirects=True
|
||||||
)
|
)
|
||||||
@@ -741,16 +739,21 @@ def test_should_redirect_after_request_to_go_live(
|
|||||||
user_name=active_user_with_permissions.name,
|
user_name=active_user_with_permissions.name,
|
||||||
user_email=active_user_with_permissions.email_address
|
user_email=active_user_with_permissions.email_address
|
||||||
)
|
)
|
||||||
|
assert mock_post.call_args[1]['message'] == (
|
||||||
returned_message = mock_post.call_args[1]['message']
|
'Service: service one\n'
|
||||||
assert 'Service: service one' in returned_message
|
'http://localhost/services/{}\n'
|
||||||
assert 'Organisation type: central' in returned_message
|
'\n'
|
||||||
assert 'Agreement signed: Can’t tell' in returned_message
|
'---\n'
|
||||||
assert 'Channel: email and text messages' in returned_message
|
'Organisation type: Central\n'
|
||||||
assert 'Start date: 01/01/2017' in returned_message
|
'Agreement signed: Can’t tell (domain is user.gov.uk)\n'
|
||||||
assert 'Start volume: 100,000' in returned_message
|
'Emails in next year: 111\n'
|
||||||
assert 'Peak volume: 2,000,000' in returned_message
|
'Text messages in next year: 222\n'
|
||||||
assert 'Features: one off, file upload and API' in returned_message
|
'Letters in next year: 333\n'
|
||||||
|
'Consent to research: Yes\n'
|
||||||
|
'\n'
|
||||||
|
'---\n'
|
||||||
|
'{}, None, service one, Test User, test@user.gov.uk, -, 21/12/2012, 222, 111, 333'
|
||||||
|
).format(SERVICE_ONE_ID, SERVICE_ONE_ID)
|
||||||
|
|
||||||
assert normalize_spaces(page.select_one('.banner-default').text) == (
|
assert normalize_spaces(page.select_one('.banner-default').text) == (
|
||||||
'Thanks for your request to go live. We’ll get back to you within one working day.'
|
'Thanks for your request to go live. We’ll get back to you within one working day.'
|
||||||
|
|||||||
Reference in New Issue
Block a user