No Description

settings.py 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. """
  2. Django settings for network_report project.
  3. Generated by 'django-admin startproject' using Django 4.1.5.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/4.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/4.1/ref/settings/
  8. """
  9. from pathlib import Path
  10. import os
  11. import os
  12. import environ
  13. from pprint import pprint
  14. import django
  15. from django.utils.encoding import smart_str
  16. django.utils.encoding.smart_text = smart_str
  17. env = environ.Env()
  18. environ.Env.read_env()
  19. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  20. BASE_DIR = Path(__file__).resolve().parent.parent
  21. from celery.schedules import crontab
  22. # Quick-start development settings - unsuitable for production
  23. # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
  24. # SECURITY WARNING: keep the secret key used in production secret!
  25. SECRET_KEY = 'django-insecure-e197skh+hf2!q)k&z9a*=#_mnr4y(+x@i856z76oxpz!19%3u='
  26. # SECURITY WARNING: don't run with debug turned on in production!
  27. DEBUG = True
  28. mode = os.getenv('MODE')
  29. pprint(f"==== {mode} ====")
  30. if mode == "dev" or mode == "":
  31. DEBUG = True
  32. else:
  33. DEBUG = False
  34. ALLOWED_HOSTS = ['*']
  35. # Application definition
  36. INSTALLED_APPS = [
  37. 'django.contrib.admin',
  38. 'django.contrib.auth',
  39. 'django.contrib.contenttypes',
  40. 'django.contrib.sessions',
  41. 'django.contrib.messages',
  42. 'django.contrib.staticfiles',
  43. 'django.contrib.humanize',
  44. 'django.contrib.postgres',
  45. 'crispy_forms',
  46. "crispy_bootstrap5",
  47. # "django_browser_reload",
  48. 'widget_tweaks',
  49. 'django_bootstrap_breadcrumbs',
  50. 'django_filters',
  51. 'django_yarnpkg',
  52. 'backend.apps.BackendConfig',
  53. ]
  54. MIDDLEWARE = [
  55. 'django.middleware.security.SecurityMiddleware',
  56. 'django.contrib.sessions.middleware.SessionMiddleware',
  57. 'django.middleware.common.CommonMiddleware',
  58. 'django.middleware.csrf.CsrfViewMiddleware',
  59. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  60. 'django.contrib.messages.middleware.MessageMiddleware',
  61. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  62. # "django_browser_reload.middleware.BrowserReloadMiddleware",
  63. ]
  64. ROOT_URLCONF = 'network_report.urls'
  65. TEMPLATES = [
  66. {
  67. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  68. 'DIRS': [os.path.join(BASE_DIR,'templates')],
  69. 'APP_DIRS': True,
  70. 'OPTIONS': {
  71. 'context_processors': [
  72. 'django.template.context_processors.debug',
  73. 'django.template.context_processors.request',
  74. 'django.contrib.auth.context_processors.auth',
  75. 'django.contrib.messages.context_processors.messages',
  76. 'backend.context_processors.network_report',
  77. ],
  78. },
  79. },
  80. ]
  81. WSGI_APPLICATION = 'network_report.wsgi.application'
  82. # Database
  83. # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
  84. DATABASES = {
  85. 'default': {
  86. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  87. 'NAME': env("POSTGRES_NAME"),
  88. 'USER': env("POSTGRES_USER"),
  89. 'PASSWORD': env("POSTGRES_PASSWORD"),
  90. 'HOST': 'db',
  91. 'PORT': '5432',
  92. }
  93. }
  94. # Password validation
  95. # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
  96. AUTH_PASSWORD_VALIDATORS = [
  97. {
  98. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  99. },
  100. {
  101. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  102. },
  103. {
  104. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  105. },
  106. {
  107. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  108. },
  109. ]
  110. # Internationalization
  111. # https://docs.djangoproject.com/en/4.1/topics/i18n/
  112. LANGUAGE_CODE = 'en-us'
  113. TIME_ZONE = 'UTC'
  114. USE_I18N = True
  115. USE_TZ = True
  116. # Static files (CSS, JavaScript, Images)
  117. # https://docs.djangoproject.com/en/4.1/howto/static-files/
  118. STATIC_URL = 'static/'
  119. # Default primary key field type
  120. # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
  121. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  122. MEDIA_URL = '/media/'
  123. MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  124. CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
  125. CRISPY_TEMPLATE_PACK = "bootstrap5"
  126. STATICFILES_DIRS = [
  127. BASE_DIR / "static",
  128. ]
  129. STATIC_ROOT = BASE_DIR / 'staticfiles'
  130. STATICFILES_FINDERS = [
  131. 'django.contrib.staticfiles.finders.FileSystemFinder',
  132. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  133. 'django_yarnpkg.finders.NodeModulesFinder',
  134. 'compressor.finders.CompressorFinder'
  135. ]
  136. YARN_INSTALLED_APPS = (
  137. 'bootstrap@^5.0',
  138. 'underscore@^1.6.1',
  139. 'alpinejs@^3.10.5',
  140. 'axios@^1.2.2',
  141. 'tailwindcss@^3.2.4',
  142. 'sortablejs@^1.1.5',
  143. 'chart.js@^4.1.1',
  144. 'datatables.net-bs5',
  145. 'lightbox2',
  146. 'granim',
  147. 'slick-carousel',
  148. 'mjml',
  149. 'tailwind-color-palette',
  150. 'paper-css'
  151. )
  152. CELERY_BEAT_SCHEDULE = {
  153. # "dumpapi": {
  154. # "task": "backend.views.dump_api_task",
  155. # #"schedule": crontab(minute="*/1"),
  156. # # "schedule": crontab(minute="*/30"),
  157. # # "schedule": crontab(hour="17", minute="15"),
  158. # "schedule": crontab(minute="*/3", hour="17-21"),
  159. # },
  160. "mikro_dump": {
  161. "task": "backend.views.mikro_dump_task",
  162. "schedule": crontab(minute="*/3"),
  163. },
  164. "gen_report": {
  165. "task": "backend.views.gen_report_task",
  166. "schedule": crontab(hour="12,22", minute="15"),
  167. },
  168. }