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