mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-14 10:00:40 +00:00
Delete files in db model methods.
This commit is contained in:
@ -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()
|
||||
|
@ -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))
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user