Merge pull request #370 from sartography/library-listing-453
Library listing #453
This commit is contained in:
commit
15efc2f3f1
|
@ -31,11 +31,14 @@ def all_specifications(libraries=False,standalone=False):
|
||||||
if standalone:
|
if standalone:
|
||||||
return schema.dump(session.query(WorkflowSpecModel)\
|
return schema.dump(session.query(WorkflowSpecModel)\
|
||||||
.filter(WorkflowSpecModel.standalone==True).all())
|
.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 standard workflows (not library, not standalone)
|
||||||
return schema.dump(session.query(WorkflowSpecModel)\
|
return schema.dump(session.query(WorkflowSpecModel)
|
||||||
.filter((WorkflowSpecModel.library==False)|(
|
.filter((WorkflowSpecModel.library==False) | (
|
||||||
WorkflowSpecModel.library==None)).all())
|
WorkflowSpecModel.library==None))
|
||||||
|
.filter((WorkflowSpecModel.standalone==False) | (
|
||||||
|
WorkflowSpecModel.standalone==None))
|
||||||
|
.all())
|
||||||
|
|
||||||
|
|
||||||
def add_workflow_specification(body):
|
def add_workflow_specification(body):
|
||||||
|
@ -43,6 +46,9 @@ def add_workflow_specification(body):
|
||||||
WorkflowService.cleanup_workflow_spec_display_order(category_id)
|
WorkflowService.cleanup_workflow_spec_display_order(category_id)
|
||||||
count = session.query(WorkflowSpecModel).filter_by(category_id=category_id).count()
|
count = session.query(WorkflowSpecModel).filter_by(category_id=category_id).count()
|
||||||
body['display_order'] = 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)
|
new_spec: WorkflowSpecModel = WorkflowSpecModelSchema().load(body, session=session)
|
||||||
session.add(new_spec)
|
session.add(new_spec)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
@ -119,6 +125,10 @@ def update_workflow_specification(spec_id, body):
|
||||||
# There is a separate endpoint for this
|
# There is a separate endpoint for this
|
||||||
body['display_order'] = spec.display_order
|
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()
|
schema = WorkflowSpecModelSchema()
|
||||||
spec = schema.load(body, session=session, instance=spec, partial=True)
|
spec = schema.load(body, session=session, instance=spec, partial=True)
|
||||||
session.add(spec)
|
session.add(spec)
|
||||||
|
|
|
@ -221,3 +221,18 @@ class TestWorkflowSpec(BaseTest):
|
||||||
for test_category in categories:
|
for test_category in categories:
|
||||||
self.assertEqual(test_order, test_category.display_order)
|
self.assertEqual(test_order, test_category.display_order)
|
||||||
test_order += 1
|
test_order += 1
|
||||||
|
|
||||||
|
def test_add_library_with_category_id(self):
|
||||||
|
self.load_example_data()
|
||||||
|
category_id = session.query(WorkflowSpecCategoryModel).first().id
|
||||||
|
spec = WorkflowSpecModel(id='test_spec', name='test_spec', display_name='Test Spec',
|
||||||
|
description='Library with a category id', category_id=category_id,
|
||||||
|
standalone=False, library=True)
|
||||||
|
rv = self.app.post('/v1.0/workflow-specification',
|
||||||
|
headers=self.logged_in_headers(),
|
||||||
|
content_type="application/json",
|
||||||
|
data=json.dumps(WorkflowSpecModelSchema().dump(spec)))
|
||||||
|
self.assert_success(rv)
|
||||||
|
# libraries don't get category_ids
|
||||||
|
# so, the category_id should not get set
|
||||||
|
self.assertIsNone(rv.json['category_id'])
|
||||||
|
|
Loading…
Reference in New Issue