mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
CSV files currently have ‘to’ as the recipient column. This is changing in https://github.com/alphagov/notifications-api/pull/109 The admin app also has to validate that the CSV files have the right columns, because the API expects any CSV that it’s given to have been checked (also we want things to actually work). This commit is the minimum code change needed. In the future it should reuse the same code as the API for processing CSV files. This will need more thinking.
91 lines
2.9 KiB
HTML
91 lines
2.9 KiB
HTML
{% extends "withnav_template.html" %}
|
||
{% from "components/email-message.html" import email_message %}
|
||
{% from "components/sms-message.html" import sms_message %}
|
||
{% from "components/table.html" import list_table, field %}
|
||
{% from "components/placeholder.html" import placeholder %}
|
||
{% from "components/file-upload.html" import file_upload %}
|
||
{% from "components/page-footer.html" import page_footer %}
|
||
|
||
{% block page_title %}
|
||
{{ "Check and confirm" if upload_result.valid else page_heading }} – GOV.UK Notify
|
||
{% endblock %}
|
||
|
||
{% block maincolumn_content %}
|
||
|
||
|
||
{% if template.additional_data %}
|
||
{{ banner(
|
||
"Remove these columns from your CSV file:" + ", ".join(template.missing_data),
|
||
type="dangerous"
|
||
) }}
|
||
{% elif not upload_result.valid %}
|
||
{{ banner(
|
||
"Your CSV file contained missing or invalid data",
|
||
type="dangerous"
|
||
) }}
|
||
{% endif %}
|
||
|
||
<h1 class="heading-large">
|
||
{{ "Check and confirm" if upload_result.valid else page_heading }}
|
||
</h1>
|
||
|
||
{% if 'email' == template.template_type %}
|
||
{{ email_message(
|
||
template.subject,
|
||
template.replaced if upload_result.valid else template.formatted_as_markup,
|
||
from_address='{}@notifications.service.gov.uk'.format(service.email_from),
|
||
from_name=service.name
|
||
)}}
|
||
{% elif 'sms' == template.template_type %}
|
||
<div class="grid-row">
|
||
<div class="column-two-thirds">
|
||
{{ sms_message(
|
||
template.replaced if upload_result.valid else template.formatted_as_markup
|
||
)}}
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% if upload_result.valid %}
|
||
<form method="post" enctype="multipart/form-data">
|
||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||
<input type="submit" class="button" value="{{ "Send {} text message{}".format(upload_result.rows|count, '' if upload_result.rows|count == 1 else 's') }}" />
|
||
<a href="{{url_for('.send_messages', service_id=service_id, template_id=template.id)}}" class="page-footer-back-link">Back</a>
|
||
</form>
|
||
{% else %}
|
||
{{file_upload(form.file, button_text='Upload a CSV file')}}
|
||
{% endif %}
|
||
|
||
{% call(item) list_table(
|
||
upload_result.rows,
|
||
caption=original_file_name,
|
||
field_headings=column_headers
|
||
) %}
|
||
{% if item.get('phone number', '')|valid_phone_number %}
|
||
{% call field() %}
|
||
{{ item['phone number'] }}
|
||
{% endcall %}
|
||
{% elif item.get('email address') %}
|
||
{% call field() %}
|
||
{{ item['email address'] }}
|
||
{% endcall %}
|
||
{% else %}
|
||
{% call field(status='missing') %}
|
||
{{ item['phone number'] }}
|
||
{% endcall %}
|
||
{% endif %}
|
||
{% for column in template.placeholders %}
|
||
{% if item.get(column) %}
|
||
{% call field() %}
|
||
{{ item.get(column) }}
|
||
{% endcall %}
|
||
{% else %}
|
||
{% call field(status='missing') %}
|
||
missing
|
||
{% endcall %}
|
||
{% endif %}
|
||
{% endfor %}
|
||
{% endcall %}
|
||
|
||
{% endblock %}
|