Don't let updates to workflow-spec and workflow-spec-category metadata change the display_order

Force display_order changes to use the new reorder API endpoints
This commit is contained in:
mike cullerton 2021-08-31 10:36:22 -04:00
parent f6816a2e42
commit 994ce4008f
1 changed files with 9 additions and 0 deletions

View File

@ -104,6 +104,7 @@ def validate_workflow_specification(spec_id, study_id=None, test_until=None):
return ApiErrorSchema(many=True).dump([error])
return []
def update_workflow_specification(spec_id, body):
if spec_id is None:
raise ApiError('unknown_spec', 'Please provide a valid Workflow Spec ID.')
@ -112,6 +113,10 @@ def update_workflow_specification(spec_id, body):
if spec is None:
raise ApiError('unknown_study', 'The spec "' + spec_id + '" is not recognized.')
# Make sure they don't try to change the display_order
# There is a separate endpoint for this
body['display_order'] = spec.display_order
schema = WorkflowSpecModelSchema()
spec = schema.load(body, session=session, instance=spec, partial=True)
session.add(spec)
@ -334,6 +339,10 @@ def update_workflow_spec_category(cat_id, body):
if category is None:
raise ApiError('unknown_category', 'The category "' + cat_id + '" is not recognized.')
# Make sure they don't try to change the display_order
# There is a separate endpoint for that
body['display_order'] = category.display_order
schema = WorkflowSpecCategoryModelSchema()
category = schema.load(body, session=session, instance=category, partial=True)
session.add(category)