mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-19 22:13:48 -04:00
Merge pull request #1407 from alphagov/no-letters-trial-mode
Don’t let users in trial mode send letters
This commit is contained in:
@@ -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'
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -454,7 +457,8 @@ def check_messages(service_id, template_type, upload_id):
|
||||
data['recipients'].too_many_rows or
|
||||
not data['count_of_recipients'] or
|
||||
not data['recipients'].has_recipient_columns or
|
||||
data['recipients'].missing_column_headers
|
||||
data['recipients'].missing_column_headers or
|
||||
data['trying_to_send_letters_in_trial_mode']
|
||||
):
|
||||
return render_template('views/check/column-errors.html', **data)
|
||||
|
||||
|
||||
@@ -75,14 +75,29 @@
|
||||
</p>
|
||||
|
||||
{% elif not recipients.allowed_to_send_to %}
|
||||
|
||||
{% with
|
||||
count_of_recipients=count_of_recipients,
|
||||
template_type_label=recipients.recipient_column_headers[0]
|
||||
%}
|
||||
{% include "partials/check/not-allowed-to-send-to.html" %}
|
||||
{% endwith %}
|
||||
|
||||
{% 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 can’t 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>
|
||||
|
||||
{% elif recipients.more_rows_than_can_send %}
|
||||
|
||||
{% include "partials/check/too-many-messages.html" %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{{ skip_to_file_contents() }}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</p>
|
||||
<ul class="list list-bullet">
|
||||
<li>
|
||||
you can only send messages to yourself
|
||||
you can only send text messages and emails to yourself
|
||||
</li>
|
||||
<li>
|
||||
you can add people to
|
||||
@@ -26,10 +26,13 @@
|
||||
{% else %}
|
||||
your team,
|
||||
{% endif %}
|
||||
then you can send messages to them too
|
||||
then you can send text messages and emails to them too
|
||||
</li>
|
||||
<li>
|
||||
you can only send 50 messages per day
|
||||
you can only send 50 text messages or emails per day
|
||||
</li>
|
||||
<li>
|
||||
you can’t send any letters
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -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,58 @@ 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),
|
||||
])
|
||||
@pytest.mark.parametrize('number_of_rows, expected_error_message', [
|
||||
(1, 'You can’t send this letter'),
|
||||
(111, 'You can’t send these letters'),
|
||||
])
|
||||
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,
|
||||
number_of_rows,
|
||||
expected_error_message,
|
||||
):
|
||||
|
||||
service_mock(mocker, api_user_active)
|
||||
|
||||
mocker.patch('app.main.views.send.s3download', return_value='\n'.join(
|
||||
['address_line_1,address_line_2,postcode,'] +
|
||||
['First Last, 123 Street, SW1 1AA'] * number_of_rows
|
||||
))
|
||||
|
||||
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) == (
|
||||
'{} '
|
||||
'In trial mode you can only preview how your letters will look '
|
||||
'Skip to file contents'
|
||||
).format(expected_error_message)
|
||||
else:
|
||||
assert not error
|
||||
|
||||
|
||||
def test_check_messages_shows_over_max_row_error(
|
||||
logged_in_client,
|
||||
api_user_active,
|
||||
@@ -1620,7 +1674,7 @@ def test_non_ascii_characters_in_letter_recipients_file_shows_error(
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service,
|
||||
mock_get_live_service,
|
||||
mock_has_permissions,
|
||||
mock_get_service_letter_template,
|
||||
mock_get_detailed_service_for_today,
|
||||
|
||||
Reference in New Issue
Block a user