Project

General

Profile

0002-In-FileSystemLoader-rename-settings-from-MULTITENANT.patch

Benjamin Dauvergne, 20 August 2014 03:23 PM

Download (2.69 KB)

View differences:

Subject: [PATCH 02/10] In FileSystemLoader rename settings from
 MULTITENANT_TEMPLATE_DIRS to TENANT_TEMPLATE_DIRS to
 unformize with other settings

 entrouvert/djommon/multitenant/app_settings.py    |   19 -------------------
 entrouvert/djommon/multitenant/template_loader.py |    6 +++---
 2 files changed, 3 insertions(+), 22 deletions(-)
 delete mode 100644 entrouvert/djommon/multitenant/app_settings.py
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
86 86
            return
87 87
        if not template_dirs:
88 88
            try:
89
                template_dirs = app_settings.MULTITENANT_TEMPLATE_DIRS
89
                template_dirs = settings.TENANT_TEMPLATE_DIRS
90 90
            except AttributeError:
91
                raise ImproperlyConfigured('To use %s.%s you must define the MULTITENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__))
91
                raise ImproperlyConfigured('To use %s.%s you must define the TENANT_TEMPLATE_DIRS' % (__name__, FilesystemLoader.__name__))
92 92
        for template_dir in template_dirs:
93 93
            try:
94 94
                yield safe_join(template_dir, connection.tenant.domain_url, template_name)
......
112 112
        if tried:
113 113
            error_msg = "Tried %s" % tried
114 114
        else:
115
            error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
115
            error_msg = "Your TENANT_TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory."
116 116
        raise TemplateDoesNotExist(error_msg)
117 117
    load_template_source.is_usable = True
118
-