Files
notifications-api/app/dao/jobs_dao.py
Adam Shimali e024db6858 As job update is a PUT then all non nullable fields
need to be sent with update.

Also bug in not committing update fixed.
2016-02-05 13:07:02 +00:00

26 lines
594 B
Python

from app import db
from app.models import Job
def save_job(job, update_dict={}):
if update_dict:
update_dict.pop('id', None)
update_dict.pop('service', None)
update_dict.pop('template', None)
Job.query.filter_by(id=job.id).update(update_dict)
else:
db.session.add(job)
db.session.commit()
def get_job(service_id, job_id):
return Job.query.filter_by(service_id=service_id, id=job_id).one()
def get_jobs_by_service(service_id):
return Job.query.filter_by(service_id=service_id).all()
def _get_jobs():
return Job.query.all()