mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-05 14:11:41 -04:00
add other send notification error branches and tests
This commit is contained in:
@@ -51,6 +51,8 @@ class Config(object):
|
||||
SESSION_COOKIE_SECURE = True
|
||||
SESSION_REFRESH_EACH_REQUEST = True
|
||||
SHOW_STYLEGUIDE = True
|
||||
# TODO: move to utils
|
||||
SMS_CHAR_COUNT_LIMIT = 459
|
||||
TOKEN_MAX_AGE_SECONDS = 3600
|
||||
WTF_CSRF_ENABLED = True
|
||||
WTF_CSRF_TIME_LIMIT = None
|
||||
|
||||
@@ -638,14 +638,23 @@ def _check_notification(service_id, template_id, exception=None):
|
||||
|
||||
|
||||
def get_template_error_dict(exception):
|
||||
# TODO: Make API return some computer-friendly identifier as well as the end user error messages
|
||||
if 'service is in trial mode' in exception.message:
|
||||
error = 'not-allowed-to-send-to'
|
||||
elif 'Exceeded send limits' in exception.message:
|
||||
error = 'too-many-messages'
|
||||
elif 'Content for template has a character count greater than the limit of' in exception.message:
|
||||
error = 'message-too-long'
|
||||
else:
|
||||
raise exception
|
||||
|
||||
return {
|
||||
'error': error,
|
||||
'SMS_CHAR_COUNT_LIMIT': 0
|
||||
'SMS_CHAR_COUNT_LIMIT': current_app.config['SMS_CHAR_COUNT_LIMIT'],
|
||||
'current_service': current_service,
|
||||
|
||||
# used to trigger CSV specific err msg content, so not needed for single notification errors.
|
||||
'original_file_name': False
|
||||
}
|
||||
|
||||
|
||||
@@ -668,6 +677,10 @@ def send_notification(service_id, template_id):
|
||||
personalisation=session['placeholders']
|
||||
)
|
||||
except HTTPError as exception:
|
||||
current_app.logger.info('Service {} could not send notification: "{}"'.format(
|
||||
current_service['id'],
|
||||
exception.message
|
||||
))
|
||||
return _check_notification(service_id, template_id, exception)
|
||||
|
||||
session.pop('placeholders')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% from "components/banner.html" import banner_wrapper %}
|
||||
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% from "components/banner.html" import banner_wrapper %}
|
||||
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
%}
|
||||
{% include "partials/check/not-allowed-to-send-to.html" %}
|
||||
{% endwith %}
|
||||
{% elif error == 'more_rows_than_can_send' %}
|
||||
{% elif error == 'too-many-messages' %}
|
||||
{% include "partials/check/too-many-messages.html" %}
|
||||
{% elif error == 'row_errors' %}
|
||||
{% elif error == 'message-too-long' %}
|
||||
{# the only row_errors we can get when sending one off messages is that the message is too long #}
|
||||
{% include "partials/check/message-too-long.html" %}
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user