mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
Refactor check error templates to repeat less
There was a lot of repetetive wrapping code being repeated for every conditional block in these files. Let’s wrap it around the whole conditional bit once instead.
This commit is contained in:
@@ -1,25 +1,12 @@
|
|||||||
{% from "components/banner.html" import banner_wrapper %}
|
<h1 class='banner-title'>
|
||||||
|
You can’t send to
|
||||||
{% macro skip_to_file_contents() %}
|
{{ 'this' if count_of_recipients == 1 else 'these' }}
|
||||||
<p class="visually-hidden">
|
{{ template_type_label }}
|
||||||
<a href="#{{ file_contents_header_id }}">Skip to file contents</a>
|
{%- if count_of_recipients != 1 -%}
|
||||||
</p>
|
{{ 'es' if 'email address' == template_type_label else 's' }}
|
||||||
{% endmacro %}
|
{%- endif %}
|
||||||
|
</h1>
|
||||||
<div class="bottom-gutter">
|
<p>
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
In <a href="{{ url_for('.trial_mode') }}">trial mode</a> you can only
|
||||||
<h1 class='banner-title'>
|
send to yourself and members of your team
|
||||||
You can’t send to
|
</p>
|
||||||
{{ 'this' if count_of_recipients == 1 else 'these' }}
|
|
||||||
{{ template_type_label }}
|
|
||||||
{%- if count_of_recipients != 1 -%}
|
|
||||||
{{ 'es' if 'email address' == template_type_label else 's' }}
|
|
||||||
{%- endif %}
|
|
||||||
</h1>
|
|
||||||
<p>
|
|
||||||
In <a href="{{ url_for('.trial_mode') }}">trial mode</a> you can only
|
|
||||||
send to yourself and members of your team
|
|
||||||
</p>
|
|
||||||
{{ skip_to_file_contents() }}
|
|
||||||
{% endcall %}
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,46 +1,40 @@
|
|||||||
{% from "components/banner.html" import banner_wrapper %}
|
<h1 class='banner-title'>
|
||||||
|
{% if original_file_name %}
|
||||||
<div class="bottom-gutter">
|
Too many recipients
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
{% else %}
|
||||||
<h1 class='banner-title'>
|
Daily limit reached
|
||||||
{% if original_file_name %}
|
{% endif %}
|
||||||
Too many recipients
|
</h1>
|
||||||
{% else %}
|
<p>
|
||||||
Daily limit reached
|
You can only send {{ current_service.message_limit }} messages per day
|
||||||
{% endif %}
|
{%- if current_service.restricted %}
|
||||||
</h1>
|
in <a href="{{ url_for('.trial_mode')}}">trial mode</a>
|
||||||
<p>
|
{%- endif -%}
|
||||||
You can only send {{ current_service.message_limit }} messages per day
|
.
|
||||||
{%- if current_service.restricted %}
|
</p>
|
||||||
in <a href="{{ url_for('.trial_mode')}}">trial mode</a>
|
{% if original_file_name %}
|
||||||
{%- endif -%}
|
<p>
|
||||||
.
|
{% if current_service.message_limit != remaining_messages %}
|
||||||
</p>
|
You can still send {{ remaining_messages }} messages today, but
|
||||||
{% if original_file_name %}
|
|
||||||
<p>
|
|
||||||
{% if current_service.message_limit != remaining_messages %}
|
|
||||||
You can still send {{ remaining_messages }} messages today, but
|
|
||||||
{% endif %}
|
|
||||||
‘{{ original_file_name }}’ contains
|
|
||||||
{{ count_of_recipients }}
|
|
||||||
{% if count_of_recipients == 1 -%}
|
|
||||||
{%- if template.template_type == 'email' -%}
|
|
||||||
email address
|
|
||||||
{%- elif template.template_type == 'sms' -%}
|
|
||||||
phone number
|
|
||||||
{%- elif template.template_type == 'letter' -%}
|
|
||||||
address
|
|
||||||
{%- endif -%}
|
|
||||||
{%- else -%}
|
|
||||||
{%- if template.template_type == 'email' -%}
|
|
||||||
email addresses
|
|
||||||
{%- elif template.template_type == 'sms' -%}
|
|
||||||
phone numbers
|
|
||||||
{%- elif template.template_type == 'letter' -%}
|
|
||||||
addresses
|
|
||||||
{%- endif -%}
|
|
||||||
{%- endif -%}.
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endcall %}
|
‘{{ original_file_name }}’ contains
|
||||||
</div>
|
{{ count_of_recipients }}
|
||||||
|
{% if count_of_recipients == 1 -%}
|
||||||
|
{%- if template.template_type == 'email' -%}
|
||||||
|
email address
|
||||||
|
{%- elif template.template_type == 'sms' -%}
|
||||||
|
phone number
|
||||||
|
{%- elif template.template_type == 'letter' -%}
|
||||||
|
address
|
||||||
|
{%- endif -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- if template.template_type == 'email' -%}
|
||||||
|
email addresses
|
||||||
|
{%- elif template.template_type == 'sms' -%}
|
||||||
|
phone numbers
|
||||||
|
{%- elif template.template_type == 'letter' -%}
|
||||||
|
addresses
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endif -%}.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -19,10 +19,11 @@
|
|||||||
|
|
||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
{% if recipients.too_many_rows %}
|
<div class="bottom-gutter">
|
||||||
|
{% call banner_wrapper(type='dangerous') %}
|
||||||
|
|
||||||
|
{% if recipients.too_many_rows %}
|
||||||
|
|
||||||
<div class="bottom-gutter">
|
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
|
||||||
<h1 class='banner-title'>
|
<h1 class='banner-title'>
|
||||||
Your file has too many rows
|
Your file has too many rows
|
||||||
</h1>
|
</h1>
|
||||||
@@ -31,14 +32,9 @@
|
|||||||
{{ "{:,}".format(recipients.max_rows) }} rows at once. Your
|
{{ "{:,}".format(recipients.max_rows) }} rows at once. Your
|
||||||
file has {{ "{:,}".format(recipients|length) }} rows.
|
file has {{ "{:,}".format(recipients|length) }} rows.
|
||||||
</p>
|
</p>
|
||||||
{{ skip_to_file_contents() }}
|
|
||||||
{% endcall %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% elif not count_of_recipients %}
|
{% elif not count_of_recipients %}
|
||||||
|
|
||||||
<div class="bottom-gutter">
|
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
|
||||||
<h1 class='banner-title'>
|
<h1 class='banner-title'>
|
||||||
Your file is missing some rows
|
Your file is missing some rows
|
||||||
</h1>
|
</h1>
|
||||||
@@ -48,14 +44,9 @@
|
|||||||
prefix_plural='columns called'
|
prefix_plural='columns called'
|
||||||
) }}.
|
) }}.
|
||||||
</p>
|
</p>
|
||||||
{{ skip_to_file_contents() }}
|
|
||||||
{% endcall %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% elif not recipients.has_recipient_columns %}
|
{% elif not recipients.has_recipient_columns %}
|
||||||
|
|
||||||
<div class="bottom-gutter">
|
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
|
||||||
<h1 class='banner-title'>
|
<h1 class='banner-title'>
|
||||||
Your file needs {{ recipients.recipient_column_headers | formatted_list(
|
Your file needs {{ recipients.recipient_column_headers | formatted_list(
|
||||||
prefix='a column called',
|
prefix='a column called',
|
||||||
@@ -68,14 +59,9 @@
|
|||||||
prefix_plural='columns called '
|
prefix_plural='columns called '
|
||||||
) }}.
|
) }}.
|
||||||
</p>
|
</p>
|
||||||
{{ skip_to_file_contents() }}
|
|
||||||
{% endcall %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% elif recipients.missing_column_headers %}
|
{% elif recipients.missing_column_headers %}
|
||||||
|
|
||||||
<div class="bottom-gutter">
|
|
||||||
{% call banner_wrapper(type='dangerous') %}
|
|
||||||
<h1 class='banner-title'>
|
<h1 class='banner-title'>
|
||||||
The columns in your file need to match the double brackets in
|
The columns in your file need to match the double brackets in
|
||||||
your template
|
your template
|
||||||
@@ -87,20 +73,22 @@
|
|||||||
prefix_plural='columns called '
|
prefix_plural='columns called '
|
||||||
) }}.
|
) }}.
|
||||||
</p>
|
</p>
|
||||||
{{ skip_to_file_contents() }}
|
|
||||||
{% endcall %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% elif not recipients.allowed_to_send_to %}
|
{% elif not recipients.allowed_to_send_to %}
|
||||||
{% with
|
{% with
|
||||||
count_of_recipients=count_of_recipients,
|
count_of_recipients=count_of_recipients,
|
||||||
template_type_label=recipients.recipient_column_headers[0]
|
template_type_label=recipients.recipient_column_headers[0]
|
||||||
%}
|
%}
|
||||||
{% include "partials/check/not-allowed-to-send-to.html" %}
|
{% include "partials/check/not-allowed-to-send-to.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% elif recipients.more_rows_than_can_send %}
|
{% elif recipients.more_rows_than_can_send %}
|
||||||
{% include "partials/check/too-many-messages.html" %}
|
{% include "partials/check/too-many-messages.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{{ skip_to_file_contents() }}
|
||||||
|
|
||||||
|
{% endcall %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="bottom-gutter-3-2">
|
<div class="bottom-gutter-3-2">
|
||||||
{% if request.args.from_test %}
|
{% if request.args.from_test %}
|
||||||
|
|||||||
Reference in New Issue
Block a user