Make sure we don't try to get WorkflowMetadata if the spec does not exist

This was raising a 500 error
This commit is contained in:
mike cullerton 2022-02-25 14:41:58 -05:00
parent dd7eddb936
commit 531802f927

View File

@ -243,9 +243,10 @@ def get_task_events(action = None, workflow = None, study = None):
study = session.query(StudyModel).filter(StudyModel.id == event.study_id).first()
workflow = session.query(WorkflowModel).filter(WorkflowModel.id == event.workflow_id).first()
spec = WorkflowSpecService().get_spec(workflow.workflow_spec_id)
workflow_meta = WorkflowMetadata.from_workflow(workflow, spec)
if study and study.status in [StudyStatus.open_for_enrollment, StudyStatus.in_progress]:
task_events.append(TaskEvent(event, study, workflow_meta))
if spec is not None:
workflow_meta = WorkflowMetadata.from_workflow(workflow, spec)
if study and study.status in [StudyStatus.open_for_enrollment, StudyStatus.in_progress]:
task_events.append(TaskEvent(event, study, workflow_meta))
return TaskEventSchema(many=True).dump(task_events)