From 9bd012c8222512e94f8a981aac6cdb4de28a4be2 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Wed, 8 Sep 2021 11:16:49 -0400 Subject: [PATCH] Clean up display_order numbers when reordering. This fixes the problem where we have don't have all unique display_order numbers. I.e., 0, 1, 1, 3, 5 --- crc/api/workflow.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crc/api/workflow.py b/crc/api/workflow.py index fb3f6a91..e0091b25 100644 --- a/crc/api/workflow.py +++ b/crc/api/workflow.py @@ -161,6 +161,7 @@ def reorder_workflow_specification(spec_id, direction): message='The direction must be `up` or `down`.') spec = session.query(WorkflowSpecModel).filter(WorkflowSpecModel.id == spec_id).first() if spec: + WorkflowService.cleanup_workflow_spec_display_order(spec.category_id) ordered_specs = WorkflowService.reorder_workflow_spec(spec, direction) else: raise ApiError(code='bad_spec_id', @@ -366,6 +367,7 @@ def reorder_workflow_spec_category(cat_id, direction): if direction not in ('up', 'down'): raise ApiError(code='bad_direction', message='The direction must be `up` or `down`.') + WorkflowService.cleanup_workflow_spec_category_display_order() category = session.query(WorkflowSpecCategoryModel).\ filter(WorkflowSpecCategoryModel.id == cat_id).first() if category: