158 lines
4.7 KiB
Python
158 lines
4.7 KiB
Python
"""
|
|
Django settings for test_project project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.0.10.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.0/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = "=yddl-40388w3e2hl$e8)revce=n67_idi8pfejtn3!+2%!_qt"
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
ADMIN_CONFIRM_DEBUG = True
|
|
|
|
USE_DOCKER = os.environ.get("USE_DOCKER", "").lower() == "true"
|
|
|
|
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
|
|
if USE_DOCKER:
|
|
import socket
|
|
|
|
ALLOWED_HOSTS += [socket.gethostbyname(socket.gethostname())]
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"admin_confirm",
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"storages",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.debug",
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.0/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",
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/3.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = "UTC"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
# Setting the hostnames of the services which we are running
|
|
# On github actions, services can be configured on the jobs themselves
|
|
# and can be accessed at localhost. See: https://docs.github.com/en/actions/guides/about-service-containers#communicating-with-service-containers
|
|
|
|
LOCALSTACK_HOST = os.getenv("LOCALSTACK_HOST", "localhost")
|
|
SELENIUM_HOST = os.getenv("SELENIUM_HOST", "localhost")
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
|
|
|
# STATIC_URL = "/static/"
|
|
|
|
# S3 Storage settings
|
|
|
|
USE_S3 = os.getenv("USE_S3", "true").lower() == "true"
|
|
|
|
if USE_S3:
|
|
# aws settings
|
|
AWS_S3_ENDPOINT_URL = f"http://{LOCALSTACK_HOST}:4566"
|
|
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID", "test")
|
|
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY", "test")
|
|
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME", "mybucket")
|
|
AWS_DEFAULT_ACL = None
|
|
AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"
|
|
AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"}
|
|
# s3 static settings
|
|
STATIC_LOCATION = "static"
|
|
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{STATIC_LOCATION}/"
|
|
STATICFILES_STORAGE = "tests.storage_backends.StaticStorage"
|
|
# s3 public media settings
|
|
PUBLIC_MEDIA_LOCATION = "media"
|
|
MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/"
|
|
DEFAULT_FILE_STORAGE = "tests.storage_backends.PublicMediaStorage"
|
|
else:
|
|
STATIC_URL = "/staticfiles/"
|
|
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
|
MEDIA_URL = "/mediafiles/"
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
|
|
|
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
|