settings.py 6.42 KB
Newer Older
1
"""
2
Django settings for roomlist project.
3 4

For more information on this file, see
5
https://docs.djangoproject.com/en/1.7/topics/settings/
6 7

For the full list of settings and their values, see
8
https://docs.djangoproject.com/en/1.7/ref/settings/
9 10
"""

11
# standard library imports
12
from __future__ import absolute_import, print_function
13 14 15 16 17
import os
# core django imports
from django.contrib.messages import constants as messages
# imports from your apps
from . import secret
18

19 20
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
21

22 23
# cryptography
SECRET_KEY = secret.SECRET_KEY
24

25 26 27 28 29
# These configurations are set by default for a local development environment. Turning
# off debug mode will display 404 and 500 error pages instead of detailed logs.
DEBUG = True
# the domains this application will be deployed on, e.g. which
# domains this app should listen to requests from.
30
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
31

32 33 34
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
35 36 37
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
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
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            # where template files are located
            os.path.join(BASE_DIR, 'templates'),
            # may specify to avoid requiring paths
            os.path.join(BASE_DIR, 'housing/templates'),
            os.path.join(BASE_DIR, 'accounts/templates'),
        ],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
            'debug': DEBUG,
        }
    }
]
Daniel W Bond's avatar
Daniel W Bond committed
68

69 70 71 72 73 74 75 76
# Application definition
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
Jason D Yeomans's avatar
Jason D Yeomans committed
77
    'django.contrib.sites',
78
    'django.contrib.humanize',
Daniel W Bond's avatar
Daniel W Bond committed
79
    # apps
80
    'api',
81
    'housing',
82
    'accounts',
Daniel W Bond's avatar
Daniel W Bond committed
83
    'welcome',
84
    'core',
Daniel W Bond's avatar
Daniel W Bond committed
85
    # packages
86 87
    'analytical',
    'cas',
88 89
    'crispy_forms',
    'django_gravatar',
Daniel W Bond's avatar
Daniel W Bond committed
90
    'haystack',
91
    'multiselectfield',
92
    'randomslugfield',
93
    'rest_framework',
94
    # social media authentication
Jason D Yeomans's avatar
Jason D Yeomans committed
95 96 97 98 99 100
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',
101
    'allauth.socialaccount.providers.instagram',
102
    'allauth.socialaccount.providers.tumblr',
103
    'allauth.socialaccount.providers.github',
104
    # 'allauth.socialaccount.providers.spotify',
105
    # twitch? stackexchange? soundcloud?
106 107
)

108 109
CRISPY_TEMPLATE_PACK = 'bootstrap'

110 111
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
112
    'django.contrib.sessions.middleware.SessionMiddleware',
113
    'django.contrib.auth.middleware.AuthenticationMiddleware',
Daniel W Bond's avatar
Daniel W Bond committed
114
    'cas.middleware.CASMiddleware',
115
    'django.contrib.admindocs.middleware.XViewMiddleware',
116 117

    'django.middleware.csrf.CsrfViewMiddleware',
118 119 120 121
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

122
ROOT_URLCONF = 'settings.urls'
123

124
WSGI_APPLICATION = 'settings.wsgi.application'
125

126 127
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
128 129
DATABASES = {
    'default': {
130
        # If you want to change the database engine you are free to do so here.
131
        'ENGINE': 'django.db.backends.mysql',
132 133
        'NAME': 'roomlist',
        'USER': 'roommate',
134
        'PASSWORD': secret.DB_PASSWORD,
135 136
        'HOST': 'localhost',
        'PORT': '',
137 138 139 140
    }
}

# Internationalization
141
# https://docs.djangoproject.com/en/1.7/topics/i18n/
142
LANGUAGE_CODE = 'en-us'
143
TIME_ZONE = 'America/New_York'
144 145 146 147
USE_I18N = True
USE_L10N = True
USE_TZ = True

148
# set for social auth
149
# example.com is by default set to 1
150
# add localhost and it will be 2
151
SITE_ID = 2
Daniel W Bond's avatar
Daniel W Bond committed
152

153
# further settings for social auth
154
# custom account adapter
155 156
SOCIALACCOUNT_ADAPTER = 'accounts.adapter.AccountAdapter'

157
# specifying what information is being requested from Facebook
158 159 160 161 162 163 164 165 166 167 168 169
SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': ['public_profile', ],
        'FIELDS': [
            'id',
            'first_name',
            'last_name',
            'link',
            ]
        }
    }

170 171
# for bootstrap css classes
MESSAGE_TAGS = {messages.ERROR: 'danger', }
172

173
# for using Mason's Central Authentication Service
Jason D Yeomans's avatar
Jason D Yeomans committed
174
AUTHENTICATION_BACKENDS = (
175
    'django.contrib.auth.backends.ModelBackend',
Daniel W Bond's avatar
Daniel W Bond committed
176
    'cas.backends.CASBackend',
Jason D Yeomans's avatar
Jason D Yeomans committed
177
)
178
# Mason's CAS endpoint-- note the lack of a trailing slash... actually matters
Daniel W Bond's avatar
Daniel W Bond committed
179
CAS_SERVER_URL = 'https://login.gmu.edu'
180 181
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
182 183 184
CAS_RESPONSE_CALLBACKS = (
    'accounts.cas_callbacks.create_user',
)
185 186 187 188
# Peoplefinder API endpoint for user creation in the CAS callback (above)
PF_URL = "http://api.srct.gmu.edu/pf/v1/"
# email address used in CAS callback
ORGANIZATION_EMAIL_DOMAIN = 'masonlive.gmu.edu'
Daniel W Bond's avatar
Daniel W Bond committed
189

190
# haystack is the package used for search
Daniel W Bond's avatar
Daniel W Bond committed
191
HAYSTACK_CONNECTIONS = {
Daniel W Bond's avatar
pep8 me  
Daniel W Bond committed
192 193 194
    'default': {
        'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
        'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
Daniel W Bond's avatar
Daniel W Bond committed
195 196 197 198 199 200 201
    },
}
# Haystack Signal Processor
# The RealtimeSignalProcessor allows for objects to indexed as soon as
# they are created -- in real time.
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

202 203 204 205
# dummy cache for development-- doesn't actually cache things
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
206
    }
207
}
Daniel W Bond's avatar
Daniel W Bond committed
208

209 210 211 212 213
# configure piwik analytics
# point to the piwik url
PIWIK_DOMAIN_PATH = 'piwik.example.com'
# set piwik server site id (piwik can track multiple websites)
PIWIK_SITE_ID = 1
214 215 216

# email for the development environment
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'