settings.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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", "15.0.5") # 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. OPENSHIFT = os.environ.get('OPENSHIFT', 'False') == 'True'
  25. LOCAL = os.environ.get('LOCAL', 'False') == 'True'
  26. ALLOWED_HOSTS = [".ocp-cluster.reymota.lab", "jugaralpadel.rancher.reymota.lab", "jugaralpadel.es", ".reymota.es"]
  27. CSRF_TRUSTED_ORIGINS = ["https://*.ocp-cluster.reymota.lab", "http://jugaralpadel.rancher.reymota.lab", "https://jugaralpadel.rancher.reymota.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. 'gestion_reservas',
  38. 'reymotausers',
  39. 'rest_framework',
  40. ]
  41. MIDDLEWARE = [
  42. 'django.middleware.security.SecurityMiddleware',
  43. 'django.contrib.sessions.middleware.SessionMiddleware',
  44. 'django.middleware.common.CommonMiddleware',
  45. 'django.middleware.csrf.CsrfViewMiddleware',
  46. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  47. 'django.contrib.messages.middleware.MessageMiddleware',
  48. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  49. ]
  50. ROOT_URLCONF = 'gestion_reservas.urls'
  51. TEMPLATES = [
  52. {
  53. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  54. 'DIRS': [BASE_DIR / 'templates'],
  55. 'APP_DIRS': True,
  56. 'OPTIONS': {
  57. 'context_processors': [
  58. 'django.template.context_processors.debug',
  59. 'django.template.context_processors.request',
  60. 'django.contrib.auth.context_processors.auth',
  61. 'django.contrib.messages.context_processors.messages',
  62. 'gestion_reservas.context_processors.app_version',
  63. ],
  64. 'libraries': {
  65. 'filtros_de_entorno': 'gestion_reservas.templatetags.filtros_de_entorno',
  66. }
  67. },
  68. },
  69. ]
  70. WSGI_APPLICATION = 'gestion_reservas.wsgi.application'
  71. # Database
  72. # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
  73. if LOCAL is False:
  74. DATABASES = {
  75. "default": {
  76. "ENGINE": "django.db.backends.postgresql",
  77. "NAME": "jugaralpadel",
  78. "USER": "creylopez",
  79. "PASSWORD": "Dsa-0213",
  80. "HOST": "postgresql",
  81. "PORT": "5432",
  82. }
  83. }
  84. else:
  85. DATABASES = {
  86. 'default': {
  87. "ENGINE": "django.db.backends.sqlite3",
  88. "NAME": BASE_DIR / "db.sqlite3",
  89. }
  90. }
  91. # Password validation
  92. # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
  93. AUTH_PASSWORD_VALIDATORS = [
  94. {
  95. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  96. },
  97. {
  98. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  99. },
  100. {
  101. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  102. },
  103. {
  104. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  105. },
  106. ]
  107. # Internationalization
  108. # https://docs.djangoproject.com/en/5.1/topics/i18n/
  109. LANGUAGE_CODE = 'es-es'
  110. TIME_ZONE = 'Europe/Madrid'
  111. USE_I18N = True
  112. USE_TZ = True
  113. I18N = True
  114. L10N = True
  115. DECIMAL_SEPARATOR = ','
  116. THOUSAND_SEPARATOR = '.'
  117. # Static files (CSS, JavaScript, Images)
  118. # https://docs.djangoproject.com/en/5.1/howto/static-files/
  119. STATIC_URL = 'static/'
  120. STATIC_ROOT = BASE_DIR / "staticfiles"
  121. # STATICFILES_DIRS = [BASE_DIR / "eventos/static",]
  122. # Mediafiles
  123. MEDIA_ROOT = BASE_DIR / "mediafiles"
  124. MEDIA_URL = '/media/'
  125. # Default primary key field type
  126. # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
  127. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  128. LOGIN_URL = '/accounts/login/'
  129. LOGIN_REDIRECT_URL = 'principal'
  130. LOGOUT_REDIRECT_URL = 'principal'
  131. AUTH_USER_MODEL = "reymotausers.ReyMotaUser"
  132. # Configuración de correo con Gmail
  133. if DEBUG is True:
  134. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  135. else:
  136. EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
  137. EMAIL_HOST = 'smtp.gmail.com'
  138. EMAIL_PORT = 587
  139. EMAIL_USE_TLS = True
  140. EMAIL_HOST_USER = 'jugaralpadelentreamigos@gmail.com'
  141. EMAIL_HOST_PASSWORD = 'btjnlcliimxcnmhi' # Es mejor usar una contraseña de aplicación de Google
  142. DEFAULT_FROM_EMAIL = 'jugaralpadelentreamigos@gmail.com'
  143. # Dirección del administrador
  144. # ADMIN_EMAIL = 'king.bernard.b@gmail.com'
  145. ADMIN_EMAIL = ''
  146. # El tiempo de validez del enlace para resetear la contraseña (por defecto es de 3 días)
  147. PASSWORD_RESET_TIMEOUT = 86400 # 1 día en segundos
  148. LOGGING = {
  149. 'version': 1,
  150. 'disable_existing_loggers': False,
  151. 'formatters': {
  152. 'verbose': {
  153. 'format': '{levelname} {asctime} {module} {message}',
  154. 'style': '{',
  155. },
  156. 'simple': {
  157. 'format': '{levelname} {message}',
  158. 'style': '{',
  159. },
  160. },
  161. 'handlers': {
  162. 'console': {
  163. 'level': 'DEBUG',
  164. 'class': 'logging.StreamHandler',
  165. 'formatter': 'simple',
  166. },
  167. 'file': {
  168. 'level': 'DEBUG',
  169. 'class': 'logging.FileHandler',
  170. 'filename': '/dev/null',
  171. 'formatter': 'verbose',
  172. },
  173. 'mail_admins': {
  174. 'level': 'ERROR',
  175. 'class': 'django.utils.log.AdminEmailHandler',
  176. },
  177. },
  178. 'loggers': {
  179. 'django': {
  180. 'handlers': ['file'],
  181. 'level': 'DEBUG',
  182. 'propagate': True,
  183. },
  184. 'eventos': {
  185. 'handlers': ['console', 'file'],
  186. 'level': 'DEBUG',
  187. 'propagate': False,
  188. },
  189. 'gestion_reservas': {
  190. 'handlers': ['console', 'file'],
  191. 'level': 'DEBUG',
  192. 'propagate': False,
  193. },
  194. 'django.request': {
  195. 'handlers': ['mail_admins'],
  196. 'level': 'ERROR',
  197. 'propagate': False,
  198. },
  199. },
  200. }