|
@ -24,24 +24,15 @@ BASE_DIR = path.dirname(path.dirname(path.abspath(__file__))) |
|
|
env = Env() |
|
|
env = Env() |
|
|
env.read_env(path.join(BASE_DIR, ".env"), recurse=False) |
|
|
env.read_env(path.join(BASE_DIR, ".env"), recurse=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production |
|
|
# Quick-start development settings - unsuitable for production |
|
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ |
|
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ |
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret! |
|
|
# SECURITY WARNING: keep the secret key used in production secret! |
|
|
SECRET_KEY = env("SECRET_KEY", "v8sk33sy82!uw3ty=!jjv5vp7=s2phrzw(m(hrn^f7e_#1h2al") |
|
|
SECRET_KEY = env("SECRET_KEY", "v8sk33sy82!uw3ty=!jjv5vp7=s2phrzw(m(hrn^f7e_#1h2al") |
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production! |
|
|
# SECURITY WARNING: don't run with debug turned on in production! |
|
|
DEBUG = env.bool("DEBUG", True) |
|
|
DEBUG = env.bool("DEBUG", True) |
|
|
|
|
|
|
|
|
# True if you want to allow users to be able to create an account |
|
|
|
|
|
ALLOW_SIGNUP = env.bool("ALLOW_SIGNUP", True) |
|
|
|
|
|
|
|
|
|
|
|
# ALLOWED_HOSTS = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition |
|
|
# Application definition |
|
|
|
|
|
|
|
|
INSTALLED_APPS = [ |
|
|
INSTALLED_APPS = [ |
|
|
"whitenoise.runserver_nostatic", |
|
|
"whitenoise.runserver_nostatic", |
|
|
"django.contrib.admin", |
|
|
"django.contrib.admin", |
|
@ -89,12 +80,13 @@ MIDDLEWARE = [ |
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware", |
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware", |
|
|
"corsheaders.middleware.CorsMiddleware", |
|
|
"corsheaders.middleware.CorsMiddleware", |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
if DEBUG: |
|
|
if DEBUG: |
|
|
MIDDLEWARE.append("api.middleware.RangesMiddleware") |
|
|
MIDDLEWARE.append("api.middleware.RangesMiddleware") |
|
|
|
|
|
|
|
|
ROOT_URLCONF = "config.urls" |
|
|
ROOT_URLCONF = "config.urls" |
|
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application" |
|
|
|
|
|
|
|
|
|
|
|
# Django templates |
|
|
TEMPLATES = [ |
|
|
TEMPLATES = [ |
|
|
{ |
|
|
{ |
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates", |
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates", |
|
@ -113,49 +105,32 @@ TEMPLATES = [ |
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images) |
|
|
# Static files (CSS, JavaScript, Images) |
|
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/ |
|
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/ |
|
|
|
|
|
|
|
|
STATIC_URL = "/static/" |
|
|
STATIC_URL = "/static/" |
|
|
STATIC_ROOT = path.join(BASE_DIR, "staticfiles") |
|
|
STATIC_ROOT = path.join(BASE_DIR, "staticfiles") |
|
|
|
|
|
|
|
|
STATICFILES_DIRS = [ |
|
|
STATICFILES_DIRS = [ |
|
|
path.join(BASE_DIR, "client/dist/static"), |
|
|
path.join(BASE_DIR, "client/dist/static"), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" |
|
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" |
|
|
|
|
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Auth settings |
|
|
AUTHENTICATION_BACKENDS = [ |
|
|
AUTHENTICATION_BACKENDS = [ |
|
|
"django.contrib.auth.backends.ModelBackend", |
|
|
"django.contrib.auth.backends.ModelBackend", |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
HEADER_AUTH_USER_NAME = env("HEADER_AUTH_USER_NAME", "") |
|
|
HEADER_AUTH_USER_NAME = env("HEADER_AUTH_USER_NAME", "") |
|
|
HEADER_AUTH_USER_GROUPS = env("HEADER_AUTH_USER_GROUPS", "") |
|
|
HEADER_AUTH_USER_GROUPS = env("HEADER_AUTH_USER_GROUPS", "") |
|
|
HEADER_AUTH_ADMIN_GROUP_NAME = env("HEADER_AUTH_ADMIN_GROUP_NAME", "") |
|
|
HEADER_AUTH_ADMIN_GROUP_NAME = env("HEADER_AUTH_ADMIN_GROUP_NAME", "") |
|
|
HEADER_AUTH_GROUPS_SEPERATOR = env("HEADER_AUTH_GROUPS_SEPERATOR", default=",") |
|
|
HEADER_AUTH_GROUPS_SEPERATOR = env("HEADER_AUTH_GROUPS_SEPERATOR", default=",") |
|
|
|
|
|
|
|
|
if HEADER_AUTH_USER_NAME and HEADER_AUTH_USER_GROUPS and HEADER_AUTH_ADMIN_GROUP_NAME: |
|
|
if HEADER_AUTH_USER_NAME and HEADER_AUTH_USER_GROUPS and HEADER_AUTH_ADMIN_GROUP_NAME: |
|
|
MIDDLEWARE.append("api.middleware.HeaderAuthMiddleware") |
|
|
MIDDLEWARE.append("api.middleware.HeaderAuthMiddleware") |
|
|
AUTHENTICATION_BACKENDS.append("django.contrib.auth.backends.RemoteUserBackend") |
|
|
AUTHENTICATION_BACKENDS.append("django.contrib.auth.backends.RemoteUserBackend") |
|
|
|
|
|
|
|
|
|
|
|
# Role settings |
|
|
ROLE_PROJECT_ADMIN = env("ROLE_PROJECT_ADMIN", "project_admin") |
|
|
ROLE_PROJECT_ADMIN = env("ROLE_PROJECT_ADMIN", "project_admin") |
|
|
ROLE_ANNOTATOR = env("ROLE_ANNOTATOR", "annotator") |
|
|
ROLE_ANNOTATOR = env("ROLE_ANNOTATOR", "annotator") |
|
|
ROLE_ANNOTATION_APPROVER = env("ROLE_ANNOTATION_APPROVER", "annotation_approver") |
|
|
ROLE_ANNOTATION_APPROVER = env("ROLE_ANNOTATION_APPROVER", "annotation_approver") |
|
|
|
|
|
|
|
|
# Database |
|
|
|
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases |
|
|
|
|
|
|
|
|
|
|
|
DATABASES = { |
|
|
|
|
|
"default": { |
|
|
|
|
|
"ENGINE": "django.db.backends.sqlite3", |
|
|
|
|
|
"NAME": path.join(BASE_DIR, "db.sqlite3"), |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation |
|
|
# Password validation |
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators |
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators |
|
|
|
|
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [ |
|
|
AUTH_PASSWORD_VALIDATORS = [ |
|
|
{ |
|
|
{ |
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", |
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", |
|
@ -195,17 +170,13 @@ REST_FRAMEWORK = { |
|
|
|
|
|
|
|
|
# Internationalization |
|
|
# Internationalization |
|
|
# https://docs.djangoproject.com/en/2.0/topics/i18n/ |
|
|
# https://docs.djangoproject.com/en/2.0/topics/i18n/ |
|
|
|
|
|
|
|
|
LANGUAGE_CODE = "en-us" |
|
|
LANGUAGE_CODE = "en-us" |
|
|
|
|
|
|
|
|
TIME_ZONE = "UTC" |
|
|
TIME_ZONE = "UTC" |
|
|
|
|
|
|
|
|
USE_I18N = True |
|
|
USE_I18N = True |
|
|
|
|
|
|
|
|
USE_L10N = True |
|
|
USE_L10N = True |
|
|
|
|
|
|
|
|
USE_TZ = True |
|
|
USE_TZ = True |
|
|
|
|
|
|
|
|
|
|
|
# Testing |
|
|
TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner" |
|
|
TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner" |
|
|
TEST_OUTPUT_DIR = path.join(BASE_DIR, "junitxml") |
|
|
TEST_OUTPUT_DIR = path.join(BASE_DIR, "junitxml") |
|
|
|
|
|
|
|
@ -222,6 +193,15 @@ if spec is not None: |
|
|
spec.loader.exec_module(module) |
|
|
spec.loader.exec_module(module) |
|
|
module.settings(locals(), test_runner=False) |
|
|
module.settings(locals(), test_runner=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Database |
|
|
|
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases |
|
|
|
|
|
DATABASES = { |
|
|
|
|
|
"default": { |
|
|
|
|
|
"ENGINE": "django.db.backends.sqlite3", |
|
|
|
|
|
"NAME": path.join(BASE_DIR, "db.sqlite3"), |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
# Change 'default' database configuration with $DATABASE_URL. |
|
|
# Change 'default' database configuration with $DATABASE_URL. |
|
|
DATABASES["default"].update( |
|
|
DATABASES["default"].update( |
|
|
dj_database_url.config( |
|
|
dj_database_url.config( |
|
@ -245,6 +225,8 @@ if DATABASES["default"].get("ENGINE") == "django.db.backends.mysql": |
|
|
if DATABASES["default"].get("ENGINE") == "sql_server.pyodbc": |
|
|
if DATABASES["default"].get("ENGINE") == "sql_server.pyodbc": |
|
|
DATABASES["default"].setdefault("OPTIONS", {}).setdefault("driver", "ODBC Driver 17 for SQL Server") |
|
|
DATABASES["default"].setdefault("OPTIONS", {}).setdefault("driver", "ODBC Driver 17 for SQL Server") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Sessions and CSRF |
|
|
# Honor the 'X-Forwarded-Proto' header for request.is_secure() |
|
|
# Honor the 'X-Forwarded-Proto' header for request.is_secure() |
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") |
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") |
|
|
SESSION_COOKIE_SECURE = env.bool("SESSION_COOKIE_SECURE", False) |
|
|
SESSION_COOKIE_SECURE = env.bool("SESSION_COOKIE_SECURE", False) |
|
@ -254,18 +236,16 @@ CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", []) |
|
|
# Allow all host headers |
|
|
# Allow all host headers |
|
|
ALLOWED_HOSTS = ["*"] |
|
|
ALLOWED_HOSTS = ["*"] |
|
|
|
|
|
|
|
|
# Size of the batch for creating documents |
|
|
|
|
|
# on the import phase |
|
|
|
|
|
|
|
|
# Batch size for importing data |
|
|
IMPORT_BATCH_SIZE = env.int("IMPORT_BATCH_SIZE", 1000) |
|
|
IMPORT_BATCH_SIZE = env.int("IMPORT_BATCH_SIZE", 1000) |
|
|
|
|
|
|
|
|
# necessary for email verification of new accounts |
|
|
|
|
|
|
|
|
# Necessary for email verification of new accounts |
|
|
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", False) |
|
|
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", False) |
|
|
EMAIL_HOST = env("EMAIL_HOST", None) |
|
|
EMAIL_HOST = env("EMAIL_HOST", None) |
|
|
EMAIL_HOST_USER = env("EMAIL_HOST_USER", None) |
|
|
EMAIL_HOST_USER = env("EMAIL_HOST_USER", None) |
|
|
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD", None) |
|
|
EMAIL_HOST_PASSWORD = env("EMAIL_HOST_PASSWORD", None) |
|
|
EMAIL_PORT = env.int("EMAIL_PORT", 587) |
|
|
EMAIL_PORT = env.int("EMAIL_PORT", 587) |
|
|
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL", "webmaster@localhost") |
|
|
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL", "webmaster@localhost") |
|
|
|
|
|
|
|
|
if not EMAIL_HOST: |
|
|
if not EMAIL_HOST: |
|
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" |
|
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" |
|
|
|
|
|
|
|
@ -273,10 +253,11 @@ if not EMAIL_HOST: |
|
|
if DEBUG: |
|
|
if DEBUG: |
|
|
CORS_ORIGIN_WHITELIST = ("http://127.0.0.1:3000", "http://0.0.0.0:3000", "http://localhost:3000") |
|
|
CORS_ORIGIN_WHITELIST = ("http://127.0.0.1:3000", "http://0.0.0.0:3000", "http://localhost:3000") |
|
|
|
|
|
|
|
|
|
|
|
# User media files |
|
|
MEDIA_ROOT = path.join(BASE_DIR, "media") |
|
|
MEDIA_ROOT = path.join(BASE_DIR, "media") |
|
|
MEDIA_URL = "/media/" |
|
|
MEDIA_URL = "/media/" |
|
|
|
|
|
|
|
|
# Filepond settings. |
|
|
|
|
|
|
|
|
# Filepond settings |
|
|
DJANGO_DRF_FILEPOND_UPLOAD_TMP = path.join(BASE_DIR, "filepond-temp-uploads") |
|
|
DJANGO_DRF_FILEPOND_UPLOAD_TMP = path.join(BASE_DIR, "filepond-temp-uploads") |
|
|
DJANGO_DRF_FILEPOND_FILE_STORE_PATH = MEDIA_ROOT |
|
|
DJANGO_DRF_FILEPOND_FILE_STORE_PATH = MEDIA_ROOT |
|
|
|
|
|
|
|
|