From 24c818bf311454339ed7629c54ff1e2d4314dfaf Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 29 Apr 2021 14:29:21 -0400 Subject: [PATCH] Added study_id to workflow_api --- crc/api.yml | 4 +++- crc/models/api_models.py | 7 ++++--- crc/services/workflow_service.py | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crc/api.yml b/crc/api.yml index b9ed7df1..be95c2dd 100644 --- a/crc/api.yml +++ b/crc/api.yml @@ -427,7 +427,7 @@ paths: - name: spec_id in: path required: true - description: The unique id of an existing workflow specification to modify. + description: The unique id of an existing workflow specification. schema: type: string get: @@ -1640,6 +1640,8 @@ components: type: integer num_tasks_incomplete: type: integer + study_id: + type: integer example: id: 291234 diff --git a/crc/models/api_models.py b/crc/models/api_models.py index 2bb4abc6..308823fc 100644 --- a/crc/models/api_models.py +++ b/crc/models/api_models.py @@ -191,7 +191,7 @@ class DocumentDirectory(object): class WorkflowApi(object): def __init__(self, id, status, next_task, navigation, spec_version, is_latest_spec, workflow_spec_id, total_tasks, completed_tasks, - last_updated, is_review, title): + last_updated, is_review, title, study_id): self.id = id self.status = status self.next_task = next_task # The next task that requires user input. @@ -204,13 +204,14 @@ class WorkflowApi(object): self.last_updated = last_updated self.title = title self.is_review = is_review + self.study_id = study_id or '' class WorkflowApiSchema(ma.Schema): class Meta: model = WorkflowApi fields = ["id", "status", "next_task", "navigation", "workflow_spec_id", "spec_version", "is_latest_spec", "total_tasks", "completed_tasks", - "last_updated", "is_review", "title"] + "last_updated", "is_review", "title", "study_id"] unknown = INCLUDE status = EnumField(WorkflowStatus) @@ -221,7 +222,7 @@ class WorkflowApiSchema(ma.Schema): def make_workflow(self, data, **kwargs): keys = ['id', 'status', 'next_task', 'navigation', 'workflow_spec_id', 'spec_version', 'is_latest_spec', "total_tasks", "completed_tasks", - "last_updated", "is_review", "title"] + "last_updated", "is_review", "title", "study_id"] filtered_fields = {key: data[key] for key in keys} filtered_fields['next_task'] = TaskSchema().make_task(data['next_task']) return WorkflowApi(**filtered_fields) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 9edaf856..2369ceaf 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -408,7 +408,8 @@ class WorkflowService(object): completed_tasks=processor.workflow_model.completed_tasks, last_updated=processor.workflow_model.last_updated, is_review=is_review, - title=spec.display_name + title=spec.display_name, + study_id=processor.workflow_model.study_id or None ) if not next_task: # The Next Task can be requested to be a certain task, useful for parallel tasks. # This may or may not work, sometimes there is no next task to complete.