Add an endpoint to cancel a job

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 `POST`
endpoint for individual jobs which sets their status to `cancelled`.

This also means adding a new status of `cancelled`, so there’s a
migration…
This commit is contained in:
Chris Hill-Scott
2016-09-01 14:31:01 +01:00
parent aa8ee3a8da
commit 4a7267be8b
7 changed files with 92 additions and 2 deletions

View File

@@ -44,6 +44,13 @@ def dao_get_scheduled_jobs():
.all()
def dao_get_future_scheduled_job_by_id_and_service_id(job_id, service_id):
return Job.query \
.filter_by(service_id=service_id, id=job_id) \
.filter(Job.job_status == 'scheduled', Job.scheduled_for > datetime.utcnow()) \
.one()
def dao_create_job(job):
db.session.add(job)
db.session.commit()