Warn if a file has been sent already

We have some teams who haver a series of files they have to send each
day. It’s easy to get muddled up and accidentally send the same file
again, if you think you haven’t already sent it.

This commit blocks you from sending the same combination of template
version and filename more than once on the same day[1].

This won’t affect teams who re-use the same template to give (for
example) updates on an incident for business continuity. These teams
edit the template between each send, thereby updating the version
number of the template.

1. This is based on how the `limit_days` argument to the API works - you
can dig into the code here: 2bd4f74ad0/app/dao/jobs_dao.py (L50)
This commit is contained in:
Chris Hill-Scott
2019-02-04 14:08:11 +00:00
parent 2055a83516
commit 88f9d156c7
6 changed files with 105 additions and 11 deletions

View File

@@ -609,6 +609,9 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
)),
required_recipient_columns=OrderedSet(recipients.recipient_column_headers) - optional_address_columns,
preview_row=preview_row,
sent_previously=job_api_client.has_sent_previously(
service_id, template.id, db_template['version'], request.args.get('original_file_name', '')
)
)
@@ -625,7 +628,8 @@ def check_messages(service_id, template_id, upload_id, row_index=2):
not data['count_of_recipients'] or
not data['recipients'].has_recipient_columns or
data['recipients'].duplicate_recipient_column_headers or
data['recipients'].missing_column_headers
data['recipients'].missing_column_headers or
data['sent_previously']
):
return render_template('views/check/column-errors.html', **data)