Delete files in db model methods.

This commit is contained in:
Patrick Jentsch
2020-07-10 11:36:54 +02:00
parent f86f3f4fd5
commit 7f8797d227
8 changed files with 84 additions and 93 deletions

View File

@ -1,22 +1,23 @@
from .. import db
from ..decorators import background
from ..models import Job
@background
def delete_job(job_id, *args, **kwargs):
app = kwargs['app']
with app.app_context():
with kwargs['app'].app_context():
job = Job.query.get(job_id)
if job is None:
raise Exception('Could not find job with id {}'.format(job_id))
raise Exception('Job {} not found'.format(job_id))
job.delete()
db.session.commit()
@background
def restart_job(job_id, *args, **kwargs):
app = kwargs['app']
with app.app_context():
with kwargs['app'].app_context():
job = Job.query.get(job_id)
if job is None:
raise Exception('Could not find job with id {}'.format(job_id))
raise Exception('Job {} not found'.format(job_id))
job.restart()
db.session.commit()

View File

@ -60,10 +60,6 @@ def restart(job_id):
else:
tasks.restart_job(job_id)
flash('Job has been restarted!', 'job')
job_inputs = [dict(filename=input.filename,
id=input.id,
job_id=job.id)
for input in job.inputs]
return redirect(url_for('jobs.job', job_id=job_id))