Don’t let users in trial mode send letters

Users in trial mode haven’t signed the MOU. This means that they haven’t
agreed to pay for any costs they incur.

Unlike text messages and emails, we don’t give you any free allowance of
letters. Sending _any_ letters will cost the user money.

Therefore we shouldn’t let users who haven’t agreed that they will pay
for the service to incur costs by sending letters.

The pattern used for this is roughly the same as other trial mode errors
that we have already, ie a red box that says you’re not allowed. Not
sure if this is exactly right because it’s not exactly an error so the
pattern might feel too heavy-handed.

Getting this in place means we can turn letters on for users in trial
mode without worrying that they’ll accidentally send real letters, which
would result in:
- us having to absorb those costs
- some awkward conversations
This commit is contained in:
Chris Hill-Scott
2017-08-08 10:01:44 +01:00
parent f90bab8e0c
commit 8f40cbd2bb
3 changed files with 64 additions and 2 deletions

View File

@@ -439,7 +439,10 @@ def _check_messages(service_id, template_type, upload_id, letters_as_pdf=False):
remaining_messages=remaining_messages,
choose_time_form=choose_time_form,
back_link=back_link,
help=get_help_argument()
help=get_help_argument(),
trying_to_send_letters_in_trial_mode=bool(
current_service['restricted'] and template.template_type == 'letter'
),
)
@@ -461,7 +464,7 @@ def check_messages(service_id, template_type, upload_id):
if data['row_errors']:
return render_template('views/check/row-errors.html', **data)
if data['errors']:
if data['errors'] or data['trying_to_send_letters_in_trial_mode']:
return render_template('views/check/column-errors.html', **data)
return render_template('views/check/ok.html', **data)

View File

@@ -87,6 +87,17 @@
{% include "partials/check/too-many-messages.html" %}
{% elif trying_to_send_letters_in_trial_mode %}
<h1 class='banner-title' data-module="track-error" data-error-type="Trying to send letters in trial mode" data-error-label="{{ upload_id }}">
You cant send
{{ 'this letter' if count_of_recipients == 1 else 'these letters' }}
</h1>
<p>
In <a href="{{ url_for('.trial_mode') }}">trial mode</a> you
can only preview how your letters will look
</p>
{% endif %}
{{ skip_to_file_contents() }}

View File

@@ -24,6 +24,8 @@ from tests.conftest import (
mock_get_service_email_template,
normalize_spaces,
SERVICE_ONE_ID,
mock_get_service,
mock_get_live_service,
)
template_types = ['email', 'sms']
@@ -1577,6 +1579,52 @@ def test_check_messages_shows_trial_mode_error(
)
@pytest.mark.parametrize('service_mock, error_should_be_shown', [
(mock_get_service, True),
(mock_get_live_service, False),
])
def test_check_messages_shows_trial_mode_error_for_letters(
client_request,
api_user_active,
mock_get_service_letter_template,
mock_has_permissions,
mock_get_users_by_service,
mock_get_detailed_service_for_today,
mocker,
service_mock,
error_should_be_shown,
):
service_mock(mocker, api_user_active)
mocker.patch('app.main.views.send.s3download', return_value='''
address_line_1,address_line_2,postcode,
First Last, 123 Street, SW1 1AA
''')
with client_request.session_transaction() as session:
session['upload_data'] = {'template_id': ''}
page = client_request.get(
'main.check_messages',
service_id=SERVICE_ONE_ID,
template_type='letter',
upload_id=uuid.uuid4(),
_test_page_title=False,
)
error = page.select('.banner-dangerous')
if error_should_be_shown:
assert normalize_spaces(error[0].text) == (
'You cant send this letter '
'In trial mode you can only preview how your letters will look '
'Skip to file contents'
)
else:
assert not error
def test_check_messages_shows_over_max_row_error(
logged_in_client,
api_user_active,