settings.py
9.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
"""
Django settings for amadeus project.
Generated by 'django-admin startproject' using Django 1.9.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
import dj_database_url
from django.conf.global_settings import DATETIME_INPUT_FORMATS, DATE_INPUT_FORMATS
from django.utils.translation import ugettext_lazy as _
db_from_ev = dj_database_url.config(conn_max_age=500)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '$=8)c!5)iha85a&8q4+kv1pyg0yl7_xe_x^z=2cn_1d7r0hny4'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'widget_tweaks',
'rolepermissions',
'oauth2_provider',
'rest_framework',
'django_bootstrap_breadcrumbs',
's3direct',
'django_summernote',
'session_security',
'django_crontab',
'django_cron',
'channels',
'resubmit', # Utilizado para salvar arquivos na cache, para caso o formulario não seja preenchido corretamente o usuário não precise fazer o upload outra vez dos arquivos
'amadeus',
'users',
'notifications',
'log',
'categories',
'subjects',
'students_group',
'topics',
'pendencies',
'mural',
'chat',
'file_link',
'goals',
'pdf_file',
'links',
'webpage',
'youtube_video',
'mailsender',
'security',
'themes',
'api',
'reports',
'webconference',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'users.middleware.SessionExpireMiddleware',
'session_security.middleware.SessionSecurityMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'log.middleware.TimeSpentMiddleware',
#libs-middleware
]
ROOT_URLCONF = 'amadeus.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'amadeus.context_processors.theme',
'amadeus.context_processors.notifies',
'amadeus.context_processors.mural_notifies',
'amadeus.context_processors.chat_notifies',
],
},
},
]
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
"resubmit": {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
"LOCATION": os.path.join(BASE_DIR, 'data/cache/resubmit'),
},
}
WSGI_APPLICATION = 'amadeus.wsgi.application'
SESSION_SECURITY_WARN_AFTER = 1140
SESSION_SECURITY_EXPIRE_AFTER = 1200
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
# Database
# https://docs.djangopr/*oject.com/en/1.9/ref/settings/#databases
DATABASES = { 'default': db_from_ev,
}
#superuser: admin pass: amadeus2358
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'pt-br'
LANGUAGES = [
('pt-br', _('Portuguese')),
('en', _('English')),
]
TIME_ZONE = 'America/Recife'
USE_I18N = True
USE_L10N = True
USE_TZ = True
FORMAT_MODULE_PATH = 'amadeus.formats'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
#Static files heroku
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "amadeus/static")
]
CRON_CLASSES = [
'notifications.cron.Notify',
'goals.cron.SetGoals'
]
CRONJOBS = [
('1 */12 * * *', 'notifications.cron.notification_cron'),
('1 */12 * * *', 'goals.cron.setgoals_cron')
]
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgiref.inmemory.ChannelLayer",
"ROUTING": "amadeus.routing.channel_routing",
},
}
#SECURITY
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https')
#Allow all host headers
ALLOWED_HOSTS = ['*']
# Files
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'uploads')
MEDIA_URL = '/uploads/'
# Users
LOGIN_REDIRECT_URL = 'app:index'
LOGIN_URL = 'core:home'
AUTH_USER_MODEL = 'users.User'
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]
ROLEPERMISSIONS_MODULE = 'amadeus.roles'
LOGS_URL = 'logs/'
#https://github.com/squ1b3r/Djaneiro
# E-mail
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# DEFAULT_FROM_EMAIL = 'admin@amadeus.com.br'
# Messages
from django.contrib.messages import constants as messages_constants
MESSAGE_TAGS = {
messages_constants.DEBUG: 'debug',
messages_constants.INFO: 'info',
messages_constants.SUCCESS: 'success',
messages_constants.WARNING: 'warning',
messages_constants.ERROR: 'danger',
}
#Send email for forgot Password
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'amadeusteste@gmail.com'
# SERVER_EMAIL = 'amadeusteste@gmail.com'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'amadeusteste@gmail.com'
EMAIL_HOST_PASSWORD = 'amadeusteste'
# SMTP CONFIG
# EMAIL_BACKEND = 'core.smtp.AmadeusEmailBackend'
#API CONFIG STARTS
#TELL the rest framework to use a different backend
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':(
'oauth2_provider.ext.rest_framework.OAuth2Authentication',),
'DEFAULT_PERMISSION_CLASSES':(
'rest_framework.permissions.IsAuthenticated',),
'PAGE_SIZE': 10, #pagination purposes
}
OAUTH2_PROVIDER = {
'SCOPES':{'read':'Read scope', 'write': 'Write scope'}
}
#API CONFIG ENDS
#For date purposes
DATE_INPUT_FORMATS.append('%d/%m/%y')
DATE_INPUT_FORMATS.append('%m/%d/%y')
#s3direct
# AWS keys
AWS_SECRET_ACCESS_KEY = ''
AWS_ACCESS_KEY_ID = ''
AWS_STORAGE_BUCKET_NAME = ''
S3DIRECT_REGION = 'sa-east-1'
from uuid import uuid4
S3DIRECT_DESTINATIONS = {
# Specify a non-default bucket for PDFs
'material': (lambda original_filename: 'uploads/material/'+str(uuid4())+'.pdf', lambda u: True, ['application/pdf']),
}
#API CONFIG STARTS
#TELL the rest framework to use a different backend
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':(
'oauth2_provider.ext.rest_framework.OAuth2Authentication',),
'DEFAULT_PERMISSION_CLASSES':(
'rest_framework.permissions.IsAuthenticated',),
'PAGE_SIZE': 10, #pagination purposes
}
OAUTH2_PROVIDER = {
'SCOPES':{'read':'Read scope', 'write': 'Write scope'}
}
#API CONFIG ENDS
# FILE UPLOAD
MAX_UPLOAD_SIZE = 10485760
SUMMERNOTE_CONFIG = {
# Using SummernoteWidget - iframe mode
'iframe': True, # or set False to use SummernoteInplaceWidget - no iframe mode
# Using Summernote Air-mode
'airMode': False,
# Use native HTML tags (`<b>`, `<i>`, ...) instead of style attributes
# (Firefox, Chrome only)
'styleWithTags': True,
# Set text direction : 'left to right' is default.
'direction': 'ltr',
# Change editor size
'width': '100%',
'height': '300',
# Use proper language setting automatically (default)
'lang': None,
# Or, set editor language/locale forcely
'lang_matches': {
'pt': 'pt-BR',
},
# Customize toolbar buttons
'toolbar': [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'superscript', 'subscript',
'strikethrough', 'clear']],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'video', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']],
],
# Need authentication while uploading attachments.
'attachment_require_authentication': True,
# Set `upload_to` function for attachments.
#'attachment_upload_to': my_custom_upload_to_func(),
}
try:
from .local_settings import *
except ImportError:
pass