]> git.openstreetmap.org Git - osqa.git/blob - settings.py
Added a small error message in wmd.js
[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 CACHE_MAX_KEY_LENGTH = 235
11
12 MIDDLEWARE_CLASSES = [
13     'django.middleware.csrf.CsrfViewMiddleware',
14     'django.middleware.csrf.CsrfResponseMiddleware',
15     'forum.middleware.django_cookies.CookiePreHandlerMiddleware',
16     'django.contrib.sessions.middleware.SessionMiddleware',
17     'django.middleware.common.CommonMiddleware',
18     'forum.middleware.extended_user.ExtendedUser',
19     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
20     'forum.middleware.request_utils.RequestUtils',
21     'forum.middleware.cancel.CancelActionMiddleware',
22     'forum.middleware.admin_messages.AdminMessagesMiddleware',
23     'forum.middleware.custom_pages.CustomPagesFallbackMiddleware',
24     'django.middleware.transaction.TransactionMiddleware',
25     'forum.middleware.django_cookies.CookiePostHandlerMiddleware',
26 ]
27
28 TEMPLATE_CONTEXT_PROCESSORS = [
29     'django.core.context_processors.request',
30     'forum.context.application_settings',
31     'forum.user_messages.context_processors.user_messages',
32     'django.core.context_processors.auth',
33 ]
34
35 ROOT_URLCONF = 'urls'
36 APPEND_SLASH = True
37
38 TEMPLATE_DIRS = (
39     os.path.join(os.path.dirname(__file__),'forum','skins').replace('\\','/'),
40 )
41
42
43 FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/')
44 FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler",
45  "django.core.files.uploadhandler.TemporaryFileUploadHandler",)
46 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
47
48 ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
49 ALLOW_MAX_FILE_SIZE = 1024 * 1024
50
51 # User settings
52 from settings_local import *
53
54 if DEBUG:
55     TEMPLATE_LOADERS = [
56         'django.template.loaders.filesystem.load_template_source',
57         'django.template.loaders.app_directories.load_template_source',
58         'forum.modules.template_loader.module_templates_loader',
59         'forum.skins.load_template_source',
60     ]
61 else:
62     TEMPLATE_LOADERS = [
63         ('django.template.loaders.cached.Loader',(
64             'django.template.loaders.filesystem.load_template_source',
65             'django.template.loaders.app_directories.load_template_source',
66             'forum.modules.template_loader.module_templates_loader',
67             'forum.skins.load_template_source',
68             )),
69     ]
70
71 try:
72     if len(FORUM_SCRIPT_ALIAS) > 0:
73         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
74 except NameError:
75     pass
76
77 app_url_split = APP_URL.split("://")
78
79 APP_PROTOCOL = app_url_split[0]
80 APP_DOMAIN = app_url_split[1].split('/')[0]
81 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
82
83 FORCE_SCRIPT_NAME = ''
84
85 for path in app_url_split[1].split('/')[1:]:
86     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
87
88 if FORCE_SCRIPT_NAME.endswith('/'):
89     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
90
91 #Module system initialization
92 MODULES_PACKAGE = 'forum_modules'
93 MODULES_FOLDER = os.path.join(SITE_SRC_ROOT, MODULES_PACKAGE)
94
95 MODULE_LIST = filter(lambda m: getattr(m, 'CAN_USE', True), [
96         __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules'])
97         for f in os.listdir(MODULES_FOLDER)
98         if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and
99            os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and
100            not f in DISABLED_MODULES
101 ])
102
103 [MIDDLEWARE_CLASSES.extend(
104         ["%s.%s" % (m.__name__, mc) for mc in getattr(m, 'MIDDLEWARE_CLASSES', [])]
105                           ) for m in MODULE_LIST]
106
107 [TEMPLATE_LOADERS.extend(
108         ["%s.%s" % (m.__name__, tl) for tl in getattr(m, 'TEMPLATE_LOADERS', [])]
109                           ) for m in MODULE_LIST]
110
111
112 INSTALLED_APPS = [
113     'django.contrib.auth',
114     'django.contrib.contenttypes',
115     'django.contrib.sessions',
116     'django.contrib.sites',
117     'django.contrib.admin',
118     'django.contrib.humanize',
119     'django.contrib.sitemaps',
120     'django.contrib.markup',
121     'forum',
122 ]
123
124 if DEBUG:
125     try:
126         import debug_toolbar
127         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
128         INSTALLED_APPS.append('debug_toolbar')
129     except:
130         pass
131
132 try:
133     import south
134     INSTALLED_APPS.append('south')
135 except:
136     pass
137
138 # Try loading Gunicorn web server
139 try:
140     import gunicorn
141     INSTALLED_APPS.append('gunicorn')
142 except ImportError:
143     pass
144
145 if not DEBUG:
146     try:
147         import rosetta
148         INSTALLED_APPS.append('rosetta')
149     except:
150         pass
151
152 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]