multitenant: use environment to get application name (#29323)
This commit is contained in:
parent
48b16b1a9d
commit
20da13f842
|
@ -209,7 +209,7 @@ class ThemeSettings(SettingsDictUpdateMixin):
|
|||
theme = get_theme(theme_id)
|
||||
if not theme:
|
||||
return
|
||||
module_name = settings.SETTINGS_MODULE.split('.')[0]
|
||||
module_name = os.environ.get('DJANGO_SETTINGS_MODULE', '').split('.')[0]
|
||||
module_settings = theme.get('settings', {}).get(module_name)
|
||||
if not module_settings:
|
||||
return
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import threading
|
||||
import random
|
||||
import pytest
|
||||
|
@ -106,12 +107,14 @@ def test_tenant_theme_settings(tenants, settings, client):
|
|||
with utilities.patch_default_settings(settings,
|
||||
TENANT_SETTINGS_LOADERS=('hobo.multitenant.settings_loaders.TemplateVars',
|
||||
'hobo.multitenant.settings_loaders.ThemeSettings')):
|
||||
with override_settings(SETTINGS_MODULE='fake.settings'):
|
||||
with tenant_context(tenants[0]):
|
||||
# check it's defined when moving into the schema
|
||||
assert django.conf.settings.TEMPLATE_VARS
|
||||
assert django.conf.settings.TEMPLATE_VARS['theme'] == 'publik'
|
||||
assert django.conf.settings.HELLO == 'world'
|
||||
old_value = os.environ['DJANGO_SETTINGS_MODULE']
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'fake.settings'
|
||||
with tenant_context(tenants[0]):
|
||||
# check it's defined when moving into the schema
|
||||
assert django.conf.settings.TEMPLATE_VARS
|
||||
assert django.conf.settings.TEMPLATE_VARS['theme'] == 'publik'
|
||||
assert django.conf.settings.HELLO == 'world'
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = old_value
|
||||
|
||||
def test_multithreading(tenants, settings, client):
|
||||
|
||||
|
|
Loading…
Reference in New Issue