wcs: handle API transitioning from list to 'data' dict (#13521)
This commit is contained in:
parent
b83db4889c
commit
e7cfb8dbdc
|
@ -53,6 +53,9 @@ class WcsFormCell(CellBase):
|
|||
wcs_key, form_slug = self.formdef_reference.split(':')
|
||||
wcs_site = get_wcs_services().get(wcs_key)
|
||||
forms_response_json = get_wcs_json(wcs_site, 'api/formdefs/')
|
||||
if isinstance(forms_response_json, dict):
|
||||
# forward compability with future w.c.s. API
|
||||
forms_response_json = forms_response_json.get('data')
|
||||
for form in forms_response_json:
|
||||
slug = form.get('slug')
|
||||
if slug == form_slug:
|
||||
|
@ -161,7 +164,12 @@ class WcsBlurpMixin(object):
|
|||
log_errors=False)
|
||||
returns.add(response.status_code)
|
||||
if response.status_code == 200:
|
||||
wcs_site['data'] = response.json()
|
||||
json_response = response.json()
|
||||
if isinstance(json_response, list):
|
||||
# backward compat with older w.c.s.
|
||||
wcs_site['data'] = json_response
|
||||
elif json_response.get('err', 0) == 0:
|
||||
wcs_site['data'] = json_response['data']
|
||||
|
||||
if not 200 in returns: # not a single valid answer
|
||||
logging.error('failed to get data from any %s (%r)', self.api_url, returns)
|
||||
|
|
Loading…
Reference in New Issue