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

@@ -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,