· 7 years ago · Jul 12, 2018, 11:54 AM
1"""
2Django settings for spyhceplanner project.
3
4Generated by 'django-admin startproject' using Django 1.9.5.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.9/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.9/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16# PROJECT_ROOT is the root for the project folder
17import sys
18
19BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
21STATICFILES_DIRS = (
22 os.path.join(PROJECT_ROOT, 'static'),
23)
24
25# Quick-start development settings - unsuitable for production
26# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
27
28# SECURITY WARNING: keep the secret key used in production secret!
29SECRET_KEY = '77tvg-urr$e4=!o(1tr@5-rj9^8*!)lw$2-)k@4(j5rwwm&6&s'
30
31# SECURITY WARNING: don't run with debug turned on in production!
32DEBUG = True
33
34ALLOWED_HOSTS = []
35
36# Application definition
37
38DJANGO_APPS = [
39 'django.contrib.admin',
40 'django.contrib.auth',
41 'django.contrib.contenttypes',
42 'django.contrib.sessions',
43 'django.contrib.messages',
44 'django.contrib.staticfiles',
45]
46
47THIRD_PARTY_APPS = [
48 'widget_tweaks',
49 'django_nose',
50 'bootstrap3_datetime',
51 'social.apps.django_app.default',
52 'raven.contrib.django.raven_compat'
53]
54
55MY_APPS = [
56 'planner.apps.PlannerConfig',
57 'project.apps.ProjectConfig',
58 'user.apps.UserConfig',
59]
60
61INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + MY_APPS
62
63MIDDLEWARE_CLASSES = [
64 'django.middleware.security.SecurityMiddleware',
65 'django.contrib.sessions.middleware.SessionMiddleware',
66 'django.middleware.common.CommonMiddleware',
67 'django.middleware.csrf.CsrfViewMiddleware',
68 'django.contrib.auth.middleware.AuthenticationMiddleware',
69 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
70 'django.contrib.messages.middleware.MessageMiddleware',
71 'django.middleware.clickjacking.XFrameOptionsMiddleware',
72 'spyhceplanner.middleware.LoginRequiredMiddleware',
73 'spyhceplanner.middleware.PermissionMiddleware',
74 'spyhceplanner.middleware.HandleExceptionsMiddleware',
75 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware',
76]
77
78ROOT_URLCONF = 'spyhceplanner.urls'
79
80TEMPLATES = [
81 {
82 'BACKEND': 'django.template.backends.django.DjangoTemplates',
83 'DIRS': [os.path.join(PROJECT_ROOT, 'templates')],
84 'APP_DIRS': True,
85 'OPTIONS': {
86 'context_processors': [
87 'django.template.context_processors.debug',
88 'django.template.context_processors.request',
89 'django.contrib.auth.context_processors.auth',
90 'django.contrib.messages.context_processors.messages',
91 'user.context_processors.role_types.user_roles',
92 'planner.context_processors.leave_request_status.leave_status'
93 ],
94 },
95 },
96]
97
98WSGI_APPLICATION = 'spyhceplanner.wsgi.application'
99
100# Database
101# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
102DATABASES = {
103 'default': {
104 'ENGINE': 'django.db.backends.postgresql_psycopg2',
105 'NAME': 'spyhceplanner',
106 'USER': 'default',
107 'PASSWORD': 'password',
108 'HOST': 'localhost',
109 'PORT': '',
110 }
111}
112
113SOCIAL_AUTH_PIPELINE = (
114 # Checks the Google Account E-mail and sees if it belongs to the
115 # BUSINESS_DOMAIN defined in settings
116 'user.pipeline.check_domain',
117 'social.pipeline.social_auth.social_details',
118 'social.pipeline.social_auth.social_uid',
119 'social.pipeline.social_auth.auth_allowed',
120 # Checks if the current social-account is already associated in the site.
121 'social.pipeline.social_auth.social_user',
122 # Make up a username for this person, appends a random string at the end if
123 # there's any collision.
124 'social.pipeline.user.get_username',
125 # Create a user account if we haven't found one yet.
126 'social.pipeline.user.create_user',
127 'social.pipeline.social_auth.associate_user',
128 'social.pipeline.social_auth.load_extra_data',
129 'social.pipeline.user.user_details',
130)
131
132AUTHENTICATION_BACKENDS = (
133 'social.backends.google.GoogleOAuth2',
134 'django.contrib.auth.backends.ModelBackend')
135
136# Password validation
137# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
138
139AUTH_PASSWORD_VALIDATORS = [
140 {
141 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
142 },
143 {
144 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
145 },
146 {
147 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
148 },
149 {
150 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
151 },
152]
153
154# Internationalization
155# https://docs.djangoproject.com/en/1.9/topics/i18n/
156
157LANGUAGE_CODE = 'en-us'
158
159TIME_ZONE = 'UTC'
160
161USE_I18N = True
162
163USE_L10N = True
164
165USE_TZ = True
166
167# Testing
168TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
169
170NOSE_ARGS = [
171 '--with-coverage',
172 '--cover-package=planner, project, user',
173]
174
175# Static files (CSS, JavaScript, Images)
176# https://docs.djangoproject.com/en/1.9/howto/static-files/
177
178LOG_LEVEL = 'WARNING'
179
180app_logger = {
181 'handlers': ['django_log', 'console'],
182 'level': LOG_LEVEL,
183 'propagate': True,
184}
185LOGGING = {
186 'version': 1,
187 'disable_existing_loggers': False,
188 'filters': {
189 'require_debug_false': {
190 '()': 'django.utils.log.RequireDebugFalse',
191 },
192 'require_debug_true': {
193 '()': 'django.utils.log.RequireDebugTrue',
194 },
195 },
196 'formatters': {
197 'verbose': {
198 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
199 },
200 'simple': {
201 'format': '%(levelname)s %(message)s'
202 },
203 },
204 'handlers': {
205 'django_log': {
206 'level': 'DEBUG',
207 'class': 'logging.FileHandler',
208 'filename': os.path.join('/home/planneracc/django.log'),
209 'formatter': 'verbose'
210 },
211 'console': {
212 'filters': ['require_debug_true'],
213 'level': 'WARNING',
214 'class': 'logging.StreamHandler',
215 'formatter': 'simple'
216 },
217 },
218 'loggers': {
219 'py.warnings': app_logger.copy(),
220 'django': app_logger.copy(),
221 'ratelimitbackend': app_logger.copy(),
222 'middleware': app_logger.copy()
223 }
224}
225
226STATIC_URL = '/static/'
227
228AUTH_PROFILE_MODULE = 'user.UserProfile'
229
230# Login Required Middleware
231LOGIN_URL = '/user/login/'
232
233# Media related
234MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')
235MEDIA_URL = '/media/'
236
237# Miscellaneous
238MANAGEMENT_APPROVALS_NEEDED = 1
239IMAGE_EXTENSIONS = [
240 'image/JPEG',
241 'image/PNG',
242]
243BUSINESS_DOMAIN = [
244 'spyhce.com',
245]
246CALENDAR_NAME = 'spyhceplanner'
247
248# E-mail configuration
249EMAIL_HOST = 'smtp.gmail.com'
250EMAIL_PORT = 465
251EMAIL_HOST_USER = 'default@spyhce.com'
252EMAIL_HOST_PASSWORD = 'password'
253EMAIL_USE_SSL = True
254
255# Oauth2 Google Integration
256SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '111654272200-ns8odptkgb5tvqhmg2as30j2bm9i6ojd.apps.googleusercontent.com'
257SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'RbF0PFvVL6OVWmsamycSBaM-'
258SOCIAL_AUTH_LOGIN_ERROR_URL = '/'
259LOGIN_REDIRECT_URL = '/'
260
261# Base url
262BASE_URL = 'http://planner.spyhce.com'
263
264# Raven Config
265RAVEN_CONFIG = {
266 'dsn': 'https://60ddaffaba3c4543ad087d24c77c0060:6b0188fe12104f2f94e665ae0c09e12a@sentry.jibecompany.com/57',
267}
268
269# Import Local Settings
270try:
271 from .local_settings import *
272except ImportError:
273 print("No local settings file found!")
274
275# Set testing db
276if 'test' in sys.argv:
277 DATABASES['default'] = {'ENGINE': 'django.db.backends.sqlite3'}