summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2015-10-30 15:36:46 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-11-02 15:05:33 (GMT)
commit4996f592ec8a5a89482c371815f324f65f4ae31c (patch)
tree62a7b9961d4323f70752bd4c523a23ac7add52c5
parent26a13a36562cb3c9ae8f51344ecaff1195f56058 (diff)
downloadhobo-4996f592ec8a5a89482c371815f324f65f4ae31c.zip
hobo-4996f592ec8a5a89482c371815f324f65f4ae31c.tar.gz
hobo-4996f592ec8a5a89482c371815f324f65f4ae31c.tar.bz2
settings: replace - by _ in $slug_url TEMPLATE_VARS (#8827)
-rw-r--r--hobo/multitenant/settings_loaders.py2
-rw-r--r--tests_multitenant/conftest.py4
-rw-r--r--tests_multitenant/test_settings.py1
3 files changed, 6 insertions, 1 deletions
diff --git a/hobo/multitenant/settings_loaders.py b/hobo/multitenant/settings_loaders.py
index b067a5a..4cf6f4b 100644
--- a/hobo/multitenant/settings_loaders.py
+++ b/hobo/multitenant/settings_loaders.py
@@ -75,7 +75,7 @@ class TemplateVars(FileBaseSettingsLoader):
for service in hobo_json.get('services'):
if not service.get('slug'):
continue
- variables['%s_url' % service.get('slug')] = service.get('base_url')
+ variables['%s_url' % service.get('slug').replace('-','_')] = service.get('base_url')
if not service.get('this'): continue
variables.update(service.get('variables') or {})
variables['site_title'] = service.get('title')
diff --git a/tests_multitenant/conftest.py b/tests_multitenant/conftest.py
index 77dff80..49adcbb 100644
--- a/tests_multitenant/conftest.py
+++ b/tests_multitenant/conftest.py
@@ -35,6 +35,10 @@ def tenants(db, request, settings):
'other_variable': 'bar',
}
},
+ {'slug': 'slug-with-hyphen',
+ 'title': 'Hyphen',
+ 'base_url': 'http://slug-with-hyphen.example.net'
+ },
{'slug': 'other',
'title': 'Other',
'base_url': 'http://other.example.net'},
diff --git a/tests_multitenant/test_settings.py b/tests_multitenant/test_settings.py
index 762ac01..a59e5b8 100644
--- a/tests_multitenant/test_settings.py
+++ b/tests_multitenant/test_settings.py
@@ -56,6 +56,7 @@ def test_tenant_template_vars(tenants, settings, client):
assert django.conf.settings.TEMPLATE_VARS['hobo_test_variable'] is True
assert django.conf.settings.TEMPLATE_VARS['test_url'] == tenant.get_base_url()
assert django.conf.settings.TEMPLATE_VARS['other_url'] == 'http://other.example.net'
+ assert django.conf.settings.TEMPLATE_VARS['slug_with_hyphen_url'] == 'http://slug-with-hyphen.example.net'
assert django.conf.settings.TEMPLATE_VARS['site_title'] == 'Test'
assert django.conf.settings.TEMPLATE_VARS['other_variable'] == 'bar'