[Settings] fix typos
[mygpo.git] / mygpo / settings.py
blob9b453383e445eee11977b43cfd700e1b280d1a8b
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.users':
42 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
44 'mygpo.userdata':
45 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
48 # Maps design documents to databases. The keys correspond to the directories in
49 # mygpo/couch/, the values are the app labels which are mapped to the actual
50 # databases in COUCHDB_DATABASES. This indirect mapping is used because
51 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
52 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
53 COUCHDB_DDOC_MAPPING = {
54 'userdata': 'userdata',
55 'users': 'users',
58 # Local time zone for this installation. Choices can be found here:
59 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
60 # although not all choices may be available on all operating systems.
61 # If running in a Windows environment this must be set to the same as your
62 # system time zone.
63 TIME_ZONE = 'UTC'
65 # Language code for this installation. All choices can be found here:
66 # http://www.i18nguy.com/unicode/language-identifiers.html
67 LANGUAGE_CODE = 'en-us'
69 SITE_ID = 1
71 # If you set this to False, Django will make some optimizations so as not
72 # to load the internationalization machinery.
73 USE_I18N = True
75 STATIC_ROOT = 'staticfiles'
76 STATIC_URL = '/media/'
78 STATICFILES_DIRS = (
79 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
82 # List of callables that know how to import templates from various sources.
83 TEMPLATE_LOADERS = (
84 'django.template.loaders.app_directories.Loader',
87 MIDDLEWARE_CLASSES = (
88 'django.middleware.cache.UpdateCacheMiddleware',
89 'django.middleware.common.CommonMiddleware',
90 'django.middleware.csrf.CsrfViewMiddleware',
91 'django.middleware.cache.FetchFromCacheMiddleware',
92 'django.contrib.sessions.middleware.SessionMiddleware',
93 'django.contrib.auth.middleware.AuthenticationMiddleware',
94 'django.middleware.locale.LocaleMiddleware',
95 'django.contrib.messages.middleware.MessageMiddleware',
98 ROOT_URLCONF = 'mygpo.urls'
100 TEMPLATE_DIRS = ()
102 INSTALLED_APPS = (
103 'django.contrib.contenttypes',
104 'django.contrib.messages',
105 'django.contrib.admin',
106 'django.contrib.humanize',
107 'django.contrib.auth',
108 'django.contrib.sessions',
109 'django.contrib.staticfiles',
110 'djcelery',
111 'mygpo.core',
112 'mygpo.podcasts',
113 'mygpo.chapters',
114 'mygpo.search',
115 'mygpo.users',
116 'mygpo.api',
117 'mygpo.web',
118 'mygpo.publisher',
119 'mygpo.subscriptions',
120 'mygpo.history',
121 'mygpo.favorites',
122 'mygpo.data',
123 'mygpo.userfeeds',
124 'mygpo.suggestions',
125 'mygpo.directory',
126 'mygpo.categories',
127 'mygpo.maintenance',
128 'mygpo.share',
129 'mygpo.administration',
130 'mygpo.pubsub',
131 'mygpo.podcastlists',
132 'mygpo.votes',
133 'mygpo.db.couchdb',
136 try:
137 import debug_toolbar
138 INSTALLED_APPS += ('debug_toolbar', )
140 except ImportError:
141 print >> sys.stderr, 'Could not load django-debug-toolbar'
144 TEST_EXCLUDE = (
145 'django',
146 'couchdbkit',
149 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
151 ACCOUNT_ACTIVATION_DAYS = 7
153 AUTHENTICATION_BACKENDS = (
154 'django.contrib.auth.backends.ModelBackend',
155 'mygpo.web.auth.EmailAuthenticationBackend',
158 SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
160 # TODO: use (default) JSON serializer for security
161 # this would currently fail as we're (de)serializing datetime objects
162 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
163 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
166 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
168 TEMPLATE_CONTEXT_PROCESSORS += (
169 "mygpo.web.google.analytics",
170 "mygpo.web.google.adsense",
172 # make the debug variable available in templates
173 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
174 "django.core.context_processors.debug",
176 # required so that the request obj can be accessed from templates.
177 # this is used to direct users to previous page after login
178 'django.core.context_processors.request',
181 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
183 USER_CLASS = 'mygpo.users.models.User'
185 LOGIN_URL = '/login/'
187 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
190 # The following entries should be set in settings_prod.py
191 DEFAULT_FROM_EMAIL = ''
192 SECRET_KEY = os.getenv('SECRET_KEY', '')
193 GOOGLE_ANALYTICS_PROPERTY_ID=''
194 DIRECTORY_EXCLUDED_TAGS = ()
195 FLICKR_API_KEY = ''
197 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
200 LOGGING = {
201 'version': 1,
202 'disable_existing_loggers': True,
203 'formatters': {
204 'verbose': {
205 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
208 'filters': {
209 'require_debug_false': {
210 '()': 'django.utils.log.RequireDebugFalse'
213 'handlers': {
214 'console':{
215 'level': 'DEBUG',
216 'class': 'logging.StreamHandler',
217 'formatter': 'verbose'
219 'mail_admins': {
220 'level': 'ERROR',
221 'filters': ['require_debug_false'],
222 'class': 'django.utils.log.AdminEmailHandler'
225 'loggers': {
226 'django': {
227 'handlers': ['console'],
228 'propagate': True,
229 'level': 'WARN',
231 'mygpo': {
232 'handlers': ['console'],
233 'level': 'INFO',
235 'celery': {
236 'handlers': ['console'],
237 'level': 'DEBUG',
242 # minimum number of subscribers a podcast must have to be assigned a slug
243 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
245 # minimum number of subscribers that a podcast needs to "push" one of its
246 # categories to the top
247 MIN_SUBSCRIBERS_CATEGORY=10
249 # maximum number of episode actions that the API processes immediatelly before
250 # returning the response. Larger requests will be handled in background.
251 # Handler can be set to None to disable
252 API_ACTIONS_MAX_NONBG=100
253 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
256 ADSENSE_CLIENT = ''
257 ADSENSE_SLOT_BOTTOM = ''
259 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
260 STAFF_TOKEN = None
262 # Flattr settings -- available after you register your app
263 FLATTR_KEY = ''
264 FLATTR_SECRET = ''
266 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
267 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
269 # The User-Agent string used for outgoing HTTP requests
270 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
272 # Base URL of the website that is used if the actually used parameters is not
273 # available. Request handlers, for example, can access the requested domain.
274 # Code that runs in background can not do this, and therefore requires a
275 # default value. This should be set to something like 'http://example.com'
276 DEFAULT_BASE_URL = ''
279 ### Celery
281 BROKER_URL='redis://localhost'
282 CELERY_RESULT_BACKEND='redis://localhost'
284 #CELERY_SEND_TASK_ERROR_EMAILS = True
285 SERVER_EMAIL = "no-reply@example.com"
288 ### Google API
290 GOOGLE_CLIENT_ID=''
291 GOOGLE_CLIENT_SECRET=''
293 # URL where users of the site can get support
294 SUPPORT_URL=''
297 # Elasticsearch settings
299 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
300 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
301 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
303 # time for how long an activation is valid; after that, an unactivated user
304 # will be deleted
305 ACTIVATION_VALID_DAYS = int(os.getenv('ACTIVATION_VALID_DAYS', 10))
307 import sys
308 if 'test' in sys.argv:
309 SECRET_KEY = 'test'
312 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
314 try:
315 from settings_prod import *
316 except ImportError, e:
317 import sys
318 print >> sys.stderr, 'create settings_prod.py with your customized settings'