From 907e1cbbb385932f17f8f8ada7bc51241384d4da Mon Sep 17 00:00:00 2001 From: Dan Funk Date: Fri, 27 Mar 2020 14:27:50 -0400 Subject: [PATCH] minor fixes that were breaking when connecting to the front end. --- crc/api/study.py | 9 +++++---- crc/api/workflow.py | 2 -- crc/models/api_models.py | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crc/api/study.py b/crc/api/study.py index 1acd76bd..ac335169 100644 --- a/crc/api/study.py +++ b/crc/api/study.py @@ -68,7 +68,7 @@ def all_studies(): """:type: crc.models.user.UserModel""" # Get studies matching this user from Protocol Builder - pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(g.user.id) + pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(g.user.uid) # Get studies from the database db_studies = session.query(StudyModel).filter_by(user_uid=g.user.uid).all() @@ -100,7 +100,7 @@ def post_update_study_from_protocol_builder(study_id): the protocol builder.""" db_study = session.query(StudyModel).filter_by(study_id=study_id).all() - pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(g.user.id) + pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(g.user.uid) pb_study = next((pbs for pbs in pb_studies if pbs.STUDYID == study_id), None) if pb_study: db_study.update_from_protocol_builder(pb_study) @@ -113,9 +113,10 @@ def post_update_study_from_protocol_builder(study_id): def get_study_workflows(study_id): """Returns all the workflows related to this study""" - workflow_models = session.query(WorkflowModel).filter_by(study_id=study_id).all() + existing_workflow_models = session.query(WorkflowModel).filter_by(study_id=study_id).all() + all_specs = session.query(WorkflowSpecModel).filter_by(is_master_spec=False).all() api_models = [] - for workflow_model in workflow_models: + for workflow_model in existing_workflow_models: processor = WorkflowProcessor(workflow_model, workflow_model.bpmn_workflow_json) api_models.append(__get_workflow_api_model(processor)) diff --git a/crc/api/workflow.py b/crc/api/workflow.py index ff87e11c..cd3eed1e 100644 --- a/crc/api/workflow.py +++ b/crc/api/workflow.py @@ -97,10 +97,8 @@ def __get_workflow_api_model(processor: WorkflowProcessor, status_data=None): last_task=Task.from_spiff(processor.bpmn_workflow.last_task), next_task=None, user_tasks=user_tasks, - workflow_spec_id=processor.workflow_spec_id, spec_version=processor.get_spec_version(), is_latest_spec=processor.get_spec_version() == processor.get_latest_version_string(processor.workflow_spec_id), - is_active=is_active ) if processor.next_task(): workflow_api.next_task = Task.from_spiff(processor.next_task()) diff --git a/crc/models/api_models.py b/crc/models/api_models.py index aa8fd0fe..4bee49dc 100644 --- a/crc/models/api_models.py +++ b/crc/models/api_models.py @@ -95,17 +95,15 @@ class TaskSchema(ma.Schema): class WorkflowApi(object): - def __init__(self, id, status, user_tasks, last_task, next_task, workflow_spec_id, spec_version, - is_latest_spec, is_active): + def __init__(self, id, status, user_tasks, last_task, next_task, + spec_version, is_latest_spec): self.id = id self.status = status self.user_tasks = user_tasks self.last_task = last_task self.next_task = next_task - self.workflow_spec_id = workflow_spec_id self.spec_version = spec_version self.is_latest_spec = is_latest_spec - self.is_active = is_active class WorkflowApiSchema(ma.Schema):