forked from MTG/freesound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
298 lines (241 loc) · 9.77 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# -*- coding: utf-8 -*-
# Test comment
# Django settings for freesound project.
import os
import datetime
import logging.config
DEBUG = False
TEMPLATE_CONTEXT_PROCESSORS = (
# 'django.core.context_processors.auth',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.contrib.messages.context_processors.messages',
'context_processor.context_extra',
)
MIDDLEWARE_CLASSES = (
'middleware.PermissionDeniedHandler',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'middleware.TosAcceptanceHandler',
'middleware.BulkChangeLicenseHandler',
'middleware.CheckIfRequestIsHttps',
#'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'middleware.OnlineUsersHandler',
'utils.corsheaders.middleware.CorsMiddleware',
)
INSTALLED_APPS = (
'messages',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.flatpages',
'django.contrib.markup',
'django.contrib.messages',
'south',
'geotags',
'accounts',
'comments',
'ratings',
'tags',
'general',
'support',
'wiki',
'favorites',
'sounds',
'bookmarks',
'forum',
'search',
'api',
'django_extensions',
'tickets',
'gunicorn',
'rest_framework',
'provider.oauth2',
'apiv2',
'provider',
'utils.corsheaders',
#'test_utils', # Don't use this in production!
)
AUTHENTICATION_BACKENDS = ('accounts.modelbackend.CustomModelBackend',)
TEMPLATE_DIRS = (
# Myles' template directory is here because it allows him to work on tabasco.
'/home/mdebastion/templates',
os.path.join(os.path.dirname(__file__), 'templates'),
)
# Email settings
SERVER_EMAIL = 'noreply@freesound.org'
EMAIL_SUBJECT_PREFIX = '[freesound] '
SEND_BROKEN_LINK_EMAILS = True
DEFAULT_FROM_EMAIL = 'Freesound NoReply <noreply@freesound.org>'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
TIME_ZONE = 'Europe/Brussels'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_X_FORWARDED_HOST = True
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = 'freesound'
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
ROOT_URLCONF = 'urls'
AUTH_PROFILE_MODULE = 'accounts.Profile'
LOGIN_URL = '/home/login/'
LOGOUT_URL = '/home/logout/'
LOGIN_REDIRECT_URL = '/home/'
IGNORABLE_404_STARTS = ('/cgi-bin/', '/_vti_bin', '/_vti_inf', '/favicon')
IGNORABLE_404_ENDS = ('.jsp', 'mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', '.php', 'similar')
# A tuple of IP addresses, as strings, that:
# See debug comments, when DEBUG is True
INTERNAL_IPS = ['localhost', '127.0.0.1']
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
MEDIA_URL = "/media/"
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
ADMIN_MEDIA_PREFIX = '/media/admin_media/'
FILES_UPLOAD_DIRECTORY = os.path.join(os.path.dirname(__file__), 'uploads')
# urls for which the "lasta ction time" needs updating
LAST_ACTION_TIME_URLS = ('/forum/', )
FREESOUND_RSS = "http://10.55.0.51/?feed=rss2" #"http://blog.freesound.org/?feed=rss2"
FORUM_POSTS_PER_PAGE = 20
FORUM_THREADS_PER_PAGE = 40
SOUND_COMMENTS_PER_PAGE = 5
SOUNDS_PER_PAGE = 15
PACKS_PER_PAGE = 15
REMIXES_PER_PAGE = 10
SOUNDS_PER_API_RESPONSE = 30
MAX_SOUNDS_PER_API_RESPONSE = 100
SOUNDS_PER_DESCRIBE_ROUND = 10
USERFLAG_THRESHOLD_FOR_NOTIFICATION = 3
USERFLAG_THRESHOLD_FOR_AUTOMATIC_BLOCKING = 6
MAX_TICKETS_IN_MODERATION_ASSIGNED_PAGE = 30
SOUNDS_PENDING_MODERATION_PER_PAGE = 8
MAX_UNMODERATED_SOUNDS_IN_HOME_PAGE = 5
# COOKIE_LAW_EXPIRATION_TIME change in freesound.js (now is 360 days)
# $.cookie("cookieConsent", "yes", { expires: 360, path: '/' });
DELETED_USER_ID = 1
LOG_CLICKTHROUGH_DATA = False
DISPLAY_DEBUG_TOOLBAR = False # change this in the local_settings
#-------------------------------------------------------------------------------
# freesound paths and urls:
DATA_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../freesound-data/'))
AVATARS_PATH = os.path.join(DATA_PATH, "avatars/")
PREVIEWS_PATH = os.path.join(DATA_PATH, "previews/")
DISPLAYS_PATH = os.path.join(DATA_PATH, "displays/") # waveform and spectrum views
SOUNDS_PATH = os.path.join(DATA_PATH, "sounds/")
PACKS_PATH = os.path.join(DATA_PATH, "packs/")
UPLOADS_PATH = os.path.join(DATA_PATH, "uploads/")
ANALYSIS_PATH = os.path.join(DATA_PATH, "analysis/")
SENDFILE_SECRET_URL = "/secret/"
SOUNDS_SENDFILE_URL = SENDFILE_SECRET_URL + "sounds/"
PACKS_SENDFILE_URL = SENDFILE_SECRET_URL + "packs/"
#-------------------------------------------------------------------------------
STEREOFY_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '_sandbox/stereofy/stereofy'))
SESSION_COOKIE_DOMAIN = None # leave this until you know what you are doing
# leave at bottom starting here!
from local_settings import *
TEMPLATE_DEBUG = DEBUG
MANAGERS = ADMINS
# Only cache templates in production
if DEBUG:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
else:
TEMPLATE_LOADERS = (
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
#'django.template.loaders.eggs.load_template_source',
)),
)
# change the media url to tabasco to make the players work when testing
if DEBUG:
DATA_URL = "http://freesound.org/data/"
#DATA_URL = "/data/"
else:
DATA_URL = "/data/"
AVATARS_URL = DATA_URL + "avatars/"
PREVIEWS_URL = DATA_URL + "previews/"
DISPLAYS_URL = DATA_URL + "displays/"
ANALYSIS_URL = DATA_URL + "analysis/"
if DEBUG and DISPLAY_DEBUG_TOOLBAR:
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS +=('127.0.0.1', 'localhost')
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
'debug_toolbar.panels.cache.CacheDebugPanel'
)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
ESSENTIA_EXECUTABLE = '/home/fsweb/freesound/essentia/streaming_extractor_freesound'
# We use the last restart date as a timestamp of the last time freesound web was restarted (lat time
# settings were loaded). We add this variable to the context processor and use it in base.html as a
# parameter for the url of all.css and freesound.js files, so me make sure client browsers update these
# files when we do a deploy (the url changes)
LAST_RESTART_DATE = datetime.datetime.now().strftime("%d%m")
# APIV2 settings
################
APIV2KEYS_ALLOWED_FOR_APIV1 = True
ALLOW_WRITE_WHEN_SESSION_BASED_AUTHENTICATION = False
APIV2_RESOURCES_REQUIRING_HTTPS = ['apiv2-sound-download',
'apiv2-user-create-bookmark',
'apiv2-user-create-rating',
'apiv2-user-create-comment',
'apiv2-uploads-upload',
'apiv2-uploads-not-described',
'apiv2-uploads-describe',
'apiv2-uploads-upload-and-describe',
'apiv2-uploads-not-moderated',
'apiv2-pack-download','apiv2-me',
'oauth2:capture',
'oauth2:authorize',
'oauth2:redirect',
'oauth2:access_token',
'api-login']
REST_FRAMEWORK = {
'PAGINATE_BY': 15,
'PAGINATE_BY_PARAM': 'page_size',
'MAX_PAGINATE_BY': 100,
'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
'rest_framework.renderers.YAMLRenderer',
'rest_framework.renderers.JSONPRenderer',
'rest_framework.renderers.XMLRenderer',
)
}
# Oauth2 provider settings
OAUTH_EXPIRE_DELTA = datetime.timedelta(seconds=60*60*24)
OAUTH_EXPIRE_CODE_DELTA = datetime.timedelta(seconds=10*60)
OAUTH_SINGLE_ACCESS_TOKEN = True
USE_MINIMAL_TEMPLATES_FOR_OAUTH = True
#OAUTH_ENFORCE_SECURE = True # We can not use this parameter because it does not work well with our current django version
# Temportal tag recommendation settings
ONLY_RECOMMEND_TAGS_TO_HALF_OF_UPLOADS = True
from logger import LOGGING