mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Use Template to replace/highlight placeholders
This commit brings in the `Template` util, added here: https://github.com/alphagov/notifications-utils/pull/1 It also does a fair bit of tidying up, which I’ve unfortunately squashed into this one massive commit. The main change is moving 404 handling into the templates dao, so that every view isn’t littered with `try: … except(HTTPError)`. It also adds new features, in a prototypy sort of way, which are: - download a prefilled example CSV - show all the columns for your template on the 'check' page
This commit is contained in:
@@ -17,14 +17,14 @@
|
||||
{% for rejected in upload_result.rejects %}
|
||||
<p>Line {{rejected.line_number}}: {{rejected.phone }}</a>
|
||||
{% endfor %}
|
||||
<p><a href="{{url_for('.send_sms', service_id=service_id, template_id=template_id)}}" class="button">Go back and resolve errors</a></p>
|
||||
<p><a href="{{url_for('.send_sms', service_id=service_id, template_id=template.id)}}" class="button">Go back and resolve errors</a></p>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-two-thirds">
|
||||
{{ sms_message(
|
||||
message_template|replace_placeholders(upload_result.valid[0])
|
||||
template.replaced
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,13 +32,13 @@
|
||||
<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.valid|count, '' if upload_result.valid|count == 1 else 's') }}" />
|
||||
<a href="{{url_for('.send_sms', service_id=service_id, template_id=template_id)}}" class="page-footer-back-link">Back</a>
|
||||
<a href="{{url_for('.send_sms', service_id=service_id, template_id=template.id)}}" class="page-footer-back-link">Back</a>
|
||||
</form>
|
||||
|
||||
{% call(item) list_table(
|
||||
upload_result.valid,
|
||||
caption=original_file_name,
|
||||
field_headings=['Phone number']
|
||||
field_headings=column_headers
|
||||
) %}
|
||||
{% call field() %}
|
||||
{{ item.phone }}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<div class="grid-row">
|
||||
<div class="column-two-thirds">
|
||||
{{ sms_message(
|
||||
template['content'],
|
||||
template.formatted_as_markup,
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,19 +26,19 @@ Manage templates – GOV.UK Notify
|
||||
<div class="column-two-thirds">
|
||||
|
||||
{% for template in templates %}
|
||||
{% if template.get_field('template_type') == 'sms' %}
|
||||
{{ sms_message(
|
||||
template.get_field('content'),
|
||||
name=template.title,
|
||||
id=template.get_field('id'),
|
||||
edit_link=url_for('.edit_service_template', service_id=template.get_field('service'), template_id=template.get_field('id'))
|
||||
) }}
|
||||
{% elif template.get_field('template_type') == 'email' %}
|
||||
{% if template.template_type == 'email' %}
|
||||
{{ email_message(
|
||||
template.get_field('subject'),
|
||||
template.get_field('content'),
|
||||
name=template.get_field('name'),
|
||||
edit_link=url_for('.edit_service_template', service_id=template.get_field('service'), template_id=template.get_field('id'))
|
||||
edit_link=url_for('.edit_service_template', service_id=service_id, template_id=template.id)
|
||||
) }}
|
||||
{% else %}
|
||||
{{ sms_message(
|
||||
template.formatted_as_markup,
|
||||
name=template.name,
|
||||
id=template.id,
|
||||
edit_link=url_for('.edit_service_template', service_id=service_id, template_id=template.id)
|
||||
) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% from "components/sms-message.html" import sms_message %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/table.html" import list_table %}
|
||||
|
||||
{% block page_title %}
|
||||
Send text messages – GOV.UK Notify
|
||||
@@ -32,5 +33,20 @@
|
||||
"Continue to preview"
|
||||
) }}
|
||||
|
||||
{% if column_headers %}
|
||||
{% call(item) list_table(
|
||||
[],
|
||||
caption='Preview',
|
||||
field_headings=column_headers,
|
||||
field_headings_visible=True,
|
||||
caption_visible=False,
|
||||
empty_message="Your data here"
|
||||
) %}
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
<p class="table-show-more-link">
|
||||
<a href="{{ url_for('.get_example_csv', service_id=service_id, template_id=template.id) }}">Download this CSV file</a>
|
||||
</p>
|
||||
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user