diff --git a/web/app/jobs/views.py b/web/app/jobs/views.py index ffb5df150f797b2eea59837e330d8085f96e53dd..4101c7ae9b6d47544df0c2d1d7c4dae9e6c12a3b 100644 --- a/web/app/jobs/views.py +++ b/web/app/jobs/views.py @@ -47,8 +47,8 @@ def download_job_input(job_id, job_input_id): @admin_required def restart(job_id): job = Job.query.get_or_404(job_id) - if job.status != 'failed': - flash('Can not restart job "{}": Status is not "failed"'.format(job.title), 'error') # noqa + if job.status not in ['complete', 'failed']: + flash('Can not restart job "{}": Status is not "complete/failed"'.format(job.title), 'error') # noqa else: tasks.restart_job(job_id) flash('Job "{}" has been marked to get restarted!'.format(job.title), 'job') # noqa diff --git a/web/app/models.py b/web/app/models.py index 6cd94698e24f9da3e40a0a17e65b1b9894db920d..ba139e9196a78130686c2146bc30a14290ca07f1 100644 --- a/web/app/models.py +++ b/web/app/models.py @@ -410,11 +410,11 @@ class Job(db.Model): def restart(self): ''' - Restart a job - only if the status is failed + Restart a job - only if the status is complete or failed ''' - if self.status != 'failed': - raise Exception('Could not restart job: status is not "failed"') + if self.status not in ['complete', 'failed']: + raise Exception('Could not restart job: status is not "complete/failed"') # noqa shutil.rmtree(os.path.join(self.path, 'output'), ignore_errors=True) shutil.rmtree(os.path.join(self.path, 'pyflow.data'), ignore_errors=True) # noqa self.end_date = None