From 392536b5e2f6442e0ced98e86c71968cc8d6dbb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= actions
reprend les rôles disposant d'une capacité
d'action sur la demande.
+L'information sur l'origine de la demande, si la saisie a eu lieu depuis le
+backoffice et quel était le canal d'origine de la demande, est disponible
+dans l'attribut submission
.
+
Il est bien sûr nécessaire de disposer des autorisations nécessaires pour diff --git a/tests/test_api.py b/tests/test_api.py index 57bfcfb..5f261bc 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -551,6 +551,7 @@ def test_formdata(pub, local_user): assert resp.json['fields']['item_raw'] == '1' assert resp.json['fields']['item_structured'] == {'id': '1', 'text': 'foo', 'more': 'XXX'} assert resp.json['workflow']['status']['name'] == 'New' + assert resp.json['submission']['channel'] == 'Web' assert [x.get('id') for x in resp.json['roles']['_receiver']] == [str(role.id)] assert [x.get('id') for x in resp.json['roles']['_foobar']] == [str(another_role.id)] @@ -681,6 +682,10 @@ def test_api_list_formdata(pub, local_user): formdata.jump_status('new') else: formdata.jump_status('finished') + if i%7 == 0: + formdata.backoffice_submission = True + formdata.submission_channel = 'mail' + formdata.store() # check access is denied if the user has not the appropriate role @@ -703,6 +708,11 @@ def test_api_list_formdata(pub, local_user): assert 'fields' in resp.json[0] assert 'file' not in resp.json[0]['fields'] # no file export in full lists + assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 0'][0]['submission']['backoffice'] is True + assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 0'][0]['submission']['channel'] == 'Mail' + assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 1'][0]['submission']['backoffice'] is False + assert [x for x in resp.json if x['fields']['foobar'] == 'FOO BAR 1'][0]['submission']['channel'] == 'Web' + # check filtered results resp = get_app(pub).get(sign_uri('/api/forms/test/list?filter-foobar3=foo', user=local_user)) assert len(resp.json) == 8 diff --git a/wcs/formdata.py b/wcs/formdata.py index 7ceaced..aa6ae4b 100644 --- a/wcs/formdata.py +++ b/wcs/formdata.py @@ -673,6 +673,11 @@ class FormData(StorableObject): role_list = [x.get_json_export_dict() for x in role_list if x is not None] data['roles'][role_key] = role_list + data['submission'] = { + 'backoffice': self.backoffice_submission, + 'channel': self.get_submission_channel_label(), + } + return data def export_to_json(self, include_files=True): -- 2.7.0.rc3