mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 16:54:03 -04:00
Merge pull request #2725 from alphagov/job-sent-already
Warn if a file has been sent already
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -60,6 +60,17 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
|
||||
return jobs
|
||||
|
||||
def has_sent_previously(self, service_id, template_id, template_version, original_file_name):
|
||||
return (
|
||||
template_id, template_version, original_file_name
|
||||
) in (
|
||||
(
|
||||
job['template'], job['template_version'], job['original_file_name'],
|
||||
)
|
||||
for job in self.get_jobs(service_id, limit_days=0)['data']
|
||||
if job['job_status'] != 'cancelled'
|
||||
)
|
||||
|
||||
def get_page_of_jobs(self, service_id, page):
|
||||
return self.get_jobs(
|
||||
service_id,
|
||||
|
||||
6
app/templates/partials/check/sent-previously.html
Normal file
6
app/templates/partials/check/sent-previously.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="File previously sent" data-error-label="{{ upload_id }}">
|
||||
You already sent these messages
|
||||
</h1>
|
||||
<p>
|
||||
If you want to send the same messages again, rename the file and re-upload it
|
||||
</p>
|
||||
@@ -98,6 +98,10 @@
|
||||
) }}.
|
||||
</p>
|
||||
|
||||
{% elif sent_previously %}
|
||||
|
||||
{% include "partials/check/sent-previously.html" %}
|
||||
|
||||
{% elif not recipients.allowed_to_send_to %}
|
||||
|
||||
{% with
|
||||
|
||||
Reference in New Issue
Block a user