From fc58547be30f5fe7b09fa8b7c538815b94e458e4 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 16 Mar 2020 17:00:34 +0000 Subject: [PATCH] =?UTF-8?q?Tell=20the=20API=20which=20contact=20list=20a?= =?UTF-8?q?=20job=E2=80=99s=20come=20from?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that we can make enhancements to the UI in the future, for example grouping jobs within their associated contact list. --- app/main/views/send.py | 4 ++- app/notify_client/job_api_client.py | 5 ++- app/templates/views/check/ok.html | 1 + tests/app/main/views/test_send.py | 38 ++++++++++++++++++++-- tests/app/notify_client/test_job_client.py | 15 +++++++++ tests/conftest.py | 2 +- 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index bde1b3a85..7784dd902 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -530,6 +530,7 @@ def send_from_contact_list(service_id, template_id, contact_list_id): template_id=template_id, upload_id=contact_list.copy_to_uploads(), original_file_name=contact_list.original_file_name, + contact_list_id=contact_list.id, )) @@ -742,7 +743,8 @@ def start_job(service_id, upload_id): job_api_client.create_job( upload_id, service_id, - scheduled_for=request.form.get('scheduled_for', '') + scheduled_for=request.form.get('scheduled_for', ''), + contact_list_id=request.form.get('contact_list_id', ''), ) session.pop('sender_id', None) diff --git a/app/notify_client/job_api_client.py b/app/notify_client/job_api_client.py index 803bbe26e..f143da94b 100644 --- a/app/notify_client/job_api_client.py +++ b/app/notify_client/job_api_client.py @@ -78,12 +78,15 @@ class JobApiClient(NotifyAdminAPIClient): def has_jobs(self, service_id): return bool(self.get_jobs(service_id)['data']) - def create_job(self, job_id, service_id, scheduled_for=None): + def create_job(self, job_id, service_id, scheduled_for=None, contact_list_id=None): data = {"id": job_id} if scheduled_for: data.update({'scheduled_for': scheduled_for}) + if contact_list_id: + data.update({'contact_list_id': contact_list_id}) + data = _attach_current_user(data) job = self.post(url='/service/{}/job'.format(service_id), data=data) diff --git a/app/templates/views/check/ok.html b/app/templates/views/check/ok.html index 3ec9d2ac9..7554f18c0 100644 --- a/app/templates/views/check/ok.html +++ b/app/templates/views/check/ok.html @@ -37,6 +37,7 @@