]> git.openstreetmap.org Git - osqa.git/blob - settings.py
fix breach in award points that allows user to award infinite points / extra fix
[osqa.git] / settings.py
1 # encoding:utf-8
2 import os.path
3 import sys
4
5 SITE_ID = 1
6
7 SECRET_KEY = 'a;::qCl1mfh?avagttOJ;8f5Rr54d,9qy7;o15M2cYO75?OQo51u3LnQ;!8N.:,7'
8
9 CACHE_MAX_KEY_LENGTH = 235
10
11 MIDDLEWARE_CLASSES = [
12     'django.middleware.csrf.CsrfViewMiddleware',
13     'forum.middleware.django_cookies.CookiePreHandlerMiddleware',
14     'django.contrib.sessions.middleware.SessionMiddleware',
15     'django.contrib.messages.middleware.MessageMiddleware',
16     'django.middleware.common.CommonMiddleware',
17     'forum.middleware.extended_user.ExtendedUser',
18     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
19     'forum.middleware.request_utils.RequestUtils',
20     'forum.middleware.cancel.CancelActionMiddleware',
21     'forum.middleware.admin_messages.AdminMessagesMiddleware',
22     'forum.middleware.custom_pages.CustomPagesFallbackMiddleware',
23     'django.middleware.transaction.TransactionMiddleware',
24     'forum.middleware.django_cookies.CookiePostHandlerMiddleware',
25 ]
26
27 TEMPLATE_CONTEXT_PROCESSORS = [
28     'django.core.context_processors.request',
29     'forum.context.application_settings',
30     'django.contrib.messages.context_processors.messages',
31     'forum.user_messages.context_processors.user_messages',
32     'django.contrib.auth.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 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
52
53 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
54
55 # User settings
56 from settings_local import *
57
58 template_loaders = (
59     'django.template.loaders.filesystem.Loader',
60     'django.template.loaders.app_directories.Loader',
61     'forum.modules.template_loader.module_templates_loader',
62     'forum.skins.load_template_source',
63 )
64 TEMPLATE_LOADERS = list(template_loaders) if DEBUG else [ ('django.template.loaders.cached.Loader', template_loaders) ]
65
66 try:
67     if len(FORUM_SCRIPT_ALIAS) > 0:
68         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
69 except NameError:
70     pass
71
72 app_url_split = APP_URL.split("://")
73
74 APP_PROTOCOL = app_url_split[0]
75 APP_DOMAIN = app_url_split[1].split('/')[0]
76 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
77
78 FORCE_SCRIPT_NAME = ''
79
80 for path in app_url_split[1].split('/')[1:]:
81     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
82
83 if FORCE_SCRIPT_NAME.endswith('/'):
84     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
85
86 #Module system initialization
87 MODULES_PACKAGE = 'forum_modules'
88 MODULES_FOLDER = os.path.join(SITE_SRC_ROOT, MODULES_PACKAGE)
89
90 MODULE_LIST = filter(lambda m: getattr(m, 'CAN_USE', True), [
91         __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules'])
92         for f in os.listdir(MODULES_FOLDER)
93         if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and
94            os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and
95            not f in DISABLED_MODULES
96 ])
97
98 [MIDDLEWARE_CLASSES.extend(
99         ["%s.%s" % (m.__name__, mc) for mc in getattr(m, 'MIDDLEWARE_CLASSES', [])]
100                           ) for m in MODULE_LIST]
101
102 [TEMPLATE_LOADERS.extend(
103         ["%s.%s" % (m.__name__, tl) for tl in getattr(m, 'TEMPLATE_LOADERS', [])]
104                           ) for m in MODULE_LIST]
105
106
107 INSTALLED_APPS = [
108     'django.contrib.auth',
109     'django.contrib.contenttypes',
110     'django.contrib.sessions',
111     'django.contrib.sites',
112     'django.contrib.admin',
113     'django.contrib.humanize',
114     'django.contrib.sitemaps',
115     'django.contrib.messages',
116     'forum',
117 ]
118
119 if DEBUG:
120     try:
121         import debug_toolbar
122         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
123         INSTALLED_APPS.append('debug_toolbar')
124     except:
125         pass
126
127 try:
128     import south
129     INSTALLED_APPS.append('south')
130 except:
131     pass
132
133 # Try loading Gunicorn web server
134 try:
135     import gunicorn
136     INSTALLED_APPS.append('gunicorn')
137 except ImportError:
138     pass
139
140 if not DEBUG:
141     try:
142         import rosetta
143         INSTALLED_APPS.append('rosetta')
144     except:
145         pass
146
147 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]