Gets mi_index out of Spiff task internal data

This commit is contained in:
Aaron Louie 2020-06-28 11:35:35 -04:00
parent 848ad563d3
commit a996c81508
1 changed files with 10 additions and 10 deletions

View File

@ -240,24 +240,24 @@ class WorkflowService(object):
return workflow_api return workflow_api
@staticmethod @staticmethod
def get_previously_submitted_data(workflow_id, task): def get_previously_submitted_data(workflow_id, spiff_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."""
query = db.session.query(TaskEventModel) \ query = 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=spiff_task.task_spec.name) \
.filter_by(action=WorkflowService.TASK_ACTION_COMPLETE) .filter_by(action=WorkflowService.TASK_ACTION_COMPLETE)
if hasattr(task, 'multi_instance_index'): if hasattr(spiff_task, 'internal_data') and 'runtimes' in spiff_task.internal_data:
query = query.filter_by(mi_index=task.multi_instance_index) query = query.filter_by(mi_index=spiff_task.internal_data['runtimes'])
latest_event = query.order_by(TaskEventModel.date.desc()).first() 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
else: else:
app.logger.error("missing_form_dat", "We have lost data for workflow %i, task %s, it is not " app.logger.error("missing_form_data", "We have lost data for workflow %i, "
"in the task event model, " "task %s, it is not in the task event model, "
"and it should be." % (workflow_id, task.task_spec.name)) "and it should be." % (workflow_id, spiff_task.task_spec.name))
return {} return {}
else: else:
return {} return {}
@ -294,8 +294,8 @@ class WorkflowService(object):
props = {} props = {}
if hasattr(spiff_task.task_spec, 'extensions'): if hasattr(spiff_task.task_spec, 'extensions'):
for id, val in spiff_task.task_spec.extensions.items(): for key, val in spiff_task.task_spec.extensions.items():
props[id] = val props[key] = val
task = Task(spiff_task.id, task = Task(spiff_task.id,
spiff_task.task_spec.name, spiff_task.task_spec.name,