2022-08-26 17:00:34 +03:00
|
|
|
import environ
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
|
|
|
|
|
2022-08-27 10:16:21 +03:00
|
|
|
AI_URL = "http://109.248.175.223:5000/api"
|
2022-08-26 23:18:02 +03:00
|
|
|
# AI_URL = "http://127.0.0.1:5000"
|
|
|
|
|
2022-08-26 17:00:34 +03:00
|
|
|
APPS_DIR = ROOT_DIR
|
|
|
|
env = environ.Env()
|
|
|
|
|
|
|
|
env.read_env(str(APPS_DIR / "conf" / ".env" / ".django"))
|
|
|
|
env.read_env(str(APPS_DIR / "conf" / ".env" / ".postgresql"))
|
|
|
|
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
|
|
|
DEBUG = env.bool("DJANGO_DEBUG", True)
|
|
|
|
|
|
|
|
TIME_ZONE = "Europe/Moscow"
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
|
|
|
SITE_ID = 1
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
|
|
|
USE_I18N = True
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
|
|
|
USE_TZ = True
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths
|
|
|
|
LOCALE_PATHS = [str(APPS_DIR / "locale")]
|
|
|
|
|
|
|
|
# DATABASES
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
|
|
|
DATABASES = {
|
2022-08-27 19:20:20 +03:00
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
|
|
'NAME': 'postgres',
|
|
|
|
'USER': 'postgres',
|
|
|
|
'PASSWORD': 'postgres',
|
|
|
|
'HOST': 'db',
|
|
|
|
'PORT': 5432,
|
|
|
|
}
|
2022-08-26 17:00:34 +03:00
|
|
|
}
|
|
|
|
|
2022-08-27 19:20:20 +03:00
|
|
|
|
2022-08-26 17:00:34 +03:00
|
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
|
|
|
|
# URLS
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
|
|
|
|
ROOT_URLCONF = "conf.urls"
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
|
|
|
WSGI_APPLICATION = "conf.wsgi.application"
|
|
|
|
|
|
|
|
# APPS
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
DJANGO_APPS = [
|
|
|
|
"django.contrib.auth",
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
"django.contrib.sessions",
|
|
|
|
"django.contrib.sites",
|
|
|
|
"django.contrib.messages",
|
|
|
|
"django.contrib.staticfiles",
|
|
|
|
"django.contrib.admin",
|
|
|
|
]
|
|
|
|
THIRD_PARTY_APPS = [
|
|
|
|
"rest_framework",
|
|
|
|
"drf_yasg",
|
|
|
|
"corsheaders",
|
2022-08-27 10:16:21 +03:00
|
|
|
"django_celery_results",
|
2022-08-26 17:00:34 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
HEALTH_CHECKS = [
|
|
|
|
"health_check", # required
|
|
|
|
"health_check.db", # stock Django health checkers
|
|
|
|
"health_check.cache",
|
|
|
|
"health_check.storage",
|
|
|
|
# 'health_check.contrib.celery',
|
|
|
|
# 'health_check.contrib.celery_ping',
|
|
|
|
"health_check.contrib.migrations",
|
|
|
|
"health_check.contrib.psutil", # disk and memory utilization
|
|
|
|
]
|
|
|
|
|
|
|
|
LOCAL_APPS = ["checker"]
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + HEALTH_CHECKS + LOCAL_APPS
|
|
|
|
|
|
|
|
# PASSWORDS
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/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",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# MIDDLEWARE
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
|
|
|
|
MIDDLEWARE = [
|
|
|
|
"django.middleware.security.SecurityMiddleware",
|
|
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
|
|
"django.middleware.locale.LocaleMiddleware",
|
|
|
|
"django.middleware.common.CommonMiddleware",
|
|
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
|
|
"django.middleware.common.BrokenLinkEmailsMiddleware",
|
|
|
|
]
|
|
|
|
|
|
|
|
# TEMPLATES
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#dirs
|
|
|
|
"DIRS": [APPS_DIR / "templates"],
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#app-dirs
|
|
|
|
"APP_DIRS": True,
|
|
|
|
"OPTIONS": {
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
|
|
|
"context_processors": [
|
|
|
|
"django.template.context_processors.debug",
|
|
|
|
"django.template.context_processors.request",
|
|
|
|
"django.contrib.auth.context_processors.auth",
|
|
|
|
"django.template.context_processors.i18n",
|
|
|
|
"django.template.context_processors.media",
|
|
|
|
"django.template.context_processors.static",
|
|
|
|
"django.template.context_processors.tz",
|
|
|
|
"django.contrib.messages.context_processors.messages",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
# FIXTURES
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
|
|
|
|
FIXTURE_DIRS = (str(APPS_DIR / "fixtures"),)
|
|
|
|
|
|
|
|
# SECURITY
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
|
|
|
|
SESSION_COOKIE_HTTPONLY = True
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
|
|
|
|
CSRF_COOKIE_HTTPONLY = True
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
|
|
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
|
|
|
|
X_FRAME_OPTIONS = "DENY"
|
|
|
|
|
|
|
|
# ADMIN
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Django Admin URL.
|
|
|
|
ADMIN_URL = "admin/"
|
|
|
|
|
|
|
|
# LOGGING
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
|
|
|
LOGGING = {
|
|
|
|
"version": 1,
|
|
|
|
"disable_existing_loggers": False,
|
|
|
|
"formatters": {
|
|
|
|
"verbose": {
|
|
|
|
"format": "%(levelname)s %(asctime)s %(module)s "
|
|
|
|
"%(process)d %(thread)d %(message)s"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"handlers": {
|
|
|
|
"console": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"formatter": "verbose",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"root": {"level": "INFO", "handlers": ["console"]},
|
|
|
|
}
|
|
|
|
|
|
|
|
# django-rest-framework
|
|
|
|
# -------------------------------------------------------------------------------
|
|
|
|
REST_FRAMEWORK = {
|
|
|
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
|
|
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
|
|
|
),
|
|
|
|
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
|
|
|
|
}
|
|
|
|
|
|
|
|
# django-cors-headers
|
|
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
2022-08-26 20:04:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Celery
|
2022-08-27 19:20:20 +03:00
|
|
|
CELERY_BROKER_URL = "redis://redis:6379"
|
|
|
|
CELERY_RESULT_BACKEND = "redis://redis:6379"
|
2022-08-26 20:04:45 +03:00
|
|
|
CELERY_TIMEZONE = "Europe/Moscow"
|
|
|
|
CELERY_TASK_TRACK_STARTED = True
|
|
|
|
CELERY_TASK_TIME_LIMIT = 30 * 60
|
2022-08-27 10:16:21 +03:00
|
|
|
CELERY_ACCEPT_CONTENT = ["json"]
|
|
|
|
CELERY_TASK_SERIALIZER = "json"
|
|
|
|
CELERY_RESULT_SERIALIZER = "json"
|