Only filters by mi_index if task has a mult_instance_index

This commit is contained in:
Aaron Louie 2020-06-26 12:47:42 -04:00
parent 0ef52854a0
commit 848ad563d3
1 changed files with 7 additions and 5 deletions

View File

@ -242,13 +242,15 @@ class WorkflowService(object):
@staticmethod @staticmethod
def get_previously_submitted_data(workflow_id, task): def get_previously_submitted_data(workflow_id, task):
""" If the user has completed this task previously, find the form data for the last submission.""" """ If the user has completed this task previously, find the form data for the last submission."""
mi_index = task.multi_instance_index if hasattr(task, 'multi_instance_index') else None; query = db.session.query(TaskEventModel) \
latest_event = db.session.query(TaskEventModel) \
.filter_by(workflow_id=workflow_id) \ .filter_by(workflow_id=workflow_id) \
.filter_by(task_name=task.task_spec.name) \ .filter_by(task_name=task.task_spec.name) \
.filter_by(action=WorkflowService.TASK_ACTION_COMPLETE) \ .filter_by(action=WorkflowService.TASK_ACTION_COMPLETE)
.filter_by(mi_index=mi_index) \
.order_by(TaskEventModel.date.desc()).first() if hasattr(task, 'multi_instance_index'):
query = query.filter_by(mi_index=task.multi_instance_index)
latest_event = query.order_by(TaskEventModel.date.desc()).first()
if latest_event: if latest_event:
if latest_event.form_data is not None: if latest_event.form_data is not None:
return latest_event.form_data return latest_event.form_data