settings.py 6.38 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
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
43
            # where template files are located
44 45 46 47 48 49 50 51 52
            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'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
53 54 55 56 57
                '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',
58 59
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.request',
60 61
            ],
            'debug': DEBUG,
62 63 64
        }
    }
]
Daniel W Bond's avatar
Daniel W Bond committed
65

66 67 68 69 70 71 72 73
# 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
74
    'django.contrib.sites',
75
    'django.contrib.humanize',
Daniel W Bond's avatar
Daniel W Bond committed
76
    # apps
77
    'api',
78
    'housing',
79
    'accounts',
Daniel W Bond's avatar
Daniel W Bond committed
80
    'welcome',
81
    'core',
Daniel W Bond's avatar
Daniel W Bond committed
82
    # packages
83 84
    'analytical',
    'cas',
85 86
    'crispy_forms',
    'django_gravatar',
Daniel W Bond's avatar
Daniel W Bond committed
87
    'haystack',
88
    'multiselectfield',
89
    'randomslugfield',
90
    'rest_framework',
91
    # social media authentication
Jason D Yeomans's avatar
Jason D Yeomans committed
92 93 94 95 96 97
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',
98
    'allauth.socialaccount.providers.instagram',
99
    'allauth.socialaccount.providers.tumblr',
100
    'allauth.socialaccount.providers.github',
101 102
    'allauth.socialaccount.providers.pinterest',
    'allauth.socialaccount.providers.spotify',
103
    # twitch? stackexchange? soundcloud?
104 105
)

106 107
CRISPY_TEMPLATE_PACK = 'bootstrap'

108 109
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
110
    'django.contrib.sessions.middleware.SessionMiddleware',
111
    'django.contrib.auth.middleware.AuthenticationMiddleware',
Daniel W Bond's avatar
Daniel W Bond committed
112
    'cas.middleware.CASMiddleware',
113
    'django.contrib.admindocs.middleware.XViewMiddleware',
114
    'django.middleware.csrf.CsrfViewMiddleware',
115 116
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
117
    'settings.views.BlockingMiddleware',
118 119
)

120
ROOT_URLCONF = 'settings.urls'
121

122
WSGI_APPLICATION = 'settings.wsgi.application'
123

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

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

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

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

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

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

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

188
# haystack is the package used for search
Daniel W Bond's avatar
Daniel W Bond committed
189
HAYSTACK_CONNECTIONS = {
Daniel W Bond's avatar
pep8 me  
Daniel W Bond committed
190 191 192
    '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
193 194 195 196 197 198 199
    },
}
# 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'

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

207 208 209 210 211
# 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
212 213 214

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