diff --git a/beat/web/backend/helpers.py b/beat/web/backend/helpers.py index 98f18efecd270eb8b07dde183ca51c9cdf6e0cec..f9c7541d54b2c6d5d99dc959143fe1cd786e9404 100755 --- a/beat/web/backend/helpers.py +++ b/beat/web/backend/helpers.py @@ -712,9 +712,7 @@ def update_job(job): cached_file.update(Block.FAILED) # Update the block - job.block.status = Block.FAILED - job.block.end_date = job.end_date - job.block.save() + job.block.set_failed(job.end_date) # Cancel all the remaining blocks of the experiment splits_to_cancel.extend(cancel_all_blocks(job.block.experiment)) @@ -728,9 +726,7 @@ def update_job(job): mirror_job.end_date = job.end_date mirror_job.save() - mirror_job.block.status = Block.FAILED - mirror_job.block.end_date = job.end_date - mirror_job.block.save() + mirror_job.block.set_failed(job.end_date) # Cancel all the remaining blocks of the experiment splits_to_cancel.extend(cancel_all_blocks(mirror_job.block.experiment)) @@ -795,9 +791,7 @@ def update_job(job): cached_file.update(Block.CANCELLED) # Update the block - job.block.status = Block.CANCELLED - job.block.end_date = job.end_date - job.block.save() + job.block.set_canceled(job.end_date) # Update the experiment update_experiment(job.block.experiment) @@ -874,12 +868,7 @@ def cancel_all_blocks(experiment): # (If possible) Mark the block as cancelled if block.job.splits.filter(status=JobSplit.CANCELLING).count() == 0: - block.status = Block.CANCELLED - block.end_date = datetime.now() - if block.start_date is None: - block.start_date = block.end_date - block.save() - + block.set_canceled() block.job.delete() @@ -888,15 +877,9 @@ def cancel_all_blocks(experiment): .filter(job__mirror=True) for block in mirror_blocks_to_cancel: - block.status = Block.CANCELLED - block.end_date = datetime.now() - if block.start_date is None: - block.start_date = block.end_date - block.save() - + block.set_canceled() block.job.delete() - return splits_to_cancel