wcs: make sure the wcs URL has a trailing slash (#7326)
This commit is contained in:
parent
3b64bc6617
commit
00c668a56e
|
@ -50,7 +50,7 @@ class WcsFormCell(CellBase):
|
|||
if self.formdef_reference:
|
||||
wcs_key, form_slug = self.formdef_reference.split(':')
|
||||
wcs_site = get_wcs_services().get(wcs_key)
|
||||
forms_response_json = get_wcs_json(wcs_site.get('url') + 'json')
|
||||
forms_response_json = get_wcs_json(wcs_site.get('url'), 'json')
|
||||
for form in forms_response_json:
|
||||
slug = form.get('slug')
|
||||
if slug == form_slug:
|
||||
|
@ -86,7 +86,7 @@ class WcsCommonCategoryCell(CellBase):
|
|||
if self.category_reference:
|
||||
wcs_key, category_slug = self.category_reference.split(':')
|
||||
wcs_site = get_wcs_services().get(wcs_key)
|
||||
categories_response_json = get_wcs_json(wcs_site.get('url') + 'categories')
|
||||
categories_response_json = get_wcs_json(wcs_site.get('url'), 'categories')
|
||||
for category in categories_response_json.get('data'):
|
||||
slug = category.get('slug')
|
||||
if slug == category_slug:
|
||||
|
|
|
@ -27,7 +27,10 @@ def get_wcs_services():
|
|||
return {}
|
||||
return settings.KNOWN_SERVICES.get('wcs')
|
||||
|
||||
def get_wcs_json(url):
|
||||
def get_wcs_json(wcs_url, path):
|
||||
if not wcs_url.endswith('/'):
|
||||
wcs_url += '/'
|
||||
url = wcs_url + path
|
||||
response_json = cache.get(url)
|
||||
if response_json is None:
|
||||
response_json = requests.get(url, headers={'accept': 'application/json'}).json()
|
||||
|
@ -38,7 +41,7 @@ def get_wcs_options(url):
|
|||
references = []
|
||||
for wcs_key, wcs_site in get_wcs_services().iteritems():
|
||||
site_title = wcs_site.get('title')
|
||||
response_json = get_wcs_json(wcs_site.get('url') + url)
|
||||
response_json = get_wcs_json(wcs_site.get('url'), url)
|
||||
if type(response_json) is dict:
|
||||
response_json = response_json.get('data')
|
||||
for element in response_json:
|
||||
|
|
Loading…
Reference in New Issue