0001-api-expose-backoffice_submission-and-submission_chan.patch
help/fr/api-get.page | ||
---|---|---|
106 | 106 |
"allows_backoffice_access": true |
107 | 107 |
} |
108 | 108 |
] |
109 |
}, |
|
110 |
"submission": { |
|
111 |
"backoffice": false, |
|
112 |
"channel": "Web" |
|
109 | 113 |
} |
110 | 114 |
} |
111 | 115 |
</code> |
... | ... | |
123 | 127 |
d'action sur la demande. |
124 | 128 |
</p> |
125 | 129 | |
130 |
<p> |
|
131 |
L'information sur l'origine de la demande, si la saisie a eu lieu depuis le |
|
132 |
backoffice et quel était le canal d'origine de la demande, est disponible |
|
133 |
dans l'attribut <code>submission</code>. |
|
134 |
</p> |
|
135 | ||
126 | 136 |
<note> |
127 | 137 |
<p> |
128 | 138 |
Il est bien sûr nécessaire de disposer des autorisations nécessaires pour |
tests/test_api.py | ||
---|---|---|
551 | 551 |
assert resp.json['fields']['item_raw'] == '1' |
552 | 552 |
assert resp.json['fields']['item_structured'] == {'id': '1', 'text': 'foo', 'more': 'XXX'} |
553 | 553 |
assert resp.json['workflow']['status']['name'] == 'New' |
554 |
assert resp.json['submission']['channel'] == 'Web' |
|
554 | 555 | |
555 | 556 |
assert [x.get('id') for x in resp.json['roles']['_receiver']] == [str(role.id)] |
556 | 557 |
assert [x.get('id') for x in resp.json['roles']['_foobar']] == [str(another_role.id)] |
... | ... | |
681 | 682 |
formdata.jump_status('new') |
682 | 683 |
else: |
683 | 684 |
formdata.jump_status('finished') |
685 |
if i%7 == 0: |
|
686 |
formdata.backoffice_submission = True |
|
687 |
formdata.submission_channel = 'mail' |
|
688 | ||
684 | 689 |
formdata.store() |
685 | 690 | |
686 | 691 |
# check access is denied if the user has not the appropriate role |
... | ... | |
703 | 708 |
assert 'fields' in resp.json[0] |
704 | 709 |
assert 'file' not in resp.json[0]['fields'] # no file export in full lists |
705 | 710 | |
711 |
assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 0'][0]['submission']['backoffice'] is True |
|
712 |
assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 0'][0]['submission']['channel'] == 'Mail' |
|
713 |
assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 1'][0]['submission']['backoffice'] is False |
|
714 |
assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 1'][0]['submission']['channel'] == 'Web' |
|
715 | ||
706 | 716 |
# check filtered results |
707 | 717 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list?filter-foobar3=foo', user=local_user)) |
708 | 718 |
assert len(resp.json) == 8 |
wcs/formdata.py | ||
---|---|---|
673 | 673 |
role_list = [x.get_json_export_dict() for x in role_list if x is not None] |
674 | 674 |
data['roles'][role_key] = role_list |
675 | 675 | |
676 |
data['submission'] = { |
|
677 |
'backoffice': self.backoffice_submission, |
|
678 |
'channel': self.get_submission_channel_label(), |
|
679 |
} |
|
680 | ||
676 | 681 |
return data |
677 | 682 | |
678 | 683 |
def export_to_json(self, include_files=True): |
679 |
- |