celery queue name setting
[oweals/karmaworld.git] / karmaworld / settings / common.py
index 81794c9e9c4b7bedab6c4bf76507dda6acb43e03..a679864a60ea11152591ba6f58ea2d2b7b66dbe1 100644 (file)
@@ -1,13 +1,29 @@
-"""Common settings and globals."""
-
-
+#!/usr/bin/env python
+# -*- coding:utf8 -*-
+# Copyright (C) 2012  FinalsClub Foundation
+""" Common settings and globals. """
 from datetime import timedelta
-from os.path import abspath, basename, dirname, join, normpath
+from os.path import dirname, abspath, basename, normpath, join
+import sys
+import os
 from sys import path
-
 from djcelery import setup_loader
+import dj_database_url
+
+FILEPICKER_API_KEY = os.environ['FILEPICKER_API_KEY']
+FILEPICKER_INPUT_TYPE = 'filepicker'
+
+SERIALIZATION_MODULES = {'json-pretty': 'karmaworld.apps.serializers.json_pretty'}
 
 
+########## REQUIRED SECURITY CONFIGURATION
+# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS
+# The hosts that this server runs from.
+ALLOWED_HOSTS = [
+    '*'
+]
+########## END SECURITY CONFIGURATION
+
 ########## PATH CONFIGURATION
 # Absolute filesystem path to the Django project directory:
 DJANGO_ROOT = dirname(dirname(abspath(__file__)))
@@ -36,7 +52,9 @@ TEMPLATE_DEBUG = DEBUG
 ########## MANAGER CONFIGURATION
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
 ADMINS = (
-    ('Your Name', 'your_email@example.com'),
+    ('Seth Woodworth', 'seth@finalsclub.org'),
+    ('Charles Holbrow', 'charles@finalsclub.org'),
+    ('Andrew Magliozzi', 'andrew@finalsclub.org'),
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
@@ -46,22 +64,13 @@ MANAGERS = ADMINS
 
 ########## DATABASE CONFIGURATION
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.',
-        'NAME': '',
-        'USER': '',
-        'PASSWORD': '',
-        'HOST': '',
-        'PORT': '',
-    }
-}
+DATABASES = {'default': dj_database_url.config()}
 ########## END DATABASE CONFIGURATION
 
 
 ########## GENERAL CONFIGURATION
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
-TIME_ZONE = 'America/Los_Angeles'
+TIME_ZONE = 'America/New_York'
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
 LANGUAGE_CODE = 'en-us'
