0001-wcs-handle-API-transitioning-from-list-to-data-dict-.patch
combo/apps/wcs/models.py | ||
---|---|---|
53 | 53 |
wcs_key, form_slug = self.formdef_reference.split(':') |
54 | 54 |
wcs_site = get_wcs_services().get(wcs_key) |
55 | 55 |
forms_response_json = get_wcs_json(wcs_site, 'api/formdefs/') |
56 |
if isinstance(forms_response_json, dict): |
|
57 |
# forward compability with future w.c.s. API |
|
58 |
forms_response_json = forms_response_json.get('data') |
|
56 | 59 |
for form in forms_response_json: |
57 | 60 |
slug = form.get('slug') |
58 | 61 |
if slug == form_slug: |
... | ... | |
161 | 164 |
log_errors=False) |
162 | 165 |
returns.add(response.status_code) |
163 | 166 |
if response.status_code == 200: |
164 |
wcs_site['data'] = response.json() |
|
167 |
json_response = response.json() |
|
168 |
if isinstance(json_response, list): |
|
169 |
# backward compat with older w.c.s. |
|
170 |
wcs_site['data'] = json_response |
|
171 |
elif json_response.get('err', 0) == 0: |
|
172 |
wcs_site['data'] = json_response['data'] |
|
165 | 173 | |
166 | 174 |
if not 200 in returns: # not a single valid answer |
167 | 175 |
logging.error('failed to get data from any %s (%r)', self.api_url, returns) |
168 |
- |