Revision 73b85f5d
Added by Benjamin Dauvergne about 10 years ago
entrouvert/djommon/multitenant/app_settings.py | ||
---|---|---|
1 |
import sys |
|
2 |
|
|
3 |
|
|
4 |
class AppSettings: |
|
5 |
@property |
|
6 |
def settings(self): |
|
7 |
if not hasattr(self, '_settings'): |
|
8 |
from django.conf import settings |
|
9 |
self._settings = settings |
|
10 |
return self._settings |
|
11 |
|
|
12 |
@property |
|
13 |
def MULTITENANT_TEMPLATE_DIRS(self): |
|
14 |
return self.settings.MULTITENANT_TEMPLATE_DIRS |
|
15 |
|
|
16 |
|
|
17 |
app_settings = AppSettings() |
|
18 |
app_settings.__name__ = __name__ |
|
19 |
sys.modules[__name__] = app_settings |
entrouvert/djommon/multitenant/template_loader.py | ||
---|---|---|
12 | 12 |
from django.utils._os import safe_join |
13 | 13 |
from django.db import connection |
14 | 14 |
|
15 |
from . import app_settings |
|
16 |
|
|
17 | 15 |
class CachedLoader(BaseLoader): |
18 | 16 |
is_usable = True |
19 | 17 |
|
... | ... | |
86 | 84 |
return |
87 | 85 |
if not template_dirs: |
88 | 86 |
try: |
89 |
template_dirs = app_settings.MULTITENANT_TEMPLATE_DIRS
|
|
87 |
template_dirs = settings.TENANT_TEMPLATE_DIRS
|
|
90 | 88 |
except AttributeError: |
91 |
raise ImproperlyConfigured('To use %s.%s you must define the MULTITENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__))
|
|
89 |
raise ImproperlyConfigured('To use %s.%s you must define the TENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__)) |
|
92 | 90 |
for template_dir in template_dirs: |
93 | 91 |
try: |
94 | 92 |
yield safe_join(template_dir, connection.tenant.domain_url, template_name) |
... | ... | |
112 | 110 |
if tried: |
113 | 111 |
error_msg = "Tried %s" % tried |
114 | 112 |
else: |
115 |
error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory." |
|
113 |
error_msg = "Your TENANT_TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
|
|
116 | 114 |
raise TemplateDoesNotExist(error_msg) |
117 | 115 |
load_template_source.is_usable = True |
Also available in: Unified diff
In FileSystemLoader rename settings from MULTITENANT_TEMPLATE_DIRS to TENANT_TEMPLATE_DIRS to unformize with other settings
refs #5106