2 changes

- The `all_specifications` method is now explicit in what it returns; either `library`, `standalone`, or `regular` workflow specs

- When we add/edit a workflow spec, we make sure that `library` and `standalone` workflow specs do not get a category_id
This commit is contained in:
mike cullerton 2021-09-13 16:15:18 -04:00
parent c9113965f0
commit 7b7c228a81
1 changed files with 15 additions and 5 deletions

View File

@ -31,11 +31,14 @@ def all_specifications(libraries=False,standalone=False):
if standalone:
return schema.dump(session.query(WorkflowSpecModel)\
.filter(WorkflowSpecModel.standalone==True).all())
# this still returns standalone workflow specs as well, but by default
# we do not return specs marked as library
return schema.dump(session.query(WorkflowSpecModel)\
.filter((WorkflowSpecModel.library==False)|(
WorkflowSpecModel.library==None)).all())
# return standard workflows (not library, not standalone)
return schema.dump(session.query(WorkflowSpecModel)
.filter((WorkflowSpecModel.library==False) | (
WorkflowSpecModel.library==None))
.filter((WorkflowSpecModel.standalone==False) | (
WorkflowSpecModel.standalone==None))
.all())
def add_workflow_specification(body):
@ -43,6 +46,9 @@ def add_workflow_specification(body):
WorkflowService.cleanup_workflow_spec_display_order(category_id)
count = session.query(WorkflowSpecModel).filter_by(category_id=category_id).count()
body['display_order'] = count
# Libraries and standalone workflows don't get a category_id
if body['library'] is True or body['standalone'] is True:
body['category_id'] = None
new_spec: WorkflowSpecModel = WorkflowSpecModelSchema().load(body, session=session)
session.add(new_spec)
session.commit()
@ -119,6 +125,10 @@ def update_workflow_specification(spec_id, body):
# There is a separate endpoint for this
body['display_order'] = spec.display_order
# Libraries and standalone workflows don't get a category_id
if body['library'] is True or body['standalone'] is True:
body['category_id'] = None
schema = WorkflowSpecModelSchema()
spec = schema.load(body, session=session, instance=spec, partial=True)
session.add(spec)