settings.py.template 4.12 KB
Newer Older
David Haynes's avatar
David Haynes committed
1
# Create a new file 'settings.py' and copy these contents into that file
2
from . import secret
David Haynes's avatar
David Haynes committed
3
import os
Nicholas J Anderson's avatar
Nicholas J Anderson committed
4
import sys
David Haynes's avatar
David Haynes committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# DEBUG mode is used to view more details when errors occur
# Do not have set True in production
DEBUG = False

ADMINS = ()
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': secret.DB_NAME,
        'USER': secret.DB_USER,
        'PASSWORD': secret.DB_PASSWORD,
        'HOST': secret.DB_HOST,
        'PORT': '',
    }
}

# The domains this application will be deployed on
# e.g. Which domains this app should listen to requests from.
ALLOWED_HOSTS = ['127.0.0.1']

# Peoplefinder API
31
PF_URL = "https://api.srct.gmu.edu/pf/v1/"
David Haynes's avatar
David Haynes committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True

MEDIA_URL = '/media/'
MEDIA_ROOT = ''
MEDIAFILES_DIRS = (
  os.path.join(BASE_DIR, 'media/'),
)

STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
  os.path.join(BASE_DIR, 'static/'),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

SECRET_KEY = secret.SECRET_KEY

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates')
        ],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.request'
            ],
            'loaders': [
                'django.template.loaders.app_directories.Loader'
            ],
            'debug': DEBUG
        }
    }
]

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'settings.urls'

WSGI_APPLICATION = 'settings.wsgi.application'

INSTALLED_APPS = (
91 92 93 94 95 96 97 98 99 100
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.sites',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'go',
  'django.contrib.admin',
  'qrcode',
  'crispy_forms',
Matthew Rodgers's avatar
Matthew Rodgers committed
101
  'bootstrap3_datetime',
David Haynes's avatar
David Haynes committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
)

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
Nicholas J Anderson's avatar
Nicholas J Anderson committed
119 120 121 122 123
        },
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'stream': sys.stdout
David Haynes's avatar
David Haynes committed
124 125 126 127 128 129 130 131
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
Nicholas J Anderson's avatar
Nicholas J Anderson committed
132 133 134 135 136
        'django': {
            'handlers': ['console'],
            'level': 'INFO',
            'propogate': True
        },
David Haynes's avatar
David Haynes committed
137 138 139 140 141 142 143 144 145 146 147 148
    }
}


LOGIN_URL = '/login'
LOGOUT_URL = '/logout'
LOGIN_REDIRECT_URL = '/'

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
)

David Haynes's avatar
David Haynes committed
149 150 151
CAS_SERVER_URL = "https://login.gmu.edu"
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
David Haynes's avatar
David Haynes committed
152

David Haynes's avatar
David Haynes committed
153 154 155
AUTHENTICATION_BACKENDS += (
    'cas.backends.CASBackend',
)
David Haynes's avatar
David Haynes committed
156

David Haynes's avatar
David Haynes committed
157 158 159
CAS_RESPONSE_CALLBACKS = (
    'go.cas_callbacks.create_user',
)
David Haynes's avatar
David Haynes committed
160

David Haynes's avatar
David Haynes committed
161 162 163
INSTALLED_APPS += (
    'cas',
)
David Haynes's avatar
David Haynes committed
164

David Haynes's avatar
David Haynes committed
165 166 167
MIDDLEWARE_CLASSES += (
    'cas.middleware.CASMiddleware',
)
David Haynes's avatar
David Haynes committed
168 169 170 171 172 173 174 175 176 177

CRISPY_TEMPLATE_PACK = 'bootstrap3'

# Mail settings
EMAIL_HOST = secret.EMAIL_HOST
EMAIL_PORT = secret.EMAIL_PORT
EMAIL_HOST_USER = secret.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = secret.EMAIL_HOST_PASSWORD
EMAIL_FROM = "example@example.com"
EMAIL_TO = "to@example.com"
178 179 180 181

# Domain used to email to users. See line 231 in views.py
# ie. in Mason's case '@masonlive.gmu.edu'
EMAIL_DOMAIN = "@example.com"