mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 20:38:24 -04:00
error when users put non-GSM chars in a sms template
additionally, this moves the formatted_list jinja macro into a python function, so that it can be called from the form validator
This commit is contained in:
@@ -1,35 +1,5 @@
|
||||
{% macro formatted_list(
|
||||
items,
|
||||
conjunction='and',
|
||||
before_each='‘',
|
||||
after_each='’',
|
||||
separator=', ',
|
||||
prefix='',
|
||||
prefix_plural=''
|
||||
) %}
|
||||
{% if items|length == 1 %}
|
||||
{{ prefix }} {{ before_each|safe }}{{ (items|list)[0] }}{{ after_each|safe }}
|
||||
{% elif items %}
|
||||
{{ prefix_plural }}
|
||||
{% for item in (items|list)[0:-1] -%}
|
||||
{{ before_each|safe -}}
|
||||
{{ item -}}
|
||||
{{ after_each|safe -}}
|
||||
{% if not loop.last -%}
|
||||
{{ separator -}}
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
{{ conjunction }}
|
||||
{{ before_each|safe -}}
|
||||
{{ (items|list)[-1] -}}
|
||||
{{ after_each|safe }}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro list_of_placeholders(placeholders) %}
|
||||
{{ formatted_list(
|
||||
placeholders,
|
||||
{{ placeholders | formatted_list(
|
||||
before_each="<span class='placeholder'>((",
|
||||
after_each='))</span>',
|
||||
separator=' '
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
{% from "components/table.html" import list_table, field, text_field, index_field, hidden_field_heading %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/list.html" import formatted_list %}
|
||||
{% from "components/message-count-label.html" import message_count_label %}
|
||||
|
||||
{% set file_contents_header_id = 'file-preview' %}
|
||||
@@ -41,15 +40,13 @@
|
||||
<div class="bottom-gutter">
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
<h1 class='banner-title'>
|
||||
Your file needs to have {{ formatted_list(
|
||||
recipients.recipient_column_headers,
|
||||
Your file needs to have {{ recipients.recipient_column_headers | formatted_list(
|
||||
prefix='a column called',
|
||||
prefix_plural='columns called'
|
||||
) }}
|
||||
</h1>
|
||||
<p>
|
||||
Your file has {{ formatted_list(
|
||||
recipients.column_headers,
|
||||
Your file has {{ recipients.column_headers | formatted_list(
|
||||
prefix='one column, called',
|
||||
prefix_plural='columns called'
|
||||
) }}.
|
||||
@@ -67,15 +64,13 @@
|
||||
your template
|
||||
</h1>
|
||||
<p>
|
||||
Your file has {{ formatted_list(
|
||||
recipients.column_headers,
|
||||
Your file has {{ recipients.column_headers | formatted_list(
|
||||
prefix='one column, called',
|
||||
prefix_plural='columns called'
|
||||
) }}.
|
||||
</p>
|
||||
<p>
|
||||
It doesn’t have {{ formatted_list(
|
||||
recipients.missing_column_headers,
|
||||
It doesn’t have {{ recipients.column_headers | formatted_list(
|
||||
conjunction='or',
|
||||
prefix='a column called',
|
||||
prefix_plural='columns called'
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/api-key.html" import api_key %}
|
||||
{% from "components/list.html" import formatted_list %}
|
||||
|
||||
{% block per_page_title %}
|
||||
Styleguide
|
||||
@@ -196,19 +195,19 @@
|
||||
<h2 class="heading-large">Formatted list</h2>
|
||||
|
||||
<p>
|
||||
{{ formatted_list('A', prefix="one item called") }}
|
||||
{{ 'A' | formatted_list(prefix="one item called") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ formatted_list('AB', prefix_plural="two items called") }}
|
||||
{{ 'AB' | formatted_list(prefix_plural="two items called") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ formatted_list('ABC') }}
|
||||
{{ 'ABC' | formatted_list }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ formatted_list('ABCD', before_each='<strike>', after_each='</strike>', conjunction='or') }}
|
||||
{{ 'ABCD' | formatted_list(before_each='<strike>', after_each='</strike>', conjunction='or') }}
|
||||
</p>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user