summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-05-21 09:22:57 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-05-21 11:18:52 (GMT)
commit00c668a56e126d65b12d5d3008de0c2fcf87309b (patch)
tree912bee44b75799dbdbaa609cd41a50e8fe61d65b
parent3b64bc6617b44d5b2ff465ec7068b0bee72446fb (diff)
downloadcombo-00c668a56e126d65b12d5d3008de0c2fcf87309b.zip
combo-00c668a56e126d65b12d5d3008de0c2fcf87309b.tar.gz
combo-00c668a56e126d65b12d5d3008de0c2fcf87309b.tar.bz2
wcs: make sure the wcs URL has a trailing slash (#7326)
-rw-r--r--combo/apps/wcs/models.py4
-rw-r--r--combo/apps/wcs/utils.py7
2 files changed, 7 insertions, 4 deletions
diff --git a/combo/apps/wcs/models.py b/combo/apps/wcs/models.py
index 20f3858..7e3e062 100644
--- a/combo/apps/wcs/models.py
+++ b/combo/apps/wcs/models.py
@@ -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:
diff --git a/combo/apps/wcs/utils.py b/combo/apps/wcs/utils.py
index ee885a4..d9b18fb 100644
--- a/combo/apps/wcs/utils.py
+++ b/combo/apps/wcs/utils.py
@@ -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: