[Migration] remove references to main database
[mygpo.git] / mygpo / settings.py
blob2fb7220970f61d20a486cd903eb0ed33dc2d695f
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 sys
20 import os.path
21 import dj_database_url
23 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
25 # http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
26 FORCE_SCRIPT_NAME=""
28 DEBUG = True
29 TEMPLATE_DEBUG = DEBUG
31 ADMINS = ()
33 MANAGERS = ADMINS
35 DATABASES = {
36 'default': dj_database_url.config(
37 default='postgres://mygpo:mygpo@localhost/mygpo'),
40 COUCHDB_DATABASES = {
41 'mygpo.directory':
42 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
44 'mygpo.users':
45 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
47 'mygpo.pubsub':
48 {'URL': 'http://127.0.0.1:5984/mygpo_pubsub'},
50 'mygpo.suggestions':
51 {'URL': 'http://127.0.0.1:5984/mygpo_suggestions'},
53 'mygpo.share':
54 {'URL': 'http://127.0.0.1:5984/mygpo_podcastlists'},
56 'mygpo.podcastlists':
57 {'URL': 'http://127.0.0.1:5984/mygpo_podcastlists'},
59 'django_couchdb_utils_auth':
60 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
62 'django_couchdb_utils_sessions':
63 {'URL': 'http://127.0.0.1:5984/mygpo_sessions'},
65 'django_couchdb_utils_registration':
66 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
68 'mygpo.categories':
69 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
71 'mygpo.userdata':
72 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
75 # Maps design documents to databases. The keys correspond to the directories in
76 # mygpo/couch/, the values are the app labels which are mapped to the actual
77 # databases in COUCHDB_DATABASES. This indirect mapping is used because
78 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
79 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
80 COUCHDB_DDOC_MAPPING = {
81 'categories': 'categories',
82 'pubsub': 'pubsub',
83 'userdata': 'userdata',
84 'users': 'users',
85 'suggestions': 'suggestions',
88 # Local time zone for this installation. Choices can be found here:
89 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
90 # although not all choices may be available on all operating systems.
91 # If running in a Windows environment this must be set to the same as your
92 # system time zone.
93 TIME_ZONE = 'UTC'
95 # Language code for this installation. All choices can be found here:
96 # http://www.i18nguy.com/unicode/language-identifiers.html
97 LANGUAGE_CODE = 'en-us'
99 SITE_ID = 1
101 # If you set this to False, Django will make some optimizations so as not
102 # to load the internationalization machinery.
103 USE_I18N = True
105 STATIC_ROOT = 'staticfiles'
106 STATIC_URL = '/media/'
108 STATICFILES_DIRS = (
109 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
112 # List of callables that know how to import templates from various sources.
113 TEMPLATE_LOADERS = (
114 'django.template.loaders.app_directories.Loader',
117 MIDDLEWARE_CLASSES = (
118 'django.middleware.cache.UpdateCacheMiddleware',
119 'django.middleware.common.CommonMiddleware',
120 'django.middleware.csrf.CsrfViewMiddleware',
121 'django.middleware.cache.FetchFromCacheMiddleware',
122 'django.contrib.sessions.middleware.SessionMiddleware',
123 'django.contrib.auth.middleware.AuthenticationMiddleware',
124 'django.middleware.locale.LocaleMiddleware',
125 'django.contrib.messages.middleware.MessageMiddleware',
128 ROOT_URLCONF = 'mygpo.urls'
130 TEMPLATE_DIRS = ()
132 INSTALLED_APPS = (
133 'django.contrib.contenttypes', # unused, but tests fail otherwise (?)
134 'django.contrib.messages',
135 'django.contrib.admin',
136 'django.contrib.humanize',
137 'django.contrib.auth',
138 'django.contrib.sessions',
139 'django.contrib.staticfiles',
140 'django_couchdb_utils.couchauth',
141 'django_couchdb_utils.registration',
142 'djcelery',
143 'mygpo.core',
144 'mygpo.podcasts',
145 'mygpo.search',
146 'mygpo.users',
147 'mygpo.api',
148 'mygpo.web',
149 'mygpo.publisher',
150 'mygpo.data',
151 'mygpo.userfeeds',
152 'mygpo.directory',
153 'mygpo.maintenance',
154 'mygpo.share',
155 'mygpo.administration',
156 'mygpo.pubsub',
157 'mygpo.db.couchdb',
160 try:
161 import debug_toolbar
162 INSTALLED_APPS += ('debug_toolbar.apps.DebugToolbarConfig', )
164 except ImportError:
165 print >> sys.stderr, 'Could not load django-debug-toolbar'
168 TEST_EXCLUDE = (
169 'django',
170 'couchdbkit',
173 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
175 ACCOUNT_ACTIVATION_DAYS = 7
177 AUTHENTICATION_BACKENDS = (
178 'django_couchdb_utils.couchauth.backends.CouchDBAuthBackend',
179 'mygpo.web.auth.EmailAuthenticationBackend',
180 'django.contrib.auth.backends.ModelBackend',
183 SESSION_ENGINE = "django_couchdb_utils.sessions.cached_couchdb"
185 # TODO: use (default) JSON serializer for security
186 # this would currently fail as we're (de)serializing datetime objects
187 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
188 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
191 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
193 TEMPLATE_CONTEXT_PROCESSORS += (
194 "mygpo.web.google.analytics",
195 "mygpo.web.google.adsense",
197 # make the debug variable available in templates
198 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
199 "django.core.context_processors.debug",
201 # required so that the request obj can be accessed from templates.
202 # this is used to direct users to previous page after login
203 'django.core.context_processors.request',
206 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
208 USER_CLASS = 'mygpo.users.models.User'
210 LOGIN_URL = '/login/'
212 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
215 # The following entries should be set in settings_prod.py
216 DEFAULT_FROM_EMAIL = ''
217 SECRET_KEY = ''
218 GOOGLE_ANALYTICS_PROPERTY_ID=''
219 DIRECTORY_EXCLUDED_TAGS = ()
220 FLICKR_API_KEY = ''
222 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
225 LOGGING = {
226 'version': 1,
227 'disable_existing_loggers': True,
228 'formatters': {
229 'verbose': {
230 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
233 'filters': {
234 'require_debug_false': {
235 '()': 'django.utils.log.RequireDebugFalse'
238 'handlers': {
239 'console':{
240 'level': 'DEBUG',
241 'class': 'logging.StreamHandler',
242 'formatter': 'verbose'
244 'mail_admins': {
245 'level': 'ERROR',
246 'filters': ['require_debug_false'],
247 'class': 'django.utils.log.AdminEmailHandler'
250 'loggers': {
251 'django': {
252 'handlers': ['console'],
253 'propagate': True,
254 'level': 'WARN',
256 'mygpo': {
257 'handlers': ['console'],
258 'level': 'INFO',
263 # minimum number of subscribers a podcast must have to be assigned a slug
264 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
266 # minimum number of subscribers that a podcast needs to "push" one of its
267 # categories to the top
268 MIN_SUBSCRIBERS_CATEGORY=10
270 # maximum number of episode actions that the API processes immediatelly before
271 # returning the response. Larger requests will be handled in background.
272 # Handler can be set to None to disable
273 API_ACTIONS_MAX_NONBG=100
274 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
277 ADSENSE_CLIENT = ''
278 ADSENSE_SLOT_BOTTOM = ''
280 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
281 STAFF_TOKEN = None
283 # Flattr settings -- available after you register your app
284 FLATTR_KEY = ''
285 FLATTR_SECRET = ''
287 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
288 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
290 # The User-Agent string used for outgoing HTTP requests
291 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
293 # Base URL of the website that is used if the actually used parameters is not
294 # available. Request handlers, for example, can access the requested domain.
295 # Code that runs in background can not do this, and therefore requires a
296 # default value. This should be set to something like 'http://example.com'
297 DEFAULT_BASE_URL = ''
300 ### Celery
302 BROKER_URL='redis://localhost'
303 CELERY_RESULT_BACKEND='redis://localhost'
305 import djcelery
306 djcelery.setup_loader()
308 # a dictionary containing celery settings from
309 # http://docs.celeryproject.org/en/latest/configuration.html
310 CELERY_CONF = dict(
311 CELERY_SEND_TASK_ERROR_EMAILS = True,
312 ADMINS=ADMINS,
313 SERVER_EMAIL = "no-reply@example.com",
317 ### Google API
319 GOOGLE_CLIENT_ID=''
320 GOOGLE_CLIENT_SECRET=''
322 # URL where users of the site can get support
323 SUPPORT_URL=''
326 # Elasticsearch settings
328 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
329 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
330 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
333 import sys
334 if 'test' in sys.argv:
335 SECRET_KEY = 'test'
338 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
340 try:
341 from settings_prod import *
342 except ImportError, e:
343 import sys
344 print >> sys.stderr, 'create settings_prod.py with your customized settings'