nopaque/web/app/results/tasks.py

14 lines
419 B
Python
Raw Normal View History

2020-07-10 09:36:54 +00:00
from .. import db
from ..decorators import background
from ..models import Result
@background
def delete_result(result_id, *args, **kwargs):
2020-07-10 09:36:54 +00:00
with kwargs['app'].app_context():
result = Result.query.get(result_id)
if result is None:
2020-07-10 09:36:54 +00:00
raise Exception('Result {} not found'.format(result_id))
result.delete() # cascades down and also deletes ResultFile
2020-07-10 09:36:54 +00:00
db.session.commit()