· 4 years ago · Jun 15, 2021, 09:28 PM
1"""
2Django settings for project.
3
4For more information on this file, see
5https://docs.djangoproject.com/en/1.7/topics/settings/
6
7For the full list of settings and their values, see
8https://docs.djangoproject.com/en/1.7/ref/settings/
9"""
10
11# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12import os
13import locale
14
15BASE_DIR = os.path.dirname(os.path.dirname(__file__))
16
17SILENCED_SYSTEM_CHECKS = ['django_mysql.W003', 'django_mysql.W001', 'models.E006', 'fields.W161', 'mysql.W002']
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
23SECRET_KEY = '4@lfqhr$9c0)5t30ly4r++t7m=!!buu+zgiuer8p--kremfg@j'
24
25# Dias que es valido el token de reseteo de contraseña
26PASSWORD_RESET_TIMEOUT_DAYS = 1
27
28# SECURITY WARNING: don't run with debug turned on in production!
29DEBUG = True
30
31VERSION = os.getenv('VERSION', '1.0.1')
32
33TEMPLATES = [
34 {
35 'BACKEND': 'django.template.backends.django.DjangoTemplates',
36 'DIRS': [os.path.join(BASE_DIR, 'templates')],
37 'APP_DIRS': True,
38 'OPTIONS': {
39 'context_processors': [
40 'django.template.context_processors.debug',
41 'django.template.context_processors.request',
42 'django.contrib.auth.context_processors.auth',
43 'django.contrib.messages.context_processors.messages',
44 'django.template.context_processors.static',
45 'django.template.context_processors.media',
46 'core.views.ChangeAppearanceView.add_logo_to_context',
47 'common.views.AddUserMenuToContext.add_user_menu_to_context'
48 ],
49 'libraries': {
50 'common_filters': 'common.filters.CommonFilters',
51 'exam_filters': 'exam.filters.ExamFilters',
52 'student_exam_filters': 'exam.filters.StudentExamFilters',
53 'average_filters': 'exam.filters.AverageFilters',
54 'student_attendance_filters': 'attendance.filters.StudentAttendanceFilters',
55 },
56 'debug': DEBUG,
57 },
58 },
59]
60
61ALLOWED_HOSTS = ['127.0.0.1']
62
63# Application definition
64
65INSTALLED_APPS = (
66 'django.contrib.admin',
67 'django.contrib.auth',
68 'django.contrib.contenttypes',
69 'django.contrib.sessions',
70 'django.contrib.messages',
71 'django.contrib.staticfiles',
72 'adminlte3',
73 'adminlte3_theme',
74 'crispy_forms',
75 'django_mysql',
76 'guardian',
77 'assignment',
78 'easyaudit',
79 'app',
80 'security',
81 'common',
82 'attendance',
83 'core',
84 'exam',
85 'report',
86 'datamodel',
87 'rest_framework',
88 'polymorphic',
89 'ckeditor',
90 'import_export',
91 'import_export_data',
92 'mailbox',
93 'pwa',
94 'webpush',
95 'helpdesk',
96 'help',
97 'calendarevent',
98 'forum',
99 'filemanager',
100 'finance',
101 'wiki',
102 'hijack',
103 'compat',
104 'workflow',
105)
106
107CRISPY_TEMPLATE_PACK = 'bootstrap4'
108
109CKEDITOR_CONFIGS = {
110 'default': {
111 'toolbar': 'full',
112 'height': 300
113 },
114 'basic_ckeditor': {
115 'toolbar': [
116 {'name': 'document', 'items': ['Source']},
117 {'name': 'clipboard',
118 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo', 'Preview']},
119 {'name': 'insert',
120 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']},
121 '/',
122 {'name': 'basicstyles',
123 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
124 {'name': 'paragraph',
125 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
126 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl']},
127 {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
128 '/',
129 {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
130 {'name': 'colors', 'items': ['TextColor', 'BGColor']},
131 ]
132 },
133 'mail_ckeditor': {
134 'width': 'auto',
135 'toolbar': [
136 {'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline']},
137 {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo']},
138 {'name': 'insert',
139 'items': ['Table', 'HorizontalRule', 'Smiley']},
140 {'name': 'paragraph',
141 'items': ['NumberedList', 'BulletedList', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']},
142 {'name': 'links', 'items': ['Link']},
143 {'name': 'colors', 'items': ['TextColor', 'BGColor']},
144 '/',
145 {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
146 {'name': 'document', 'items': ['Source']},
147 ]
148 },
149}
150
151WEBPUSH_SETTINGS = {
152 "VAPID_PUBLIC_KEY": "BFQUnJqJ0qi95IJUOs-AhB5nT7WgDCo1YWgMxlRW7FuDOMUMfsHOHGP_2DpPCHVSpnSstP6j8ibZSrtQdHLunRM",
153 "VAPID_PRIVATE_KEY": "Ukr5gMkSloSfAKB9Pol4iRUWXW8a97gdzkK3LnJyX_s",
154 "VAPID_ADMIN_EMAIL": "soporte@edua.com.ar"
155}
156
157PWA_APP_NAME = 'EduAnalytica'
158PWA_APP_DESCRIPTION = "Sistema de gestión educativa"
159PWA_APP_ICONS = [
160 {'src': '/static/images/logo192.png', 'sizes': '192x192'},
161 {'src': '/static/images/logo512.png', 'sizes': '512x512'}
162]
163
164PWA_APP_SPLASH_SCREEN = [
165 {'src': '/static/images/icons/splash-640x1136.png',
166 'media': '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)'
167 }
168]
169
170# PWA_APP_THEME_COLOR = '#0A0302'
171# PWA_APP_BACKGROUND_COLOR = '#ffffff'
172# PWA_APP_DISPLAY = 'standalone'
173# PWA_APP_SCOPE = '/',
174# PWA_APP_ORIENTATION = 'any'
175# PWA_APP_START_URL = '/'
176# PWA_APP_DIR = 'ltr'
177PWA_APP_LANG = 'es-AR'
178
179AUTH_PROFILE_MODULE = 'security.models.UserProfile'
180
181MIDDLEWARE = (
182 'django.contrib.sessions.middleware.SessionMiddleware',
183 'django.middleware.common.CommonMiddleware',
184 'django.middleware.csrf.CsrfViewMiddleware',
185 'django.contrib.auth.middleware.AuthenticationMiddleware',
186 'django.contrib.messages.middleware.MessageMiddleware',
187 'django.middleware.clickjacking.XFrameOptionsMiddleware',
188 'app.middleware.SessionTimeoutMiddleware.SessionTimeoutMiddleware',
189 'easyaudit.middleware.easyaudit.EasyAuditMiddleware',
190 'django.middleware.common.BrokenLinkEmailsMiddleware',
191
192)
193
194REST_FRAMEWORK = {
195 'DEFAULT_AUTHENTICATION_CLASSES': (
196 'rest_framework.authentication.SessionAuthentication',
197 )
198}
199
200AUTHENTICATION_BACKENDS = (
201 'django.contrib.auth.backends.ModelBackend',
202 'guardian.backends.ObjectPermissionBackend',
203)
204ANONYMOUS_USER_ID = -1
205
206GUARDIAN_RENDER_403 = True
207GUARDIAN_RAISE_403 = False
208
209SESSION_EXPIRE_AT_BROWSER_CLOSE = True
210SESSION_COOKIE_AGE = 360000 # Default: 1209600 (2 weeks, in seconds)
211SESSION_EXPIRE_SECONDS = 60000
212SESSION_EXPIRE_AFTER_LAST_ACTIVITY = True
213
214ROOT_URLCONF = 'app.urls'
215WSGI_APPLICATION = 'app.wsgi.application'
216
217# Database
218# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
219
220DATABASES = {
221 'default': {
222 'ENGINE': 'django.db.backends.mysql',
223 'NAME': 'soporte_20210615',
224 'USER': 'root',
225 'PASSWORD': 'gaston22',
226 'HOST': '127.0.0.1',
227 'PORT': '3306',
228 'OPTIONS': {
229 'charset': 'utf8',
230 'init_command': 'SET foreign_key_checks = 0;',
231 },
232 },
233 'audit': {
234 'ENGINE': 'django.db.backends.mysql',
235 'NAME': 'audit',
236 'USER': 'root',
237 'PASSWORD': 'gaston22',
238 'HOST': '127.0.0.1',
239 'PORT': '3306',
240 'OPTIONS': {
241 'charset': 'utf8',
242 'init_command': 'SET foreign_key_checks = 0;',
243 },
244 }
245}
246# https://docs.djangoproject.com/en/2.1/topics/db/multi-db/
247DATABASE_ROUTERS = ['app.routers.AuditRouter']
248# AUTH_USER_MODEL
249
250# Internationalization
251# https://docs.djangoproject.com/en/1.7/topics/i18n/
252
253locale.setlocale(locale.LC_TIME, "")
254
255LANGUAGE_CODE = 'es-ar'
256
257TIME_ZONE = 'America/Argentina/Buenos_Aires'
258
259USE_I18N = True
260
261USE_L10N = True
262
263USE_TZ = True
264
265# Static files (CSS, JavaScript, Images)
266# https://docs.djangoproject.com/en/1.7/howto/static-files/
267STATIC_URL = '/static/'
268STATIC_ROOT = '/home/victoria/py/SIGE/master/edua'
269STATICFILES_DIRS = [
270 os.path.join(BASE_DIR, "static"),
271 os.path.join(BASE_DIR, "static/js"),
272 os.path.join(BASE_DIR, "static/images"),
273]
274
275PLANTILLA_BOLETINES = (BASE_DIR + '/report/boletines-templates-inputs',)
276
277# Media directory
278MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
279MEDIA_URL = '/media/'
280
281LOG_DIR = os.path.join(BASE_DIR, 'log')
282LOGGING = {
283 'version': 1,
284 'disable_existing_loggers': False,
285 'filters': {
286 'require_debug_false': {
287 '()': 'django.utils.log.RequireDebugFalse'
288 }
289 },
290 'loggers': {
291 '': {
292 'handlers': ['logfile', 'mail_admins'],
293 'level': 'ERROR',
294 'propagate': True,
295 },
296 },
297 'handlers': {
298 'mail_admins': {
299 'level': 'ERROR',
300 # 'filters': ['require_debug_false'],
301 'class': 'django.utils.log.AdminEmailHandler'
302 },
303
304 # 'mail_admins': {
305 # 'level': 'ERROR',
306 # 'class': 'django.utils.log.AdminEmailHandler',
307 # 'email_backend': 'django.core.mail.backends.smtp.EmailBackend',
308
309 # 'filters': ['require_debug_false']
310 # },
311 'null': {
312 'level': 'DEBUG',
313 'class': 'logging.NullHandler',
314 },
315 'console': {
316 'level': 'DEBUG',
317 'class': 'logging.StreamHandler',
318 'formatter': 'verbose'
319 },
320 'logfile': {
321 'level': 'DEBUG',
322 'class': 'logging.handlers.RotatingFileHandler',
323 'filename': 'log/sige.log',
324 'maxBytes': 1024 * 1024 * 5, # 5MB
325 'backupCount': 0,
326 'formatter': 'verbose',
327 },
328 },
329 'formatters': {
330 'verbose': {
331 'format': '%(levelname)s|%(asctime)s|%(module)s|%(process)d|%(thread)d|%(message)s',
332 'datefmt': "%d/%b/%Y %H:%M:%S"
333 },
334 'simple': {
335 'format': '%(levelname)s|%(message)s'
336 },
337 },
338
339}
340
341EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
342
343# EMAIL_USE_TLS = 'True'
344# EMAIL_HOST = 'mail.edua.com.ar'
345# EMAIL_PORT = 587
346# EMAIL_HOST_USER = 'soporte@edua.com.ar'
347# EMAIL_HOST_PASSWORD = 'S0p0rt3.42102856'
348# DEFAULT_FROM_EMAIL = 'soporte@edua.com.ar'
349
350
351EMAIL_USE_TLS = True
352EMAIL_HOST = 'mail.edua.com.ar'
353EMAIL_PORT = 587
354EMAIL_HOST_USER = 'fameghino@edua.com.ar'
355EMAIL_HOST_PASSWORD = 'secundaria.7728'
356DEFAULT_FROM_EMAIL = 'fameghino@edua.com.ar'
357
358# EMAIL_USE_TLS= 'True'
359# EMAIL_HOST= 'smtp.gmail.com'
360# EMAIL_PORT= 587
361# EMAIL_HOST_USER= 'victoria.costas@gmail.com'
362# EMAIL_HOST_PASSWORD= 'Colos2.2'
363# DEFAULT_FROM_EMAIL= 'victoria.costas@gmail.com'
364
365
366################################################################################
367# ----------------------------------- ADMINLTE3 ---------------------------------
368################################################################################
369# AdminLTE
370ADMINLTE_SITE_TITLE = 'Demo app'
371ADMINLTE_LEGACY_USER_MENU = True
372ADMINLTE_MESSAGES_ENABLED = True
373ADMINLTE_NOTIFICATIONS_ENABLED = True
374ADMINLTE_TASKS_ENABLED = True
375ADMINLTE_TERMS_ENDPOINT = 'blank'
376
377################################################################################
378# ----------------------------------- AUDITORIA ---------------------------------
379################################################################################
380# https://github.com/soynatan/django-easy-audit/wiki/Settings
381
382DJANGO_EASY_AUDIT_WATCH_MODEL_EVENTS = True
383# Registrar eventos relacionados con el modelo, como cuando se crea, actualiza o elimina un objeto.
384
385DJANGO_EASY_AUDIT_WATCH_AUTH_EVENTS = True
386# Registrar eventos de autenticacion de usuario (Ejlogin,logouts, login fallidos)
387
388DJANGO_EASY_AUDIT_WATCH_REQUEST_EVENTS = True
389# Registrar solicitudes de URL
390
391DJANGO_EASY_AUDIT_REGISTERED_CLASSES = []
392# Modelos a registrar
393
394# DJANGO_EASY_AUDIT_UNREGISTERED_URLS_DEFAULT
395# No registrar solicitudes a esas URLs. Default: [r'^/admin/', r'^/static/', r'^/favicon.ico$']
396
397DJANGO_EASY_AUDIT_UNREGISTERED_URLS_EXTRA = [r'^/api/', r'^/login/', r'^/logout/']
398# No registrar solicitudes a esas URLs
399
400DJANGO_EASY_AUDIT_ADMIN_SHOW_MODEL_EVENTS = False
401DJANGO_EASY_AUDIT_ADMIN_SHOW_AUTH_EVENTS = False
402DJANGO_EASY_AUDIT_ADMIN_SHOW_REQUEST_EVENTS = False
403# Registrar modelos de auditoria en el sitio de administracion de Django
404# Registrar modelos de auditoria en el sitio de administracion de Django
405#
406# CACHES = {
407# 'default': {
408# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
409# 'LOCATION': '127.0.0.1:11211',
410# 'OPTIONS': {
411# 'server_max_value_length': 1024 * 1024 * 2,
412# }
413# }
414# }
415
416# INICIAR SESSION COMO UN USUARIO
417HIJACK_LOGIN_REDIRECT_URL = '/' # donde se redirige al usuario después de iniciar sesión como otro
418HIJACK_LOGOUT_REDIRECT_URL = '/' # donde se redirige cuando se vuelve al usuario original
419HIJACK_USE_BOOTSTRAP = True
420HIJACK_DECORATOR = "django.contrib.auth.decorators.login_required"
421HIJACK_AUTHORIZATION_CHECK = 'app.permissions.check_hijack_guardian_check'
422
423
424
425