app_settings: use new app_settings pattern
This commit is contained in:
parent
55fda53940
commit
8f7485031a
|
@ -1,5 +1,20 @@
|
|||
from django.conf import settings
|
||||
import sys
|
||||
|
||||
TEMPLATE_VARS = getattr(settings, 'PORTAIL_CITOYEN_TEMPLATE_VARS', {})
|
||||
FAVICON_URL = getattr(settings, 'PORTAIL_CITOYEN_FAVICON_URL', 'http://www.entrouvert.com/favicon.ico')
|
||||
WCSINST_DEFAULT_VARIABLES = getattr(settings, 'PORTAIL_CITOYEN_WCSINST_DEFAULT_VARIABLES', {})
|
||||
class AppSettings(object):
|
||||
__defaults = {
|
||||
'TEMPLATE_VARS': {},
|
||||
'FAVICON_URL': 'http://www.entrouvert.com/favicon.ico',
|
||||
'WCSINST_DEFAULT_VARIABLES': {},
|
||||
}
|
||||
|
||||
__prefix = 'PORTAIL_CITOYEN_'
|
||||
|
||||
def __getattr__(self, name):
|
||||
from django.conf import settings
|
||||
if name not in self.__defaults:
|
||||
raise AttributeError
|
||||
return getattr(settings, self.__prefix + name, self.__defaults[name])
|
||||
|
||||
app_settings = AppSettings()
|
||||
app_settings.__name__ = __name__
|
||||
sys.modules[__name__] = app_settings
|
||||
|
|
Reference in New Issue