0001-api-add-include-workflow-data-param-71330.patch
tests/api/test_carddata.py | ||
---|---|---|
7 | 7 |
from wcs.api_access import ApiAccess |
8 | 8 |
from wcs.carddef import CardDef |
9 | 9 |
from wcs.qommon.http_request import HTTPRequest |
10 |
from wcs.qommon.upload_storage import PicklableUpload |
|
10 | 11 | |
11 | 12 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app |
12 | 13 |
from .utils import sign_uri |
... | ... | |
120 | 121 |
carddata.data = {'1': 'FOO BAR'} |
121 | 122 |
carddata.user_id = local_user.id |
122 | 123 |
carddata.just_created() |
124 |
upload = PicklableUpload('test.txt', 'text/plain', 'ascii') |
|
125 |
upload.receive([b'test']) |
|
126 |
upload2 = PicklableUpload('test.txt', 'text/plain', 'ascii') |
|
127 |
upload2.receive([b'test']) |
|
128 |
carddata.workflow_data = {'blah': upload, 'blah2': upload2, 'xxx': 23} |
|
123 | 129 |
carddata.store() |
124 | 130 | |
125 | 131 |
ApiAccess.wipe() |
... | ... | |
163 | 169 |
assert 'submission' in resp.json['data'][0] |
164 | 170 |
resp = get_url('/api/cards/test/list?include-workflow=on') |
165 | 171 |
assert 'workflow' in resp.json['data'][0] |
172 |
assert 'data' not in resp.json['data'][0]['workflow'] |
|
173 |
resp = get_url('/api/cards/test/list?include-workflow-data=on') |
|
174 |
assert 'workflow' in resp.json['data'][0] |
|
175 |
assert 'data' in resp.json['data'][0]['workflow'] |
|
166 | 176 | |
167 | 177 | |
168 | 178 |
def test_carddata_user_fields(pub, local_user): |
tests/api/test_formdata.py | ||
---|---|---|
283 | 283 |
'?include-roles=on', |
284 | 284 |
'?include-submission=on', |
285 | 285 |
'?include-workflow=on', |
286 |
'?include-workflow-data=on', |
|
286 | 287 |
]: |
287 | 288 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
288 | 289 |
assert 'user' not in resp.json[0] |
... | ... | |
336 | 337 |
'?include-evolution=on', |
337 | 338 |
'?include-roles=on', |
338 | 339 |
'?include-workflow=on', |
340 |
'?include-workflow-data=on', |
|
339 | 341 |
]: |
340 | 342 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
341 | 343 |
assert 'submission' not in resp.json[0] |
... | ... | |
569 | 571 |
'?include-evolution=on', |
570 | 572 |
'?include-roles=on', |
571 | 573 |
'?include-submission=on', |
574 |
'?include-workflow=on', |
|
572 | 575 |
]: |
573 | 576 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
574 |
assert 'workflow' not in resp.json[0] |
|
575 |
for params in ['?full=on', '?include-workflow=on']: |
|
577 |
if 'workflow' in params: |
|
578 |
assert 'workflow' in resp.json[0] |
|
579 |
assert 'data' not in resp.json[0]['workflow'] |
|
580 |
else: |
|
581 |
assert 'workflow' not in resp.json[0] |
|
582 |
for params in ['?full=on', '?include-workflow-data=on']: |
|
576 | 583 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
577 | 584 |
assert 'workflow' in resp.json[0] |
585 |
assert 'data' in resp.json[0]['workflow'] |
|
578 | 586 | |
579 | 587 | |
580 | 588 |
def test_formdata_with_evolution_part_attachment(pub, local_user): |
... | ... | |
629 | 637 |
'?include-roles=on', |
630 | 638 |
'?include-submission=on', |
631 | 639 |
'?include-workflow=on', |
640 |
'?include-workflow-data=on', |
|
632 | 641 |
]: |
633 | 642 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
634 | 643 |
assert 'evolution' not in resp.json[0] |
... | ... | |
703 | 712 |
'?include-roles=on', |
704 | 713 |
'?include-submission=on', |
705 | 714 |
'?include-workflow=on', |
715 |
'?include-workflow-data=on', |
|
706 | 716 |
]: |
707 | 717 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
708 | 718 |
assert 'evolution' not in resp.json[0] |
... | ... | |
785 | 795 |
'?include-evolution=on', |
786 | 796 |
'?include-submission=on', |
787 | 797 |
'?include-workflow=on', |
798 |
'?include-workflow-data=on', |
|
788 | 799 |
]: |
789 | 800 |
resp = get_app(pub).get(sign_uri('/api/forms/test/list%s' % params, user=local_user)) |
790 | 801 |
assert 'roles' not in resp.json[0] |
wcs/backoffice/management.py | ||
---|---|---|
2468 | 2468 |
include_roles = get_request().form.get('include-roles') == 'on' or full |
2469 | 2469 |
include_submission = get_request().form.get('include-submission') == 'on' or full |
2470 | 2470 |
include_workflow = get_request().form.get('include-workflow') == 'on' or full |
2471 |
if include_fields or include_evolution or include_roles or include_submission or include_workflow: |
|
2471 |
include_workflow_data = get_request().form.get('include-workflow-data') == 'on' or full |
|
2472 |
if ( |
|
2473 |
include_fields |
|
2474 |
or include_evolution |
|
2475 |
or include_roles |
|
2476 |
or include_submission |
|
2477 |
or include_workflow |
|
2478 |
or include_workflow_data |
|
2479 |
): |
|
2472 | 2480 |
output = JsonFileExportAfterJob(self.formdef).create_json_export( |
2473 | 2481 |
items, |
2474 | 2482 |
user=user, |
... | ... | |
2481 | 2489 |
include_fields=include_fields, |
2482 | 2490 |
include_unnamed_fields=False, |
2483 | 2491 |
include_workflow=include_workflow, |
2492 |
include_workflow_data=include_workflow_data, |
|
2484 | 2493 |
) |
2485 | 2494 |
else: |
2486 | 2495 |
output = [ |
... | ... | |
4329 | 4338 |
include_fields, |
4330 | 4339 |
include_unnamed_fields, |
4331 | 4340 |
include_workflow, |
4341 |
include_workflow_data, |
|
4332 | 4342 |
): |
4333 | 4343 |
# noqa pylint: disable=too-many-arguments |
4334 | 4344 |
formdef = self.kwargs['formdef_class'].get(self.kwargs['formdef_id']) |
... | ... | |
4379 | 4389 |
include_fields=include_fields, |
4380 | 4390 |
include_unnamed_fields=include_unnamed_fields, |
4381 | 4391 |
include_workflow=include_workflow, |
4392 |
include_workflow_data=include_workflow_data, |
|
4382 | 4393 |
) |
4383 | 4394 |
data.pop('digests') |
4384 | 4395 |
if digest_key: |
... | ... | |
4402 | 4413 |
include_fields=True, |
4403 | 4414 |
include_unnamed_fields=True, |
4404 | 4415 |
include_workflow=True, |
4416 |
include_workflow_data=True, |
|
4405 | 4417 |
) |
4406 | 4418 |
}, |
4407 | 4419 |
indent=2, |
wcs/formdata.py | ||
---|---|---|
1364 | 1364 |
include_fields=True, |
1365 | 1365 |
include_unnamed_fields=False, |
1366 | 1366 |
include_workflow=True, |
1367 |
include_workflow_data=True, |
|
1367 | 1368 |
): |
1368 | 1369 |
# noqa pylint: disable=too-many-arguments |
1369 | 1370 |
data = {} |
... | ... | |
1411 | 1412 |
wf_real_status = self.get_status() |
1412 | 1413 |
if wf_real_status: |
1413 | 1414 |
data['workflow']['real_status'] = {'id': wf_real_status.id, 'name': wf_real_status.name} |
1414 |
# Workflow data have unknown purpose, do not store them in anonymised export |
|
1415 |
if self.workflow_data and not anonymise: |
|
1416 |
data['workflow']['data'] = self.workflow_data |
|
1417 | 1415 |
if self.formdef.workflow.get_backoffice_fields(): |
1418 | 1416 |
data['workflow']['fields'] = self.get_json_dict( |
1419 | 1417 |
self.formdef.workflow.get_backoffice_fields(), |
... | ... | |
1421 | 1419 |
anonymise=anonymise, |
1422 | 1420 |
include_unnamed_fields=include_unnamed_fields, |
1423 | 1421 |
) |
1422 |
if include_workflow_data: |
|
1423 |
# Workflow data have unknown purpose, do not store them in anonymised export |
|
1424 |
if self.workflow_data and not anonymise: |
|
1425 |
if 'workflow' not in data: |
|
1426 |
data['workflow'] = {} |
|
1427 |
data['workflow']['data'] = self.workflow_data |
|
1424 | 1428 | |
1425 | 1429 |
if include_roles: |
1426 | 1430 |
# add a roles dictionary, with workflow functions and two special |
1427 |
- |