0002-api-include-load-url-in-tracking-code-lookup-API-res.patch
help/fr/api-get.page | ||
---|---|---|
477 | 477 |
<screen> |
478 | 478 |
<output style="prompt">$ </output><input>curl -H "Accept: application/json" \ |
479 | 479 |
https://www.example.net/api/code/QRFPTSLR</input> |
480 |
<output>{"url": "http://www.example.net/demarche/23", "err": 0}</output> |
|
480 |
<output>{"url": "http://www.example.net/demarche/23", |
|
481 |
"load_url": "http://www.example.net/code/QRFPTSLR/load", |
|
482 |
"err": 0}</output> |
|
481 | 483 |
</screen> |
482 | 484 | |
483 | 485 |
<p> |
tests/test_api.py | ||
---|---|---|
1988 | 1988 |
resp = get_app(pub).get(sign_url('/api/code/%s?orig=coucou' % code.id, '1234'), status=200) |
1989 | 1989 |
assert resp.json['err'] == 0 |
1990 | 1990 |
assert resp.json['url'] == 'http://example.net/test/%s' % formdata.id |
1991 |
assert resp.json['load_url'] == 'http://example.net/code/%s/load' % code.id |
|
1991 | 1992 | |
1992 | 1993 |
formdef.enable_tracking_codes = False |
1993 | 1994 |
formdef.store() |
wcs/api.py | ||
---|---|---|
657 | 657 |
raise TraversalError() |
658 | 658 |
if formdata.formdef.enable_tracking_codes is False: |
659 | 659 |
raise TraversalError() |
660 |
data = {'err': 0, 'url': formdata.get_url().rstrip('/')} |
|
660 |
data = { |
|
661 |
'err': 0, |
|
662 |
'url': formdata.get_url().rstrip('/'), |
|
663 |
'load_url': get_publisher().get_frontoffice_url() + '/code/%s/load' % component, |
|
664 |
} |
|
661 | 665 |
return json.dumps(data) |
662 | 666 | |
663 | 667 | |
664 |
- |