2022-05-03 18:02:04 -07:00
|
|
|
"""
|
|
|
|
|
Django settings for threadchat project.
|
|
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 4.0.4.
|
|
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
|
https://docs.djangoproject.com/en/4.0/topics/settings/
|
|
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
|
https://docs.djangoproject.com/en/4.0/ref/settings/
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
from typing import Sequence
|
2022-05-07 14:51:26 -07:00
|
|
|
import environ
|
|
|
|
|
|
|
|
|
|
env = environ.Env()
|
|
|
|
|
environ.Env.read_env()
|
2022-05-03 18:02:04 -07:00
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
|
|
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
|
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
2022-05-07 14:51:26 -07:00
|
|
|
SECRET_KEY = env("SECRET_KEY")
|
2022-05-03 18:02:04 -07:00
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
|
|
with open("ALLOWED_HOSTS") as fp:
|
|
|
|
|
ALLOWED_HOSTS: Sequence[str] = list(filter(len, map(str.strip, fp)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
|
"django.contrib.admin",
|
|
|
|
|
"django.contrib.auth",
|
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
|
"django.contrib.sessions",
|
|
|
|
|
"django.contrib.messages",
|
|
|
|
|
"django.contrib.staticfiles",
|
2022-06-26 21:30:45 -07:00
|
|
|
"guardian",
|
2022-06-28 21:37:45 -07:00
|
|
|
"colorfield",
|
2022-05-03 18:02:04 -07:00
|
|
|
"board",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
ROOT_URLCONF = "threadchat.urls"
|
|
|
|
|
|
|
|
|
|
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",
|
2022-07-17 18:17:31 -07:00
|
|
|
"board.context_processors.settings",
|
2022-05-03 18:02:04 -07:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
WSGI_APPLICATION = "threadchat.wsgi.application"
|
|
|
|
|
|
2022-06-26 21:30:45 -07:00
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
|
"django.contrib.auth.backends.ModelBackend",
|
|
|
|
|
"guardian.backends.ObjectPermissionBackend",
|
|
|
|
|
)
|
|
|
|
|
|
2022-05-03 18:02:04 -07:00
|
|
|
|
|
|
|
|
# Database
|
|
|
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
|
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
|
"default": {
|
|
|
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
|
|
|
"NAME": BASE_DIR / "db.sqlite3",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
|
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
|
|
|
|
|
|
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
|
|
2022-05-07 14:19:06 -07:00
|
|
|
TIME_ZONE = "US/Pacific"
|
2022-05-03 18:02:04 -07:00
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
2022-07-13 15:19:20 -07:00
|
|
|
GUARDIAN_RENDER_403 = True
|
2022-05-03 18:02:04 -07:00
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
|
|
|
|
|
|
|
|
|
STATIC_URL = "static/"
|
|
|
|
|
|
|
|
|
|
# Default primary key field type
|
|
|
|
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
|
|
|
|
|
2022-06-10 18:38:05 -07:00
|
|
|
# X-Frame-Options header from XFrameOptionsMiddleware
|
|
|
|
|
X_FRAME_OPTIONS = "SAMEORIGIN"
|
|
|
|
|
|
2022-05-03 18:02:04 -07:00
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
2022-05-04 19:45:36 -07:00
|
|
|
|
2022-07-17 18:17:31 -07:00
|
|
|
# Site name
|
|
|
|
|
SITE_NAME = "interchan"
|
|
|
|
|
|
2022-05-04 19:45:36 -07:00
|
|
|
# Media root - where media files are stored on the disk
|
|
|
|
|
MEDIA_ROOT = "media/"
|
|
|
|
|
|
|
|
|
|
# Media URL - the URL where media is served from
|
|
|
|
|
MEDIA_URL = "media/"
|
|
|
|
|
|
2022-06-24 16:21:41 -07:00
|
|
|
# Thumbnail size in pixels.
|
2022-05-04 19:45:36 -07:00
|
|
|
THUMB_SIZE = (200, 200)
|
2022-05-04 21:14:00 -07:00
|
|
|
|
2022-06-24 16:21:41 -07:00
|
|
|
# Max upload size in bytes.
|
2022-05-04 21:14:00 -07:00
|
|
|
MAX_UPLOAD_SIZE = 25 * 1024**2
|
2022-05-07 14:51:26 -07:00
|
|
|
|
2022-06-24 16:21:41 -07:00
|
|
|
# Whether to use HCAPTCHA or not.
|
2022-05-07 14:51:26 -07:00
|
|
|
USE_HCAPTCHA = False
|
|
|
|
|
|
|
|
|
|
if USE_HCAPTCHA:
|
|
|
|
|
INSTALLED_APPS += ["hcaptcha"]
|
|
|
|
|
HCAPTCHA_SITEKEY = env("HCAPTCHA_SITEKEY")
|
|
|
|
|
HCAPTCHA_SECRET = env("HCAPTCHA_SECRET")
|
2022-06-24 16:21:41 -07:00
|
|
|
|
|
|
|
|
# How many seconds to wait before closing the report window after a report is
|
|
|
|
|
# created.
|
2022-07-17 15:08:33 -07:00
|
|
|
# By default, wait 3 seconds. This should give users plenty of time to read it.
|
|
|
|
|
REPORT_WINDOW_CLOSE_TIMEOUT = 3
|
2022-06-24 16:21:41 -07:00
|
|
|
|
|
|
|
|
# How many seconds to wait before closing the ban window after a ban is created.
|
|
|
|
|
# By default, wait 0 seconds and close immediately. It is assumed that the ban
|
|
|
|
|
# is created successfully, and if an error occurs, the window won't close anyway.
|
2022-07-17 15:08:33 -07:00
|
|
|
ACTION_SUCCESS_CLOSE_TIMEOUT = 0
|
2022-06-25 20:42:10 -07:00
|
|
|
|
|
|
|
|
# How many seconds to wait before closing the new post window after a post is
|
|
|
|
|
# created.
|
|
|
|
|
# By default, wait 0 seconds. If there is an error, the window won't close
|
|
|
|
|
# because it will be redirected elsewhere.
|
|
|
|
|
POST_WINDOW_CLOSE_TIMEOUT = 0
|
2022-07-13 21:28:07 -07:00
|
|
|
|
|
|
|
|
# This is the length of a user's token, which is held in a server-side session.
|
|
|
|
|
# This token is used to identify a user's individual web client, outside of IP
|
|
|
|
|
# address. You probably don't need to change this.
|
|
|
|
|
# It should be at most 30, and probably at least 10.
|
|
|
|
|
USER_TOKEN_LENGTH = 30
|