settings.py 6.22 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        # where template files are located
        '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'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            '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',
                'django.template.context_processors.request',
            ]
        }
    }
]
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',
Daniel W Bond's avatar
Daniel W Bond committed
81
    # packages
82
83
    'crispy_forms',
    'django_gravatar',
Daniel W Bond's avatar
Daniel W Bond committed
84
    'analytical',
85
    'randomslugfield',
Daniel W Bond's avatar
Daniel W Bond committed
86
    'haystack',
87
    'multiselectfield',
88
    'rest_framework',
89
    # social media authentication
Jason D Yeomans's avatar
Jason D Yeomans committed
90
91
92
93
94
95
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',
96
    'allauth.socialaccount.providers.instagram',
97
    'allauth.socialaccount.providers.tumblr',
98
    'allauth.socialaccount.providers.github',
99
    # 'allauth.socialaccount.providers.spotify',
100
    # twitch? stackexchange? soundcloud?
101
102
)

103
104
CRISPY_TEMPLATE_PACK = 'bootstrap'

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

    'django.middleware.csrf.CsrfViewMiddleware',
113
114
115
116
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

117
ROOT_URLCONF = 'settings.urls'
118

119
WSGI_APPLICATION = 'settings.wsgi.application'
120

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

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

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

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

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

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

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

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

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

204
205
206
207
208
# 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
209
210
211

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