settings.py 6.1 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
30
31
# 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
TEMPLATE_DEBUG = True
# 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']
32

33
34
35
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
36
37
38
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
39

40
41
42
43
44
45
46
# where template files are located
TEMPLATE_DIRS = (
    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'),
)
47
48
49
50
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)
51
52
53
54
55
56
57
58
TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.request',
Jason D Yeomans's avatar
Jason D Yeomans committed
59
60
    'allauth.account.context_processors.account',
    'allauth.socialaccount.context_processors.socialaccount',
61
)
Daniel W Bond's avatar
Daniel W Bond committed
62

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

100
101
CRISPY_TEMPLATE_PACK = 'bootstrap'

102
103
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
104
    'django.contrib.sessions.middleware.SessionMiddleware',
105
    'django.contrib.auth.middleware.AuthenticationMiddleware',
Daniel W Bond's avatar
Daniel W Bond committed
106
    'cas.middleware.CASMiddleware',
107
    'django.contrib.admindocs.middleware.XViewMiddleware',
108
109

    'django.middleware.csrf.CsrfViewMiddleware',
110
111
112
113
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

114
ROOT_URLCONF = 'settings.urls'
115

116
WSGI_APPLICATION = 'settings.wsgi.application'
117

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

# Internationalization
133
# https://docs.djangoproject.com/en/1.7/topics/i18n/
134
LANGUAGE_CODE = 'en-us'
135
TIME_ZONE = 'America/New_York'
136
137
138
139
USE_I18N = True
USE_L10N = True
USE_TZ = True

140
# set for social auth
141
# example.com is by default set to 1
142
# add localhost and it will be 2
143
SITE_ID = 2
Daniel W Bond's avatar
Daniel W Bond committed
144

145
# further settings for social auth
146
# custom account adapter
147
148
SOCIALACCOUNT_ADAPTER = 'accounts.adapter.AccountAdapter'

149
# specifying what information is being requested from Facebook
150
151
152
153
154
155
156
157
158
159
160
161
SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': ['public_profile', ],
        'FIELDS': [
            'id',
            'first_name',
            'last_name',
            'link',
            ]
        }
    }

162
163
# for bootstrap css classes
MESSAGE_TAGS = {messages.ERROR: 'danger', }
164

165
# for using Mason's Central Authentication Service
Jason D Yeomans's avatar
Jason D Yeomans committed
166
AUTHENTICATION_BACKENDS = (
167
    'django.contrib.auth.backends.ModelBackend',
Daniel W Bond's avatar
Daniel W Bond committed
168
    'cas.backends.CASBackend',
Jason D Yeomans's avatar
Jason D Yeomans committed
169
)
170
# Mason's CAS endpoint-- note the lack of a trailing slash... actually matters
Daniel W Bond's avatar
Daniel W Bond committed
171
CAS_SERVER_URL = 'https://login.gmu.edu'
172
173
CAS_LOGOUT_COMPLETELY = True
CAS_PROVIDE_URL_TO_LOGOUT = True
174
175
176
CAS_RESPONSE_CALLBACKS = (
    'accounts.cas_callbacks.create_user',
)
177
178
179
180
# 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
181

182
# haystack is the package used for search
Daniel W Bond's avatar
Daniel W Bond committed
183
HAYSTACK_CONNECTIONS = {
Daniel W Bond's avatar
pep8 me    
Daniel W Bond committed
184
185
186
    '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
187
188
189
190
191
192
193
    },
}
# 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'

194
195
196
197
# dummy cache for development-- doesn't actually cache things
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
198
    }
199
}
Daniel W Bond's avatar
Daniel W Bond committed
200

201
202
203
204
205
# 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
206
207
208

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