Add a cancel job button

If you schedule a job you might change your mind or circumstances might
change. So you need to be able to cancel it. This commit adds a button
on the job page which hits the `…/cancel` API endpoint for a job.
This commit is contained in:
Chris Hill-Scott
2016-09-01 15:40:49 +01:00
parent c94675f457
commit eb11615a32
5 changed files with 68 additions and 1 deletions

View File

@@ -77,3 +77,18 @@ class JobApiClient(BaseAPIClient):
job['data']['notifications_requested'] = stats['requested']
return job
def cancel_job(self, service_id, job_id):
job = self.post(
url='/service/{}/job/{}/cancel'.format(service_id, job_id),
data={}
)
stats = self.__convert_statistics(job['data'])
job['data']['notifications_sent'] = stats['delivered'] + stats['failed']
job['data']['notifications_delivered'] = stats['delivered']
job['data']['notifications_failed'] = stats['failed']
job['data']['notifications_requested'] = stats['requested']
return job