From ac27983a1d023dccda168bbcdf9ad2ef0db3183d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 14 Feb 2018 23:48:26 +0100 Subject: [PATCH 2/2] api: include load url in tracking code lookup API response (#21859) --- help/fr/api-get.page | 4 +++- tests/test_api.py | 1 + wcs/api.py | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/help/fr/api-get.page b/help/fr/api-get.page index d251e654..682b97f8 100644 --- a/help/fr/api-get.page +++ b/help/fr/api-get.page @@ -477,7 +477,9 @@ Une API existe pour déterminer l'existence d'un code de suivi et, le cas $ curl -H "Accept: application/json" \ https://www.example.net/api/code/QRFPTSLR -{"url": "http://www.example.net/demarche/23", "err": 0} +{"url": "http://www.example.net/demarche/23", + "load_url": "http://www.example.net/code/QRFPTSLR/load", + "err": 0}

diff --git a/tests/test_api.py b/tests/test_api.py index ab7d1bbe..8ea520fc 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1988,6 +1988,7 @@ def test_tracking_code(pub): resp = get_app(pub).get(sign_url('/api/code/%s?orig=coucou' % code.id, '1234'), status=200) assert resp.json['err'] == 0 assert resp.json['url'] == 'http://example.net/test/%s' % formdata.id + assert resp.json['load_url'] == 'http://example.net/code/%s/load' % code.id formdef.enable_tracking_codes = False formdef.store() diff --git a/wcs/api.py b/wcs/api.py index e3d6a4b1..8dbf2d36 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -657,7 +657,11 @@ class ApiTrackingCodeDirectory(Directory): raise TraversalError() if formdata.formdef.enable_tracking_codes is False: raise TraversalError() - data = {'err': 0, 'url': formdata.get_url().rstrip('/')} + data = { + 'err': 0, + 'url': formdata.get_url().rstrip('/'), + 'load_url': get_publisher().get_frontoffice_url() + '/code/%s/load' % component, + } return json.dumps(data) -- 2.16.1