[Tests] Check number of queries on Podcast / Episode page
[mygpo.git] / mygpo / settings.py
blob10aa5a866fd52e3bdefbe9496faa84109ad2f59f
1 # Django settings for mygpo project.
3 # This file is part of my.gpodder.org.
5 # my.gpodder.org is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or (at your
8 # option) any later version.
10 # my.gpodder.org is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
13 # License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
19 import os.path
20 import dj_database_url
22 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
24 # http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
25 FORCE_SCRIPT_NAME=""
27 DEBUG = True
28 TEMPLATE_DEBUG = DEBUG
30 ADMINS = ()
32 MANAGERS = ADMINS
34 DATABASES = {
35 'default': dj_database_url.config(
36 default='postgres://mygpo:mygpo@localhost/mygpo'),
39 COUCHDB_DATABASES = {
40 'mygpo.directory':
41 {'URL': 'http://127.0.0.1:5984/mygpo'},
43 'mygpo.core':
44 {'URL': 'http://127.0.0.1:5984/mygpo'},
46 'mygpo.api':
47 {'URL': 'http://127.0.0.1:5984/mygpo'},
49 'mygpo.users':
50 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
52 'mygpo.share':
53 {'URL': 'http://127.0.0.1:5984/mygpo'},
55 'mygpo.maintenance':
56 {'URL': 'http://127.0.0.1:5984/mygpo'},
58 'mygpo.pubsub':
59 {'URL': 'http://127.0.0.1:5984/mygpo_pubsub'},
61 'mygpo.suggestions':
62 {'URL': 'http://127.0.0.1:5984/mygpo_suggestions'},
64 'django_couchdb_utils_auth':
65 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
67 'django_couchdb_utils_sessions':
68 {'URL': 'http://127.0.0.1:5984/mygpo_sessions'},
70 'django_couchdb_utils_registration':
71 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
73 'mygpo.categories':
74 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
76 'mygpo.userdata':
77 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
80 # Maps design documents to databases. The keys correspond to the directories in
81 # mygpo/couch/, the values are the app labels which are mapped to the actual
82 # databases in COUCHDB_DATABASES. This indirect mapping is used because
83 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
84 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
85 COUCHDB_DDOC_MAPPING = {
86 'general': 'core',
87 'categories': 'categories',
88 'pubsub': 'pubsub',
89 'userdata': 'userdata',
90 'users': 'users',
91 'suggestions': 'suggestions',
94 # Local time zone for this installation. Choices can be found here:
95 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
96 # although not all choices may be available on all operating systems.
97 # If running in a Windows environment this must be set to the same as your
98 # system time zone.
99 TIME_ZONE = 'UTC'
101 # Language code for this installation. All choices can be found here:
102 # http://www.i18nguy.com/unicode/language-identifiers.html
103 LANGUAGE_CODE = 'en-us'
105 SITE_ID = 1
107 # If you set this to False, Django will make some optimizations so as not
108 # to load the internationalization machinery.
109 USE_I18N = True
111 STATIC_ROOT = 'staticfiles'
112 STATIC_URL = '/media/'
114 STATICFILES_DIRS = (
115 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
118 # List of callables that know how to import templates from various sources.
119 TEMPLATE_LOADERS = (
120 'django.template.loaders.app_directories.Loader',
123 MIDDLEWARE_CLASSES = (
124 'django.middleware.cache.UpdateCacheMiddleware',
125 'django.middleware.common.CommonMiddleware',
126 'django.middleware.csrf.CsrfViewMiddleware',
127 'django.middleware.cache.FetchFromCacheMiddleware',
128 'django.contrib.sessions.middleware.SessionMiddleware',
129 'django.contrib.auth.middleware.AuthenticationMiddleware',
130 'django.middleware.locale.LocaleMiddleware',
131 'django.contrib.messages.middleware.MessageMiddleware',
134 ROOT_URLCONF = 'mygpo.urls'
136 TEMPLATE_DIRS = ()
138 INSTALLED_APPS = (
139 'django.contrib.contenttypes', # unused, but tests fail otherwise (?)
140 'django.contrib.messages',
141 'django.contrib.admin',
142 'django.contrib.humanize',
143 'django.contrib.auth',
144 'django.contrib.sessions',
145 'django.contrib.staticfiles',
146 'django_couchdb_utils.couchauth',
147 'django_couchdb_utils.registration',
148 'djcelery',
149 'mygpo.core',
150 'mygpo.podcasts',
151 'mygpo.users',
152 'mygpo.api',
153 'mygpo.web',
154 'mygpo.publisher',
155 'mygpo.data',
156 'mygpo.userfeeds',
157 'mygpo.directory',
158 'mygpo.maintenance',
159 'mygpo.share',
160 'mygpo.administration',
161 'mygpo.pubsub',
162 'mygpo.db.couchdb',
165 try:
166 import debug_toolbar
167 INSTALLED_APPS += ('debug_toolbar.apps.DebugToolbarConfig', )
169 except ImportError:
170 pass
173 TEST_EXCLUDE = (
174 'django',
175 'couchdbkit',
178 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
180 ACCOUNT_ACTIVATION_DAYS = 7
182 AUTHENTICATION_BACKENDS = (
183 'django_couchdb_utils.couchauth.backends.CouchDBAuthBackend',
184 'mygpo.web.auth.EmailAuthenticationBackend',
185 'django.contrib.auth.backends.ModelBackend',
188 SESSION_ENGINE = "django_couchdb_utils.sessions.cached_couchdb"
190 # TODO: use (default) JSON serializer for security
191 # this would currently fail as we're (de)serializing datetime objects
192 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
193 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
196 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
198 TEMPLATE_CONTEXT_PROCESSORS += (
199 "mygpo.web.google.analytics",
200 "mygpo.web.google.adsense",
202 # make the debug variable available in templates
203 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
204 "django.core.context_processors.debug",
206 # required so that the request obj can be accessed from templates.
207 # this is used to direct users to previous page after login
208 'django.core.context_processors.request',
211 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
213 USER_CLASS = 'mygpo.users.models.User'
215 LOGIN_URL = '/login/'
217 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
220 # The following entries should be set in settings_prod.py
221 DEFAULT_FROM_EMAIL = ''
222 SECRET_KEY = ''
223 GOOGLE_ANALYTICS_PROPERTY_ID=''
224 DIRECTORY_EXCLUDED_TAGS = ()
225 FLICKR_API_KEY = ''
227 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
230 LOGGING = {
231 'version': 1,
232 'disable_existing_loggers': True,
233 'formatters': {
234 'verbose': {
235 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
238 'filters': {
239 'require_debug_false': {
240 '()': 'django.utils.log.RequireDebugFalse'
243 'handlers': {
244 'console':{
245 'level': 'DEBUG',
246 'class': 'logging.StreamHandler',
247 'formatter': 'verbose'
249 'mail_admins': {
250 'level': 'ERROR',
251 'filters': ['require_debug_false'],
252 'class': 'django.utils.log.AdminEmailHandler'
255 'loggers': {
256 'django': {
257 'handlers': ['console'],
258 'propagate': True,
259 'level': 'WARN',
261 'mygpo': {
262 'handlers': ['console'],
263 'level': 'INFO',
268 # minimum number of subscribers a podcast must have to be assigned a slug
269 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
271 # minimum number of subscribers that a podcast needs to "push" one of its
272 # categories to the top
273 MIN_SUBSCRIBERS_CATEGORY=10
275 # maximum number of episode actions that the API processes immediatelly before
276 # returning the response. Larger requests will be handled in background.
277 # Handler can be set to None to disable
278 API_ACTIONS_MAX_NONBG=100
279 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
282 ADSENSE_CLIENT = ''
283 ADSENSE_SLOT_BOTTOM = ''
285 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
286 STAFF_TOKEN = None
288 # Flattr settings -- available after you register your app
289 FLATTR_KEY = ''
290 FLATTR_SECRET = ''
292 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
293 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
295 # The User-Agent string used for outgoing HTTP requests
296 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
298 # Base URL of the website that is used if the actually used parameters is not
299 # available. Request handlers, for example, can access the requested domain.
300 # Code that runs in background can not do this, and therefore requires a
301 # default value. This should be set to something like 'http://example.com'
302 DEFAULT_BASE_URL = ''
305 ### Celery
307 BROKER_URL='redis://localhost'
308 CELERY_RESULT_BACKEND='redis://localhost'
310 import djcelery
311 djcelery.setup_loader()
313 # a dictionary containing celery settings from
314 # http://docs.celeryproject.org/en/latest/configuration.html
315 CELERY_CONF = dict(
316 CELERY_SEND_TASK_ERROR_EMAILS = True,
317 ADMINS=ADMINS,
318 SERVER_EMAIL = "no-reply@example.com",
322 ### Google API
324 GOOGLE_CLIENT_ID=''
325 GOOGLE_CLIENT_SECRET=''
327 # URL where users of the site can get support
328 SUPPORT_URL=''
331 import sys
332 if 'test' in sys.argv:
333 SECRET_KEY = 'test'
336 try:
337 from settings_prod import *
338 except ImportError, e:
339 import sys
340 print >> sys.stderr, 'create settings_prod.py with your customized settings'