Make sure we don't try to move past the top or bottom of the list.
This commit is contained in:
parent
070a9c9350
commit
a99818b177
|
@ -940,6 +940,7 @@ class WorkflowService(object):
|
|||
filter(WorkflowSpecModel.category_id == category_id). \
|
||||
filter(WorkflowSpecModel.display_order == spec.display_order - 1). \
|
||||
first()
|
||||
if neighbor:
|
||||
neighbor.display_order += 1
|
||||
spec.display_order -= 1
|
||||
if direction == 'down':
|
||||
|
@ -947,8 +948,10 @@ class WorkflowService(object):
|
|||
filter(WorkflowSpecModel.category_id == category_id). \
|
||||
filter(WorkflowSpecModel.display_order == spec.display_order + 1). \
|
||||
first()
|
||||
if neighbor:
|
||||
neighbor.display_order -= 1
|
||||
spec.display_order += 1
|
||||
if neighbor:
|
||||
session.add(spec)
|
||||
session.add(neighbor)
|
||||
session.commit()
|
||||
|
@ -965,14 +968,17 @@ class WorkflowService(object):
|
|||
neighbor = session.query(WorkflowSpecCategoryModel).\
|
||||
filter(WorkflowSpecCategoryModel.display_order == category.display_order - 1).\
|
||||
first()
|
||||
if neighbor:
|
||||
neighbor.display_order += 1
|
||||
category.display_order -= 1
|
||||
if direction == 'down':
|
||||
neighbor = session.query(WorkflowSpecCategoryModel).\
|
||||
filter(WorkflowSpecCategoryModel.display_order == category.display_order + 1).\
|
||||
first()
|
||||
if neighbor:
|
||||
neighbor.display_order -= 1
|
||||
category.display_order += 1
|
||||
if neighbor:
|
||||
session.add(neighbor)
|
||||
session.add(category)
|
||||
session.commit()
|
||||
|
|
Loading…
Reference in New Issue