api: export Status.is_waitpoint() in schema (#36412)
This commit is contained in:
parent
fb9ed2bc3e
commit
b8186bfb90
|
@ -494,8 +494,16 @@ def test_backoffice_submission_formdef_list(pub, local_user):
|
|||
def test_formdef_schema(pub):
|
||||
Workflow.wipe()
|
||||
workflow = Workflow(name='test')
|
||||
workflow.add_status('Status1', 'st1')
|
||||
workflow.add_status('Status2', 'st2')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.status = 'st2'
|
||||
jump.timeout = 100
|
||||
st1.items.append(jump)
|
||||
st2 = workflow.add_status('Status2', 'st2')
|
||||
jump = JumpWorkflowStatusItem()
|
||||
jump.status = 'st3'
|
||||
st2.items.append(jump)
|
||||
st2 = workflow.add_status('Status3', 'st3')
|
||||
workflow.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(workflow)
|
||||
workflow.backoffice_fields_formdef.fields = [
|
||||
fields.StringField(id='bo1', label='1st backoffice field',
|
||||
|
@ -575,8 +583,18 @@ def test_formdef_schema(pub):
|
|||
assert resp4.json['fields'][1]['items'] == []
|
||||
|
||||
# workflow checks
|
||||
assert len(resp.json['workflow']['statuses']) == 2
|
||||
assert len(resp.json['workflow']['statuses']) == 3
|
||||
assert resp.json['workflow']['statuses'][0]['id'] == 'st1'
|
||||
assert resp.json['workflow']['statuses'][0]['endpoint'] is False
|
||||
assert resp.json['workflow']['statuses'][0]['waitpoint'] is True
|
||||
assert resp.json['workflow']['statuses'][1]['id'] == 'st2'
|
||||
assert resp.json['workflow']['statuses'][1]['endpoint'] is False
|
||||
assert resp.json['workflow']['statuses'][1]['waitpoint'] is False
|
||||
assert resp.json['workflow']['statuses'][2]['id'] == 'st3'
|
||||
assert resp.json['workflow']['statuses'][2]['endpoint'] is True
|
||||
assert resp.json['workflow']['statuses'][2]['waitpoint'] is True
|
||||
assert len(resp.json['workflow']['fields']) == 1
|
||||
|
||||
assert resp.json['workflow']['fields'][0]['label'] == '1st backoffice field'
|
||||
|
||||
get_app(pub).get('/api/formdefs/xxx/schema', status=404)
|
||||
|
|
|
@ -652,12 +652,14 @@ class Workflow(StorableObject):
|
|||
roles[role] = unicode(label, charset)
|
||||
statuses = root['statuses'] = []
|
||||
endpoint_status_ids = [s.id for s in self.get_endpoint_status()]
|
||||
waitpoint_status_ids = [s.id for s in self.get_waitpoint_status()]
|
||||
for status in self.possible_status:
|
||||
statuses.append({
|
||||
'id': status.id,
|
||||
'name': unicode(status.name, charset),
|
||||
'forced_endpoint': status.forced_endpoint,
|
||||
'endpoint': status.id in endpoint_status_ids,
|
||||
'waitpoint': status.id in waitpoint_status_ids,
|
||||
})
|
||||
root['fields'] = []
|
||||
for field in self.get_backoffice_fields():
|
||||
|
|
Loading…
Reference in New Issue