]> git.openstreetmap.org Git - osqa.git/blob - settings.py
Fixes a possible date display bug.
[osqa.git] / settings.py
1 # encoding:utf-8
2 import os.path
3 import sys
4
5 SITE_ID = 1
6
7 ADMIN_MEDIA_PREFIX = '/admin_media/'
8 SECRET_KEY = '$oo^&_m&qwbib=(_4m_n*zn-d=g#s0he5fx9xonnym#8p6yigm'
9
10 TEMPLATE_LOADERS = [
11     'django.template.loaders.filesystem.load_template_source',
12     'django.template.loaders.app_directories.load_template_source',
13     'forum.modules.template_loader.module_templates_loader',
14     'forum.skins.load_template_source',
15 ]
16
17 MIDDLEWARE_CLASSES = [
18     'django.middleware.csrf.CsrfViewMiddleware',
19     'django.middleware.csrf.CsrfResponseMiddleware',
20     'forum.middleware.django_cookies.CookiePreHandlerMiddleware',
21     'django.contrib.sessions.middleware.SessionMiddleware',
22     'django.middleware.common.CommonMiddleware',
23     'forum.middleware.extended_user.ExtendedUser',
24     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
25     'forum.middleware.request_utils.RequestUtils',
26     'forum.middleware.cancel.CancelActionMiddleware',
27     'forum.middleware.admin_messages.AdminMessagesMiddleware',
28     'django.middleware.transaction.TransactionMiddleware',
29     'forum.middleware.django_cookies.CookiePostHandlerMiddleware',
30 ]
31
32 TEMPLATE_CONTEXT_PROCESSORS = [
33     'django.core.context_processors.request',
34     'forum.context.application_settings',
35     'forum.user_messages.context_processors.user_messages',
36     'django.core.context_processors.auth',
37 ]
38
39 ROOT_URLCONF = 'urls'
40 APPEND_SLASH = True
41
42 TEMPLATE_DIRS = (
43     os.path.join(os.path.dirname(__file__),'forum','skins').replace('\\','/'),
44 )
45
46
47 FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/')
48 FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler",
49  "django.core.files.uploadhandler.TemporaryFileUploadHandler",)
50 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
51
52 ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
53 ALLOW_MAX_FILE_SIZE = 1024 * 1024
54
55 # User settings
56 from settings_local import *
57
58 try:
59     if len(FORUM_SCRIPT_ALIAS) > 0:
60         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
61 except NameError:
62     pass
63
64 app_url_split = APP_URL.split("://")
65
66 APP_PROTOCOL = app_url_split[0]
67 APP_DOMAIN = app_url_split[1].split('/')[0]
68 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
69
70 FORCE_SCRIPT_NAME = ''
71
72 for path in app_url_split[1].split('/')[1:]:
73     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
74
75 if FORCE_SCRIPT_NAME.endswith('/'):
76     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
77
78 #Module system initialization
79 MODULES_PACKAGE = 'forum_modules'
80 MODULES_FOLDER = os.path.join(SITE_SRC_ROOT, MODULES_PACKAGE)
81
82 MODULE_LIST = filter(lambda m: getattr(m, 'CAN_USE', True), [
83         __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules'])
84         for f in os.listdir(MODULES_FOLDER)
85         if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and
86            os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and
87            not f in DISABLED_MODULES
88 ])
89
90 [MIDDLEWARE_CLASSES.extend(
91         ["%s.%s" % (m.__name__, mc) for mc in getattr(m, 'MIDDLEWARE_CLASSES', [])]
92                           ) for m in MODULE_LIST]
93
94 [TEMPLATE_LOADERS.extend(
95         ["%s.%s" % (m.__name__, tl) for tl in getattr(m, 'TEMPLATE_LOADERS', [])]
96                           ) for m in MODULE_LIST]
97
98
99 INSTALLED_APPS = [
100     'django.contrib.auth',
101     'django.contrib.contenttypes',
102     'django.contrib.sessions',
103     'django.contrib.sites',
104     'django.contrib.admin',
105     'django.contrib.humanize',
106     'django.contrib.sitemaps',
107     'django.contrib.markup',
108     'forum',
109 ]
110
111 if DEBUG:
112     try:
113         import debug_toolbar
114         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
115         INSTALLED_APPS.append('debug_toolbar')
116     except:
117         pass
118
119 try:
120     import south
121     INSTALLED_APPS.append('south')
122 except:
123     pass
124
125 if not DEBUG:
126     try:
127         import rosetta
128         INSTALLED_APPS.append('rosetta')
129     except:
130         pass
131
132 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]