Sorts approvals by display order

This commit is contained in:
Aaron Louie 2020-04-24 08:54:14 -04:00
parent 1ccedbc9fd
commit c85173de88
2 changed files with 5 additions and 0 deletions

View File

@ -79,14 +79,18 @@ class StudyService(object):
approvals = []
for workflow in workflows:
workflow: WorkflowModel = workflow
spec: WorkflowSpecModel = next(s for s in specs if s.id == workflow.workflow_spec_id)
approvals.append({
'study_id': study_id,
'workflow_id': workflow.id,
'display_name': workflow.workflow_spec.display_name,
'display_order': spec.display_order or 0,
'name': workflow.workflow_spec.display_name,
'status': workflow.status.value,
'workflow_spec_id': workflow.workflow_spec_id,
})
approvals.sort(key=lambda k: k['display_order'])
return approvals
@staticmethod

View File

@ -82,3 +82,4 @@ class TestStudyService(BaseTest):
# Get approvals
approvals = StudyService.get_approvals(studies[0].id)
self.assertGreater(len(approvals), 0)
self.assertIsNotNone(approvals[0]['display_order'])