In FileSystemLoader rename settings from MULTITENANT_TEMPLATE_DIRS to TENANT_TEMPLATE_DIRS to unformize with other settings
refs #5106
This commit is contained in:
parent
ea04b35c75
commit
1c7323072d
|
@ -1,19 +0,0 @@
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
class AppSettings:
|
|
||||||
@property
|
|
||||||
def settings(self):
|
|
||||||
if not hasattr(self, '_settings'):
|
|
||||||
from django.conf import settings
|
|
||||||
self._settings = settings
|
|
||||||
return self._settings
|
|
||||||
|
|
||||||
@property
|
|
||||||
def MULTITENANT_TEMPLATE_DIRS(self):
|
|
||||||
return self.settings.MULTITENANT_TEMPLATE_DIRS
|
|
||||||
|
|
||||||
|
|
||||||
app_settings = AppSettings()
|
|
||||||
app_settings.__name__ = __name__
|
|
||||||
sys.modules[__name__] = app_settings
|
|
|
@ -12,8 +12,6 @@ from django.utils.encoding import force_bytes
|
||||||
from django.utils._os import safe_join
|
from django.utils._os import safe_join
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
||||||
from . import app_settings
|
|
||||||
|
|
||||||
class CachedLoader(BaseLoader):
|
class CachedLoader(BaseLoader):
|
||||||
is_usable = True
|
is_usable = True
|
||||||
|
|
||||||
|
@ -86,9 +84,9 @@ class FilesystemLoader(BaseLoader):
|
||||||
return
|
return
|
||||||
if not template_dirs:
|
if not template_dirs:
|
||||||
try:
|
try:
|
||||||
template_dirs = app_settings.MULTITENANT_TEMPLATE_DIRS
|
template_dirs = settings.TENANT_TEMPLATE_DIRS
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ImproperlyConfigured('To use %s.%s you must define the MULTITENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__))
|
raise ImproperlyConfigured('To use %s.%s you must define the TENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__))
|
||||||
for template_dir in template_dirs:
|
for template_dir in template_dirs:
|
||||||
try:
|
try:
|
||||||
yield safe_join(template_dir, connection.tenant.domain_url, template_name)
|
yield safe_join(template_dir, connection.tenant.domain_url, template_name)
|
||||||
|
@ -112,6 +110,6 @@ class FilesystemLoader(BaseLoader):
|
||||||
if tried:
|
if tried:
|
||||||
error_msg = "Tried %s" % tried
|
error_msg = "Tried %s" % tried
|
||||||
else:
|
else:
|
||||||
error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
|
error_msg = "Your TENANT_TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
|
||||||
raise TemplateDoesNotExist(error_msg)
|
raise TemplateDoesNotExist(error_msg)
|
||||||
load_template_source.is_usable = True
|
load_template_source.is_usable = True
|
||||||
|
|
Loading…
Reference in New Issue