3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Common settings and globals. """
7 from datetime import timedelta
8 from os.path import abspath, basename, dirname, join, normpath
11 from djcelery import setup_loader
13 from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api
15 FILEPICKER_API_KEY = fp_api
18 SERIALIZATION_MODULES = {'json-pretty': 'karmaworld.apps.serializers.json_pretty'}
21 ########## REQUIRED SECURITY CONFIGURATION
22 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS
23 # The hosts that this server runs from.
25 '127.0.0.1', # for dev systems / VMs, but should be safe enough
26 'localhost', # for dev systems / VMs, but should be safe enough
27 'beta.karmanotes.org',
31 ########## END SECURITY CONFIGURATION
33 ########## PATH CONFIGURATION
34 # Absolute filesystem path to the Django project directory:
35 DJANGO_ROOT = dirname(dirname(abspath(__file__)))
37 # Absolute filesystem path to the top-level project folder:
38 SITE_ROOT = dirname(DJANGO_ROOT)
41 SITE_NAME = basename(DJANGO_ROOT)
43 # Add our project to our pythonpath, this way we don't need to type our project
44 # name in our dotted import paths:
45 path.append(DJANGO_ROOT)
46 ########## END PATH CONFIGURATION
49 ########## DEBUG CONFIGURATION
50 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
53 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
54 TEMPLATE_DEBUG = DEBUG
55 ########## END DEBUG CONFIGURATION
58 ########## MANAGER CONFIGURATION
59 # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
61 ('Seth Woodworth', 'seth@finalsclub.org'),
62 ('Charles Holbrow', 'charles@finalsclub.org'),
63 ('Andrew Magliozzi', 'andrew@finalsclub.org'),
66 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
68 ########## END MANAGER CONFIGURATION
71 ########## DATABASE CONFIGURATION
72 # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
75 'ENGINE': 'django.db.backends.',
83 ########## END DATABASE CONFIGURATION
86 ########## GENERAL CONFIGURATION
87 # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
88 TIME_ZONE = 'America/New_York'
90 # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
91 LANGUAGE_CODE = 'en-us'
93 # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
96 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
99 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
101 ########## END GENERAL CONFIGURATION
104 ########## MEDIA CONFIGURATION
105 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
106 MEDIA_ROOT = normpath(join(DJANGO_ROOT, 'media'))
108 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
109 MEDIA_URL = '/media/'
110 ########## END MEDIA CONFIGURATION
113 ########## STATIC FILE CONFIGURATION
115 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
117 normpath(join(DJANGO_ROOT, 'assets')),
120 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
121 STATICFILES_FINDERS = (
122 'django.contrib.staticfiles.finders.FileSystemFinder',
123 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
124 'compressor.finders.CompressorFinder',
126 ########## END STATIC FILE CONFIGURATION
129 ########## SECRET CONFIGURATION
130 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
131 SECRET_KEY = r"(s1k!&^7l28k&nrm2ek(qqo&19%y(zn#=^zq_*ur2@irjun0x4"
132 ########## END SECRET CONFIGURATION
135 ########## FIXTURE CONFIGURATION
136 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
138 normpath(join(DJANGO_ROOT, 'fixtures')),
140 ########## END FIXTURE CONFIGURATION
143 ########## TEMPLATE CONFIGURATION
144 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
145 TEMPLATE_CONTEXT_PROCESSORS = (
146 'django.contrib.auth.context_processors.auth',
147 'django.core.context_processors.debug',
148 'django.core.context_processors.i18n',
149 'django.core.context_processors.media',
150 'django.core.context_processors.static',
151 'django.core.context_processors.tz',
152 'django.contrib.messages.context_processors.messages',
153 'django.core.context_processors.request',
155 # allauth specific context processors
156 "allauth.account.context_processors.account",
157 "allauth.socialaccount.context_processors.socialaccount",
160 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
162 'django.template.loaders.filesystem.Loader',
163 'django.template.loaders.app_directories.Loader',
166 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
168 normpath(join(DJANGO_ROOT, 'templates')),
170 ########## END TEMPLATE CONFIGURATION
173 ########## MIDDLEWARE CONFIGURATION
174 # See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
175 MIDDLEWARE_CLASSES = (
176 # Use GZip compression to reduce bandwidth.
177 'django.middleware.gzip.GZipMiddleware',
179 # Default Django middleware.
180 'django.middleware.common.CommonMiddleware',
181 'django.contrib.sessions.middleware.SessionMiddleware',
182 'django.middleware.csrf.CsrfViewMiddleware',
183 'django.contrib.auth.middleware.AuthenticationMiddleware',
184 'django.contrib.messages.middleware.MessageMiddleware',
186 ########## END MIDDLEWARE CONFIGURATION
189 ########## URL CONFIGURATION
190 # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
191 ROOT_URLCONF = '%s.urls' % SITE_NAME
192 ########## END URL CONFIGURATION
195 ########## APP CONFIGURATION
197 # Default Django apps:
198 'django.contrib.auth',
199 'django.contrib.contenttypes',
200 'django.contrib.sessions',
201 'django.contrib.sites',
202 'django.contrib.messages',
203 'django.contrib.staticfiles',
205 # Useful template tags:
206 'django.contrib.humanize',
208 # grappelli django-admin improvment, must be added before admin
211 # Admin panel and documentation:
212 'django.contrib.admin',
213 'django.contrib.admindocs',
217 # Database migration helpers:
220 # Static file management:
223 # Asynchronous task queue:
226 # Tagging https://github.com/yedpodtrzitko/django-taggit
231 'allauth.socialaccount',
232 # ... include the providers you want to enable:
233 'allauth.socialaccount.providers.facebook',
234 'allauth.socialaccount.providers.google',
235 'allauth.socialaccount.providers.twitter',
240 'karmaworld.apps.notes',
241 'karmaworld.apps.courses',
242 'karmaworld.apps.document_upload',
243 'karmaworld.apps.users',
244 'karmaworld.apps.moderation',
245 'karmaworld.apps.licenses',
248 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
249 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
250 ########## END APP CONFIGURATION
253 ########## AUTHENTICATION
255 AUTHENTICATION_BACKENDS = (
256 # Needed to login by username in Django admin, regardless of `allauth`
257 "django.contrib.auth.backends.ModelBackend",
259 # `allauth` specific authentication methods, such as login by e-mail
260 "allauth.account.auth_backends.AuthenticationBackend",
263 ACCOUNT_EMAIL_REQUIRED = True
264 ACCOUNT_AUTHENTICATION_METHOD = "email"
265 ACCOUNT_CONFIRM_EMAIL_ON_GET = False
266 ACCOUNT_EMAIL_VERIFICATION = "optional"
267 ACCOUNT_EMAIL_SUBJECT_PREFIX = "KarmaNotes.org -- "
268 ACCOUNT_USER_MODEL_EMAIL_FIELD = "email"
269 ACCOUNT_USERNAME_REQUIRED = False
270 SOCIALACCOUNT_EMAIL_REQUIRED = True
271 SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
272 ACCOUNT_USER_DISPLAY = 'karmaworld.apps.users.models.user_display_name'
274 AUTH_PROFILE_MODULE = 'users.UserProfile'
276 ######### END AUTHENTICATION
278 ########## LOGGING CONFIGURATION
279 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
282 'disable_existing_loggers': False,
286 'class': 'logging.StreamHandler'
290 'class': 'django.utils.log.AdminEmailHandler'
295 'handlers': ['console'],
299 'handlers': ['mail_admins'],
305 ########## END LOGGING CONFIGURATION
308 ########## CELERY CONFIGURATION
309 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
310 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
312 # See: http://celery.github.com/celery/django/
314 ########## END CELERY CONFIGURATION
317 ########## WSGI CONFIGURATION
318 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
319 WSGI_APPLICATION = 'wsgi.application'
320 ########## END WSGI CONFIGURATION
323 ########## COMPRESSION CONFIGURATION
324 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
325 COMPRESS_ENABLED = True
327 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
328 COMPRESS_CSS_FILTERS = [
329 'compressor.filters.template.TemplateFilter',
332 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
333 COMPRESS_JS_FILTERS = [
334 'compressor.filters.template.TemplateFilter',
336 ########## END COMPRESSION CONFIGURATION
338 ########## SESSION CONFIGURATION
340 SESSION_COOKIE_AGE = 63072000 # 2 years in seconds
342 ########## END SESSION CONFIGURATION
344 ########## TAGGIT CONFIGURATION
345 # From https://github.com/yedpodtrzitko/django-taggit
348 TAGGIT_FORCE_LOWERCASE = True
350 # Ignore common stopwords
351 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
353 ########## END TAGGIT CONFIGURATION