@@ -87,11 +96,6 @@ MEDIA_URL = '/media/'
 
 
 ########## STATIC FILE CONFIGURATION
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
-STATIC_ROOT = normpath(join(DJANGO_ROOT, 'static'))
-
-# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
-STATIC_URL = '/static/'
 
 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
 STATICFILES_DIRS = (
@@ -104,6 +108,14 @@ STATICFILES_FINDERS = (
     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
     'compressor.finders.CompressorFinder',
 )
+
+S3_URL = '//%s.s3.amazonaws.com/' % os.environ.get('AWS_STORAGE_BUCKET_NAME')
+DEFAULT_FILE_STORAGE = os.environ['DEFAULT_FILE_STORAGE']
+
+AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
+AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
+AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
+
 ########## END STATIC FILE CONFIGURATION
 
 
@@ -132,6 +144,11 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     'django.core.context_processors.tz',
     'django.contrib.messages.context_processors.messages',
     'django.core.context_processors.request',
+    'karmaworld.apps.notes.context_processors.s3_url',
+
+    # allauth specific context processors
+    "allauth.account.context_processors.account",
+    "allauth.socialaccount.context_processors.socialaccount",
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
@@ -153,6 +170,9 @@ MIDDLEWARE_CLASSES = (
     # Use GZip compression to reduce bandwidth.
     'django.middleware.gzip.GZipMiddleware',
 
+    # Version control middleware.
+    'reversion.middleware.RevisionMiddleware',
+
     # Default Django middleware.
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
@@ -182,6 +202,9 @@ DJANGO_APPS = (
     # Useful template tags:
     'django.contrib.humanize',
 
+    # grappelli django-admin improvment, must be added before admin
+    'grappelli',
+
     # Admin panel and documentation:
     'django.contrib.admin',
     'django.contrib.admindocs',
@@ -199,12 +222,32 @@ THIRD_PARTY_APPS = (
 
     # Tagging https://github.com/yedpodtrzitko/django-taggit
     'taggit',
+
+    # Version control
+    'reversion',
+
+    # AJAX endpoints for autocompletion
+    'ajax_select',
+    'ajax_select_cascade',
+
+    'allauth',
+    'allauth.account',
+    'allauth.socialaccount',
+    # ... include the providers you want to enable:
+    'allauth.socialaccount.providers.facebook',
+    'allauth.socialaccount.providers.google',
+    'allauth.socialaccount.providers.twitter',
 )
 
 LOCAL_APPS = (
     # file handling app
     'karmaworld.apps.notes',
     'karmaworld.apps.courses',
+    'karmaworld.apps.document_upload',
+    'karmaworld.apps.users',
+    'karmaworld.apps.moderation',
+    'karmaworld.apps.licenses',
+    'karmaworld.apps.quizzes',
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
@@ -212,22 +255,65 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
 ########## END APP CONFIGURATION
 
 
+########## AUTHENTICATION
+
+AUTHENTICATION_BACKENDS = (
+    # Needed to login by username in Django admin, regardless of `allauth`
+    "django.contrib.auth.backends.ModelBackend",
+
+    # `allauth` specific authentication methods, such as login by e-mail
+    "allauth.account.auth_backends.AuthenticationBackend",
+)
+
+ACCOUNT_EMAIL_REQUIRED = True
+ACCOUNT_AUTHENTICATION_METHOD = "email"
+ACCOUNT_CONFIRM_EMAIL_ON_GET = False
+ACCOUNT_EMAIL_VERIFICATION = "optional"
+ACCOUNT_EMAIL_SUBJECT_PREFIX = "KarmaNotes.org -- "
+ACCOUNT_USERNAME_REQUIRED = True
+SOCIALACCOUNT_EMAIL_REQUIRED = True
+SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
+SOCIALACCOUNT_QUERY_EMAIL = True
+SOCIALACCOUNT_AUTO_SIGNUP = False
+ACCOUNT_USER_DISPLAY = 'karmaworld.apps.users.models.user_display_name'
+ACCOUNT_SIGNUP_FORM_CLASS = 'karmaworld.apps.users.forms.SignupForm'
+ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
+LOGIN_REDIRECT_URL = '/'
+
+AUTH_PROFILE_MODULE = 'users.UserProfile'
+
+######### END AUTHENTICATION
+
 ########## LOGGING CONFIGURATION
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,
+    'filters': {
+         'require_debug_false': {
+             '()': 'django.utils.log.RequireDebugFalse'
+         }
+     },
     'handlers': {
+        'console': {
+            'level': 'INFO',
+            'class': 'logging.StreamHandler'
+        },
         'mail_admins': {
             'level': 'ERROR',
+            'filters': ['require_debug_false'],
             'class': 'django.utils.log.AdminEmailHandler'
         }
     },
     'loggers': {
+        'django': {
+            'handlers': ['console'],
+            'level': 'INFO'
+        },
         'django.request': {
             'handlers': ['mail_admins'],
             'level': 'ERROR',
-            'propagate': True,
+            'propagate': True
         },
     }
 }
@@ -240,6 +326,8 @@ CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
 
 # See: http://celery.github.com/celery/django/
 setup_loader()
+
+CELERY_DEFAULT_QUEUE = os.environ['CELERY_QUEUE_NAME']
 ########## END CELERY CONFIGURATION
 
 
@@ -264,6 +352,13 @@ COMPRESS_JS_FILTERS = [
 ]
 ########## END COMPRESSION CONFIGURATION
 
+########## SESSION CONFIGURATION
+
+SESSION_ENGINE = 'django.contrib.sessions.backends.db'
+SESSION_COOKIE_AGE = 63072000    # 2 years in seconds
+
+########## END SESSION CONFIGURATION
+
 ########## TAGGIT CONFIGURATION
 # From https://github.com/yedpodtrzitko/django-taggit
 
@@ -275,3 +370,28 @@ TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
 
 ########## END TAGGIT CONFIGURATION
 
+
+########## HONEYPOT CONFIGURATION
+# parts of this code borrow from
+# https://github.com/sunlightlabs/django-honeypot
+HONEYPOT_FIELD_NAME = "instruction_url" # see that "_url"? bots gotta want that.
+HONEYPOT_VALUE = ""
+HONEYPOT_LABEL = "Humans, leave this blank so we can prevent robots from submitting bogus courses"
+HONEYPOT_ERROR = "You did not follow directions."
+########## END HONEYPOT CONFIGURATION
+
+
+########## SOUTH CONFIGURATION
+SOUTH_MIGRATION_MODULES = {
+    'taggit': 'taggit.south_migrations',
+}
+########## END SOUTH CONFIGURATION
+
+########## AJAX SELECTS CONFIGURATION
+AJAX_SELECT_BOOTSTRAP = False
+########## END AJAX SELECTS CONFIGURATION
+
+
+########## TESTING CONFIGURATION
+TESTING = 'test' in sys.argv
+########## END TESTING CONFIGURATION