settings.py 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. """
  2. Django settings for gestion_reservas project.
  3. Generated by 'django-admin startproject' using Django 5.1.1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/5.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/5.1/ref/settings/
  8. """
  9. from pathlib import Path
  10. import os
  11. import logging
  12. APP_NAME = "jugaralpadel.es"
  13. APP_VERSION = os.environ.get("APP_VERSION", "30.0.0") # Valor por defecto si no está definido
  14. IMG_VERSION = os.environ.get("IMG_VERSION", "0.0.0-dev") # Valor por defecto si no está definido
  15. MES_COMIENZO_TEMPORADA = int(os.getenv('MES_COMIENZO_TEMPORADA', '9')) # valor por defecto: septiembre
  16. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  17. BASE_DIR = Path(__file__).resolve().parent.parent
  18. # Quick-start development settings - unsuitable for production
  19. # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
  20. # SECURITY WARNING: keep the secret key used in production secret!
  21. SECRET_KEY = 'hey'
  22. # SECURITY WARNING: don't run with debug turned on in production!
  23. DEBUG = os.environ.get('DEBUG', 'False') == 'True'
  24. LOCAL = os.environ.get('LOCAL', 'False') == 'True'
  25. # hosts permitidos
  26. ALLOWED_HOSTS = [".vmcluster.lab", "jugaralpadel.es", ".reymota.es"]
  27. CSRF_TRUSTED_ORIGINS = ["http://jugaralpadel.vmcluster.lab", "https://*.vmcluster.lab", "https://jugaralpadel.es", "https://*.reymota.es"]
  28. # Application definition
  29. INSTALLED_APPS = [
  30. 'django.contrib.admin',
  31. 'django.contrib.auth',
  32. 'django.contrib.contenttypes',
  33. 'django.contrib.sessions',
  34. 'django.contrib.messages',
  35. 'django.contrib.staticfiles',
  36. 'eventos',
  37. 'accounts',
  38. 'gestion_reservas',
  39. 'reymotausers',
  40. 'rest_framework',
  41. 'tinymce',
  42. ]
  43. MIDDLEWARE = [
  44. 'django.middleware.security.SecurityMiddleware',
  45. 'django.contrib.sessions.middleware.SessionMiddleware',
  46. 'django.middleware.common.CommonMiddleware',
  47. 'django.middleware.csrf.CsrfViewMiddleware',
  48. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  49. 'django.contrib.messages.middleware.MessageMiddleware',
  50. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  51. 'whitenoise.middleware.WhiteNoiseMiddleware',
  52. ]
  53. ROOT_URLCONF = 'gestion_reservas.urls'
  54. TEMPLATES = [
  55. {
  56. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  57. 'DIRS': [BASE_DIR / 'templates'],
  58. 'APP_DIRS': True,
  59. 'OPTIONS': {
  60. 'context_processors': [
  61. 'django.template.context_processors.debug',
  62. 'django.template.context_processors.request',
  63. 'django.contrib.auth.context_processors.auth',
  64. 'django.contrib.messages.context_processors.messages',
  65. 'gestion_reservas.context_processors.app_version',
  66. 'gestion_reservas.context_processors.debug',
  67. ],
  68. 'libraries': {
  69. 'filtros_de_entorno': 'gestion_reservas.templatetags.filtros_de_entorno',
  70. }
  71. },
  72. },
  73. ]
  74. WSGI_APPLICATION = 'gestion_reservas.wsgi.application'
  75. # Database
  76. # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
  77. DATABASES = {
  78. 'default': {
  79. "ENGINE": "django.db.backends.postgresql",
  80. "NAME": "jugaralpadel",
  81. "USER": "creylopez",
  82. "PASSWORD": "Dsa-0213",
  83. "HOST": os.environ.get('SQL_HOST','postgres-cluster-rw.reymota-pg-cluster.svc.cluster.local'),
  84. "PORT": "5432",
  85. }
  86. }
  87. # Password validation
  88. # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
  89. AUTH_PASSWORD_VALIDATORS = [
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  95. },
  96. {
  97. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  98. },
  99. {
  100. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  101. },
  102. ]
  103. # Internationalization
  104. # https://docs.djangoproject.com/en/5.1/topics/i18n/
  105. LANGUAGE_CODE = 'es-es'
  106. TIME_ZONE = 'Europe/Madrid'
  107. USE_I18N = True
  108. USE_TZ = True
  109. I18N = True
  110. L10N = True
  111. DECIMAL_SEPARATOR = ','
  112. THOUSAND_SEPARATOR = '.'
  113. # Static files (CSS, JavaScript, Images)
  114. # https://docs.djangoproject.com/en/5.1/howto/static-files/
  115. STATIC_URL = 'static/'
  116. STATIC_ROOT = BASE_DIR / "staticfiles"
  117. # STATICFILES_DIRS = [BASE_DIR / "eventos/static",]
  118. STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
  119. # Mediafiles
  120. MEDIA_ROOT = BASE_DIR / 'mediafiles'
  121. MEDIA_URL = '/media/'
  122. # Default primary key field type
  123. # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
  124. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  125. LOGIN_URL = '/accounts/login/'
  126. LOGIN_REDIRECT_URL = 'principal'
  127. LOGOUT_REDIRECT_URL = 'principal'
  128. AUTH_USER_MODEL = "reymotausers.ReyMotaUser"
  129. # Configuración de correo con Gmail
  130. if DEBUG is True:
  131. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  132. else:
  133. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  134. EMAIL_HOST = 'smtp.gmail.com'
  135. EMAIL_PORT = 587
  136. EMAIL_USE_TLS = True
  137. EMAIL_HOST_USER = 'jugaralpadelentreamigos@gmail.com'
  138. EMAIL_HOST_PASSWORD = 'btjnlcliimxcnmhi' # Es mejor usar una contraseña de aplicación de Google
  139. DEFAULT_FROM_EMAIL = 'jugaralpadelentreamigos@gmail.com'
  140. # Dirección del administrador
  141. # ADMIN_EMAIL = 'king.bernard.b@gmail.com'
  142. #ADMIN_EMAIL = 'padelycervezas1974@gmail.com'
  143. ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL', 'celestino.rey@gmail.com')
  144. # El tiempo de validez del enlace para resetear la contraseña (por defecto es de 3 días)
  145. PASSWORD_RESET_TIMEOUT = 86400 # 1 día en segundos
  146. LOGGING = {
  147. 'version': 1,
  148. 'disable_existing_loggers': False,
  149. 'formatters': {
  150. 'verbose': {
  151. 'format': '{levelname} {asctime} {module} {message}',
  152. 'style': '{',
  153. },
  154. 'simple': {
  155. 'format': '{levelname} {message}',
  156. 'style': '{',
  157. },
  158. },
  159. 'handlers': {
  160. 'console': {
  161. 'level': 'DEBUG',
  162. 'class': 'logging.StreamHandler',
  163. 'formatter': 'simple',
  164. },
  165. 'file': {
  166. 'level': 'DEBUG',
  167. 'class': 'logging.FileHandler',
  168. 'filename': '/dev/null',
  169. 'formatter': 'verbose',
  170. },
  171. 'mail_admins': {
  172. 'level': 'ERROR',
  173. 'class': 'django.utils.log.AdminEmailHandler',
  174. },
  175. },
  176. 'loggers': {
  177. 'django': {
  178. 'handlers': ['file'],
  179. 'level': 'DEBUG',
  180. 'propagate': True,
  181. },
  182. 'eventos': {
  183. 'handlers': ['console', 'file'],
  184. 'level': 'DEBUG',
  185. 'propagate': True,
  186. },
  187. 'gestion_reservas': {
  188. 'handlers': ['console', 'file'],
  189. 'level': 'DEBUG',
  190. 'propagate': False,
  191. },
  192. 'django.request': {
  193. 'handlers': ['mail_admins'],
  194. 'level': 'ERROR',
  195. 'propagate': False,
  196. },
  197. },
  198. }
  199. TINYMCE_DEFAULT_CONFIG = {
  200. 'height': 360,
  201. 'width': 1120,
  202. 'cleanup_on_startup': True,
  203. 'custom_undo_redo_levels': 20,
  204. 'selector': 'textarea',
  205. 'plugins': '''
  206. textcolor save link image media preview codesample contextmenu
  207. table code lists fullscreen insertdatetime nonbreaking
  208. contextmenu directionality searchreplace wordcount visualblocks
  209. visualchars code fullscreen autolink lists charmap print hr
  210. anchor pagebreak
  211. ''',
  212. 'toolbar1': '''
  213. fullscreen preview bold italic underline | fontselect,
  214. fontsizeselect | forecolor backcolor | alignleft alignright |
  215. aligncenter alignjustify | indent outdent | bullist numlist table |
  216. ''',
  217. 'contextmenu': 'formats | link image',
  218. 'menubar': True,
  219. 'statusbar': True,
  220. 'promotion': False,
  221. }