settings.py 6.11 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',
78
    'core',
Daniel W Bond's avatar
Daniel W Bond committed
79
    # packages
80
81
    'crispy_forms',
    'django_gravatar',
Daniel W Bond's avatar
Daniel W Bond committed
82
    'analytical',
83
    'randomslugfield',
Daniel W Bond's avatar
Daniel W Bond committed
84
    'haystack',
85
    'multiselectfield',
86
    'rest_framework',
87
    # social media authentication
Jason D Yeomans's avatar
Jason D Yeomans committed
88
89
90
91
92
93
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',
94
    'allauth.socialaccount.providers.instagram',
95
    'allauth.socialaccount.providers.tumblr',
96
    'allauth.socialaccount.providers.github',
97
    # 'allauth.socialaccount.providers.spotify',
98
    # twitch? stackexchange? soundcloud?
99
100
)

101
102
CRISPY_TEMPLATE_PACK = 'bootstrap'

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

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

115
ROOT_URLCONF = 'settings.urls'
116

117
WSGI_APPLICATION = 'settings.wsgi.application'
118

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

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

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

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

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

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

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

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

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

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

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