mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-30 02:50:03 -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 %}
|
||||
|
||||
{% macro skip_to_file_contents() %}
|
||||
<p class="visually-hidden">
|
||||
<a href="#{{ file_contents_header_id }}">Skip to file contents</a>
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
You can’t send to
|
||||
{{ '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>
|
||||
<h1 class='banner-title'>
|
||||
You can’t send to
|
||||
{{ '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>
|
||||
|
||||
@@ -1,46 +1,40 @@
|
||||
{% from "components/banner.html" import banner_wrapper %}
|
||||
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
{% if original_file_name %}
|
||||
Too many recipients
|
||||
{% else %}
|
||||
Daily limit reached
|
||||
{% endif %}
|
||||
</h1>
|
||||
<p>
|
||||
You can only send {{ current_service.message_limit }} messages per day
|
||||
{%- if current_service.restricted %}
|
||||
in <a href="{{ url_for('.trial_mode')}}">trial mode</a>
|
||||
{%- endif -%}
|
||||
.
|
||||
</p>
|
||||
{% 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>
|
||||
<h1 class='banner-title'>
|
||||
{% if original_file_name %}
|
||||
Too many recipients
|
||||
{% else %}
|
||||
Daily limit reached
|
||||
{% endif %}
|
||||
</h1>
|
||||
<p>
|
||||
You can only send {{ current_service.message_limit }} messages per day
|
||||
{%- if current_service.restricted %}
|
||||
in <a href="{{ url_for('.trial_mode')}}">trial mode</a>
|
||||
{%- endif -%}
|
||||
.
|
||||
</p>
|
||||
{% if original_file_name %}
|
||||
<p>
|
||||
{% if current_service.message_limit != remaining_messages %}
|
||||
You can still send {{ remaining_messages }} messages today, but
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
</div>
|
||||
‘{{ 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 %}
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
|
||||
{% 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'>
|
||||
Your file has too many rows
|
||||
</h1>
|
||||
@@ -31,14 +32,9 @@
|
||||
{{ "{:,}".format(recipients.max_rows) }} rows at once. Your
|
||||
file has {{ "{:,}".format(recipients|length) }} rows.
|
||||
</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'>
|
||||
Your file is missing some rows
|
||||
</h1>
|
||||
@@ -48,14 +44,9 @@
|
||||
prefix_plural='columns called'
|
||||
) }}.
|
||||
</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'>
|
||||
Your file needs {{ recipients.recipient_column_headers | formatted_list(
|
||||
prefix='a column called',
|
||||
@@ -68,14 +59,9 @@
|
||||
prefix_plural='columns called '
|
||||
) }}.
|
||||
</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'>
|
||||
The columns in your file need to match the double brackets in
|
||||
your template
|
||||
@@ -87,20 +73,22 @@
|
||||
prefix_plural='columns called '
|
||||
) }}.
|
||||
</p>
|
||||
{{ skip_to_file_contents() }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
{% 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 recipients.more_rows_than_can_send %}
|
||||
{% include "partials/check/too-many-messages.html" %}
|
||||
{% endif %}
|
||||
{% 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 recipients.more_rows_than_can_send %}
|
||||
{% include "partials/check/too-many-messages.html" %}
|
||||
{% endif %}
|
||||
|
||||
{{ skip_to_file_contents() }}
|
||||
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
<div class="bottom-gutter-3-2">
|
||||
{% if request.args.from_test %}
|
||||
|
||||
Reference in New Issue
Block a user